mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
perf: Really fix event_function_call() locking
Commit558abc7e3f("perf: Fix event_function_call() locking") lost IRQ disabling by mistake. Fixes:558abc7e3f("perf: Fix event_function_call() locking") Reported-by: Pengfei Xu <pengfei.xu@intel.com> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org> Tested-by: Pengfei Xu <pengfei.xu@intel.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
This commit is contained in:
committed by
Peter Zijlstra
parent
3e15a3fe3a
commit
fe826cc265
@@ -298,8 +298,8 @@ unlock:
|
|||||||
static void event_function_call(struct perf_event *event, event_f func, void *data)
|
static void event_function_call(struct perf_event *event, event_f func, void *data)
|
||||||
{
|
{
|
||||||
struct perf_event_context *ctx = event->ctx;
|
struct perf_event_context *ctx = event->ctx;
|
||||||
struct perf_cpu_context *cpuctx = this_cpu_ptr(&perf_cpu_context);
|
|
||||||
struct task_struct *task = READ_ONCE(ctx->task); /* verified in event_function */
|
struct task_struct *task = READ_ONCE(ctx->task); /* verified in event_function */
|
||||||
|
struct perf_cpu_context *cpuctx;
|
||||||
struct event_function_struct efs = {
|
struct event_function_struct efs = {
|
||||||
.event = event,
|
.event = event,
|
||||||
.func = func,
|
.func = func,
|
||||||
@@ -327,22 +327,25 @@ again:
|
|||||||
if (!task_function_call(task, event_function, &efs))
|
if (!task_function_call(task, event_function, &efs))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
local_irq_disable();
|
||||||
|
cpuctx = this_cpu_ptr(&perf_cpu_context);
|
||||||
perf_ctx_lock(cpuctx, ctx);
|
perf_ctx_lock(cpuctx, ctx);
|
||||||
/*
|
/*
|
||||||
* Reload the task pointer, it might have been changed by
|
* Reload the task pointer, it might have been changed by
|
||||||
* a concurrent perf_event_context_sched_out().
|
* a concurrent perf_event_context_sched_out().
|
||||||
*/
|
*/
|
||||||
task = ctx->task;
|
task = ctx->task;
|
||||||
if (task == TASK_TOMBSTONE) {
|
if (task == TASK_TOMBSTONE)
|
||||||
perf_ctx_unlock(cpuctx, ctx);
|
goto unlock;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ctx->is_active) {
|
if (ctx->is_active) {
|
||||||
perf_ctx_unlock(cpuctx, ctx);
|
perf_ctx_unlock(cpuctx, ctx);
|
||||||
|
local_irq_enable();
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
func(event, NULL, ctx, data);
|
func(event, NULL, ctx, data);
|
||||||
|
unlock:
|
||||||
perf_ctx_unlock(cpuctx, ctx);
|
perf_ctx_unlock(cpuctx, ctx);
|
||||||
|
local_irq_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user