diff --git a/kernel/events/core.c b/kernel/events/core.c index 01d4fe68e57b3..cb8744a1b1206 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1761,7 +1761,16 @@ static int __perf_event_enable(void *info) struct perf_cpu_context *cpuctx = __get_cpu_context(ctx); int err; - if (WARN_ON_ONCE(!ctx->is_active)) + /* + * There's a time window between 'ctx->is_active' check + * in perf_event_enable function and this place having: + * - IRQs on + * - ctx->lock unlocked + * + * where the task could be killed and 'ctx' deactivated + * by perf_event_exit_task. + */ + if (!ctx->is_active) return -EINVAL; raw_spin_lock(&ctx->lock);