mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Namhyung Kim" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Namhyung Kim <namhyung@kernel.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: perf/core] perf/core: Simplify __detach_global_ctx_data()
Date: Sat, 28 Feb 2026 10:56:47 -0000	[thread overview]
Message-ID: <177227620714.1647592.9729034731958013027.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260211223222.3119790-4-namhyung@kernel.org>

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     da45c8d5f051434a3c68397e66ae2d3b3c97cdec
Gitweb:        https://git.kernel.org/tip/da45c8d5f051434a3c68397e66ae2d3b3c97cdec
Author:        Namhyung Kim <namhyung@kernel.org>
AuthorDate:    Wed, 11 Feb 2026 14:32:21 -08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 27 Feb 2026 16:40:22 +01:00

perf/core: Simplify __detach_global_ctx_data()

Like in the attach_global_ctx_data() it has a O(N^2) loop to delete task
context data for each thread.  But perf_free_ctx_data_rcu() can be
called under RCU read lock, so just calls it directly rather than
iterating the whole thread list again.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260211223222.3119790-4-namhyung@kernel.org
---
 kernel/events/core.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index d357714..5eeae86 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5560,22 +5560,15 @@ static void __detach_global_ctx_data(void)
 	struct task_struct *g, *p;
 	struct perf_ctx_data *cd;
 
-again:
 	scoped_guard (rcu) {
 		for_each_process_thread(g, p) {
 			cd = rcu_dereference(p->perf_ctx_data);
-			if (!cd || !cd->global)
-				continue;
-			cd->global = 0;
-			get_task_struct(p);
-			goto detach;
+			if (cd && cd->global) {
+				cd->global = 0;
+				detach_task_ctx_data(p);
+			}
 		}
 	}
-	return;
-detach:
-	detach_task_ctx_data(p);
-	put_task_struct(p);
-	goto again;
 }
 
 static void detach_global_ctx_data(void)

  reply	other threads:[~2026-02-28 10:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-11 22:32 [PATCH 0/3] perf/core: Optimize LBR callstack handling Namhyung Kim
2026-02-11 22:32 ` [PATCH 1/3] perf/core: Pass GFP flags to attach_task_ctx_data() Namhyung Kim
2026-02-28 10:56   ` [tip: perf/core] " tip-bot2 for Namhyung Kim
2026-02-11 22:32 ` [PATCH 2/3] perf/core: Try to allocate task_ctx_data quickly Namhyung Kim
2026-02-28 10:56   ` [tip: perf/core] " tip-bot2 for Namhyung Kim
2026-02-11 22:32 ` [PATCH 3/3] perf/core: Simplify __detach_global_ctx_data() Namhyung Kim
2026-02-28 10:56   ` tip-bot2 for Namhyung Kim [this message]
2026-02-26 12:07 ` [PATCH 0/3] perf/core: Optimize LBR callstack handling Peter Zijlstra
2026-02-26 18:26   ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=177227620714.1647592.9729034731958013027.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®