Skip to content

Commit

Permalink
perf events: Dont report side-band events on each cpu for per-task-pe…
Browse files Browse the repository at this point in the history
…r-cpu events

commit 5d27c23 upstream.

Acme noticed that his FORK/MMAP numbers were inflated by about
the same factor as his cpu-count.

This led to the discovery of a few more sites that need to
respect the event->cpu filter.

Reported-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <20091217121830.215333434@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Peter Zijlstra authored and Greg Kroah-Hartman committed Jan 25, 2010
1 parent 5a20267 commit b0a9392
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,9 @@ static void perf_ctx_adjust_freq(struct perf_event_context *ctx)
if (event->state != PERF_EVENT_STATE_ACTIVE)
continue;

if (event->cpu != -1 && event->cpu != smp_processor_id())
continue;

hwc = &event->hw;

interrupts = hwc->interrupts;
Expand Down Expand Up @@ -3226,6 +3229,9 @@ static void perf_event_task_output(struct perf_event *event,

static int perf_event_task_match(struct perf_event *event)
{
if (event->cpu != -1 && event->cpu != smp_processor_id())
return 0;

if (event->attr.comm || event->attr.mmap || event->attr.task)
return 1;

Expand Down Expand Up @@ -3255,13 +3261,13 @@ static void perf_event_task_event(struct perf_task_event *task_event)

cpuctx = &get_cpu_var(perf_cpu_context);
perf_event_task_ctx(&cpuctx->ctx, task_event);
put_cpu_var(perf_cpu_context);

rcu_read_lock();
if (!ctx)
ctx = rcu_dereference(task_event->task->perf_event_ctxp);
if (ctx)
perf_event_task_ctx(ctx, task_event);
put_cpu_var(perf_cpu_context);
rcu_read_unlock();
}

Expand Down Expand Up @@ -3338,6 +3344,9 @@ static void perf_event_comm_output(struct perf_event *event,

static int perf_event_comm_match(struct perf_event *event)
{
if (event->cpu != -1 && event->cpu != smp_processor_id())
return 0;

if (event->attr.comm)
return 1;

Expand Down Expand Up @@ -3378,7 +3387,6 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)

cpuctx = &get_cpu_var(perf_cpu_context);
perf_event_comm_ctx(&cpuctx->ctx, comm_event);
put_cpu_var(perf_cpu_context);

rcu_read_lock();
/*
Expand All @@ -3388,6 +3396,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
ctx = rcu_dereference(current->perf_event_ctxp);
if (ctx)
perf_event_comm_ctx(ctx, comm_event);
put_cpu_var(perf_cpu_context);
rcu_read_unlock();
}

Expand Down Expand Up @@ -3462,6 +3471,9 @@ static void perf_event_mmap_output(struct perf_event *event,
static int perf_event_mmap_match(struct perf_event *event,
struct perf_mmap_event *mmap_event)
{
if (event->cpu != -1 && event->cpu != smp_processor_id())
return 0;

if (event->attr.mmap)
return 1;

Expand Down Expand Up @@ -3539,7 +3551,6 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)

cpuctx = &get_cpu_var(perf_cpu_context);
perf_event_mmap_ctx(&cpuctx->ctx, mmap_event);
put_cpu_var(perf_cpu_context);

rcu_read_lock();
/*
Expand All @@ -3549,6 +3560,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
ctx = rcu_dereference(current->perf_event_ctxp);
if (ctx)
perf_event_mmap_ctx(ctx, mmap_event);
put_cpu_var(perf_cpu_context);
rcu_read_unlock();

kfree(buf);
Expand Down Expand Up @@ -3811,6 +3823,9 @@ static int perf_swevent_match(struct perf_event *event,
enum perf_type_id type,
u32 event_id, struct pt_regs *regs)
{
if (event->cpu != -1 && event->cpu != smp_processor_id())
return 0;

if (!perf_swevent_is_counting(event))
return 0;

Expand Down

0 comments on commit b0a9392

Please sign in to comment.