Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223836
b: refs/heads/master
c: 6c7e550
h: refs/heads/master
v: v3
  • Loading branch information
Franck Bui-Huu authored and Ingo Molnar committed Nov 26, 2010
1 parent f6337f5 commit 6d8e85f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 35d3778a8fe3c8b4a7513565e34d3bde00ce43ec
refs/heads/master: 6c7e550f13f8ad82efb6a5653ae628c2543c1768
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/cpu/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ static int x86_setup_perfctr(struct perf_event *event)
struct hw_perf_event *hwc = &event->hw;
u64 config;

if (!hwc->sample_period) {
if (!is_sampling_event(event)) {
hwc->sample_period = x86_pmu.max_period;
hwc->last_period = hwc->sample_period;
local64_set(&hwc->period_left, hwc->sample_period);
Expand Down
5 changes: 5 additions & 0 deletions trunk/include/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,11 @@ extern int perf_event_overflow(struct perf_event *event, int nmi,
struct perf_sample_data *data,
struct pt_regs *regs);

static inline bool is_sampling_event(struct perf_event *event)
{
return event->attr.sample_period != 0;
}

/*
* Return 1 for a software event, 0 for a hardware event
*/
Expand Down
10 changes: 5 additions & 5 deletions trunk/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2514,7 +2514,7 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
int ret = 0;
u64 value;

if (!event->attr.sample_period)
if (!is_sampling_event(event))
return -EINVAL;

if (copy_from_user(&value, arg, sizeof(value)))
Expand Down Expand Up @@ -4385,7 +4385,7 @@ static void perf_swevent_event(struct perf_event *event, u64 nr,
if (!regs)
return;

if (!hwc->sample_period)
if (!is_sampling_event(event))
return;

if (nr == 1 && hwc->sample_period == 1 && !event->attr.freq)
Expand Down Expand Up @@ -4548,7 +4548,7 @@ static int perf_swevent_add(struct perf_event *event, int flags)
struct hw_perf_event *hwc = &event->hw;
struct hlist_head *head;

if (hwc->sample_period) {
if (is_sampling_event(event)) {
hwc->last_period = hwc->sample_period;
perf_swevent_set_period(event);
}
Expand Down Expand Up @@ -4920,7 +4920,7 @@ static void perf_swevent_start_hrtimer(struct perf_event *event)

hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hwc->hrtimer.function = perf_swevent_hrtimer;
if (hwc->sample_period) {
if (is_sampling_event(event)) {
s64 period = local64_read(&hwc->period_left);

if (period) {
Expand All @@ -4941,7 +4941,7 @@ static void perf_swevent_cancel_hrtimer(struct perf_event *event)
{
struct hw_perf_event *hwc = &event->hw;

if (hwc->sample_period) {
if (is_sampling_event(event)) {
ktime_t remaining = hrtimer_get_remaining(&hwc->hrtimer);
local64_set(&hwc->period_left, ktime_to_ns(remaining));

Expand Down

0 comments on commit 6d8e85f

Please sign in to comment.