Skip to content

Commit

Permalink
perf_counter: Fix COMM and MMAP events for cpu wide counters
Browse files Browse the repository at this point in the history
Commit a63eaf3 ("perf_counter: Dynamically allocate tasks'
perf_counter_context struct") broke COMM and MMAP notification for
cpu wide counters by dropping out early if there was no task context,
thereby also not iterating the cpu context.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 29, 2009
1 parent 012b84d commit efb3d17
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2443,9 +2443,9 @@ static void perf_counter_comm_event(struct perf_comm_event *comm_event)

cpuctx = &get_cpu_var(perf_cpu_context);
perf_counter_comm_ctx(&cpuctx->ctx, comm_event);
if (cpuctx->task_ctx)
perf_counter_comm_ctx(cpuctx->task_ctx, comm_event);
put_cpu_var(perf_cpu_context);

perf_counter_comm_ctx(current->perf_counter_ctxp, comm_event);
}

void perf_counter_comm(struct task_struct *task)
Expand All @@ -2454,8 +2454,6 @@ void perf_counter_comm(struct task_struct *task)

if (!atomic_read(&nr_comm_tracking))
return;
if (!current->perf_counter_ctxp)
return;

comm_event = (struct perf_comm_event){
.task = task,
Expand Down Expand Up @@ -2570,10 +2568,10 @@ static void perf_counter_mmap_event(struct perf_mmap_event *mmap_event)

cpuctx = &get_cpu_var(perf_cpu_context);
perf_counter_mmap_ctx(&cpuctx->ctx, mmap_event);
if (cpuctx->task_ctx)
perf_counter_mmap_ctx(cpuctx->task_ctx, mmap_event);
put_cpu_var(perf_cpu_context);

perf_counter_mmap_ctx(current->perf_counter_ctxp, mmap_event);

kfree(buf);
}

Expand All @@ -2584,8 +2582,6 @@ void perf_counter_mmap(unsigned long addr, unsigned long len,

if (!atomic_read(&nr_mmap_tracking))
return;
if (!current->perf_counter_ctxp)
return;

mmap_event = (struct perf_mmap_event){
.file = file,
Expand Down

0 comments on commit efb3d17

Please sign in to comment.