Skip to content

Commit

Permalink
perf_events: Fix FORK events
Browse files Browse the repository at this point in the history
Commit 22e1908 ("Honour event state for aux stream data")
introduced a bug where we would drop FORK events.

The thing is that we deliver FORK events to the child process'
event, which at that time will be PERF_EVENT_STATE_INACTIVE
because the child won't be scheduled in (we're in the middle of
fork).

Solve this twice, change the event state filter to exclude only
disabled (STATE_OFF) or worse, and deliver FORK events to the
current (parent).

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Anton Blanchard <anton@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
LKML-Reference: <1266142324.5273.411.camel@laptop>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Feb 14, 2010
1 parent 1a72cfa commit 6f93d0a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -3259,16 +3259,14 @@ static void perf_event_task_output(struct perf_event *event,
task_event->event_id.tid = perf_event_tid(event, task);
task_event->event_id.ptid = perf_event_tid(event, current);

task_event->event_id.time = perf_clock();

perf_output_put(&handle, task_event->event_id);

perf_output_end(&handle);
}

static int perf_event_task_match(struct perf_event *event)
{
if (event->state != PERF_EVENT_STATE_ACTIVE)
if (event->state < PERF_EVENT_STATE_INACTIVE)
return 0;

if (event->cpu != -1 && event->cpu != smp_processor_id())
Expand Down Expand Up @@ -3300,7 +3298,7 @@ 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);
if (!ctx)
ctx = rcu_dereference(task_event->task->perf_event_ctxp);
ctx = rcu_dereference(current->perf_event_ctxp);
if (ctx)
perf_event_task_ctx(ctx, task_event);
put_cpu_var(perf_cpu_context);
Expand Down Expand Up @@ -3331,6 +3329,7 @@ static void perf_event_task(struct task_struct *task,
/* .ppid */
/* .tid */
/* .ptid */
.time = perf_clock(),
},
};

Expand Down Expand Up @@ -3380,7 +3379,7 @@ static void perf_event_comm_output(struct perf_event *event,

static int perf_event_comm_match(struct perf_event *event)
{
if (event->state != PERF_EVENT_STATE_ACTIVE)
if (event->state < PERF_EVENT_STATE_INACTIVE)
return 0;

if (event->cpu != -1 && event->cpu != smp_processor_id())
Expand Down Expand Up @@ -3500,7 +3499,7 @@ 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->state != PERF_EVENT_STATE_ACTIVE)
if (event->state < PERF_EVENT_STATE_INACTIVE)
return 0;

if (event->cpu != -1 && event->cpu != smp_processor_id())
Expand Down

0 comments on commit 6f93d0a

Please sign in to comment.