Skip to content

Commit 1d5f003

Browse files
Gleb NatapovIngo Molnar
authored andcommitted
perf: Do not set task_ctx pointer in cpuctx if there are no events in the context
Do not set task_ctx pointer during sched_in if there are no events associated with the context. Otherwise if during task execution total number of events in the system will become zero perf_event_context_sched_out() will not be called and cpuctx->task_ctx will be left with a stale value. Signed-off-by: Gleb Natapov <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 57d1c0c commit 1d5f003

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/events/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,7 +2173,8 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
21732173

21742174
perf_event_sched_in(cpuctx, ctx, task);
21752175

2176-
cpuctx->task_ctx = ctx;
2176+
if (ctx->nr_events)
2177+
cpuctx->task_ctx = ctx;
21772178

21782179
perf_pmu_enable(ctx->pmu);
21792180
perf_ctx_unlock(cpuctx, ctx);

0 commit comments

Comments
 (0)