Commit fe826cc2 authored by Namhyung Kim's avatar Namhyung Kim Committed by Peter Zijlstra
Browse files

perf: Really fix event_function_call() locking



Commit 558abc7e ("perf: Fix event_function_call() locking") lost
IRQ disabling by mistake.

Fixes: 558abc7e ("perf: Fix event_function_call() locking")
Reported-by: default avatarPengfei Xu <pengfei.xu@intel.com>
Reported-by: default avatarNaresh Kamboju <naresh.kamboju@linaro.org>
Tested-by: default avatarPengfei Xu <pengfei.xu@intel.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
parent 3e15a3fe
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -298,8 +298,8 @@ static int event_function(void *info)
static void event_function_call(struct perf_event *event, event_f func, void *data)
{
	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 perf_cpu_context *cpuctx;
	struct event_function_struct efs = {
		.event = event,
		.func = func,
@@ -327,22 +327,25 @@ static void event_function_call(struct perf_event *event, event_f func, void *da
	if (!task_function_call(task, event_function, &efs))
		return;

	local_irq_disable();
	cpuctx = this_cpu_ptr(&perf_cpu_context);
	perf_ctx_lock(cpuctx, ctx);
	/*
	 * Reload the task pointer, it might have been changed by
	 * a concurrent perf_event_context_sched_out().
	 */
	task = ctx->task;
	if (task == TASK_TOMBSTONE) {
		perf_ctx_unlock(cpuctx, ctx);
		return;
	}
	if (task == TASK_TOMBSTONE)
		goto unlock;
	if (ctx->is_active) {
		perf_ctx_unlock(cpuctx, ctx);
		local_irq_enable();
		goto again;
	}
	func(event, NULL, ctx, data);
unlock:
	perf_ctx_unlock(cpuctx, ctx);
	local_irq_enable();
}

/*