[<prev] [next>] [day] [month] [year] [list]
Message-ID: <172361423558.2215.17332323799213170213.tip-bot2@tip-bot2>
Date: Wed, 14 Aug 2024 05:43:55 -0000
From: "tip-bot2 for Namhyung Kim" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Pengfei Xu <pengfei.xu@...el.com>,
Naresh Kamboju <naresh.kamboju@...aro.org>,
Namhyung Kim <namhyung@...nel.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: perf/core] perf: Really fix event_function_call() locking
The following commit has been merged into the perf/core branch of tip:
Commit-ID: fe826cc2654e8561b64246325e6a51b62bf2488c
Gitweb: https://git.kernel.org/tip/fe826cc2654e8561b64246325e6a51b62bf2488c
Author: Namhyung Kim <namhyung@...nel.org>
AuthorDate: Tue, 13 Aug 2024 22:55:11 +02:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Wed, 14 Aug 2024 07:39:09 +02:00
perf: Really fix event_function_call() locking
Commit 558abc7e3f89 ("perf: Fix event_function_call() locking") lost
IRQ disabling by mistake.
Fixes: 558abc7e3f89 ("perf: Fix event_function_call() locking")
Reported-by: Pengfei Xu <pengfei.xu@...el.com>
Reported-by: Naresh Kamboju <naresh.kamboju@...aro.org>
Tested-by: Pengfei Xu <pengfei.xu@...el.com>
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
---
kernel/events/core.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 9893ba5..c6a720f 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -298,8 +298,8 @@ unlock:
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 @@ again:
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();
}
/*
Powered by blists - more mailing lists