mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cruz Zhao <CruzZhao@linux.alibaba.com>
To: mingo@redhat.com, peterz@infradead.org, acme@kernel.org,
	mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
	jolsa@kernel.org, namhyung@kernel.org, irogers@google.com,
	adrian.hunter@intel.com, kprateek.nayak@amd.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] perf: ignore exited thread when synthesize thread map
Date: Wed, 22 Nov 2023 10:21:54 +0800	[thread overview]
Message-ID: <20231122022154.12772-1-CruzZhao@linux.alibaba.com> (raw)

When synthesize thread map, some threads in thread map may have
already exited, so that __event__synthesize_thread() returns -1
and the synthesis breaks. However, It will not have any effect
if we just ignore the exited thread. So just ignore it and continue.

Signed-off-by: Cruz Zhao <CruzZhao@linux.alibaba.com>
---
 tools/perf/util/synthetic-events.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
index a0579c7d7b9e..43ad2298a933 100644
--- a/tools/perf/util/synthetic-events.c
+++ b/tools/perf/util/synthetic-events.c
@@ -866,14 +866,16 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
 
 	err = 0;
 	for (thread = 0; thread < threads->nr; ++thread) {
+		/*
+		 * We may race with exiting thread, so don't stop just because
+		 * one thread couldn't be synthesized.
+		 */
 		if (__event__synthesize_thread(comm_event, mmap_event,
 					       fork_event, namespaces_event,
 					       perf_thread_map__pid(threads, thread), 0,
 					       process, tool, machine,
-					       needs_mmap, mmap_data)) {
-			err = -1;
-			break;
-		}
+					       needs_mmap, mmap_data))
+			continue;
 
 		/*
 		 * comm.pid is set to thread group id by
-- 
2.39.3


             reply	other threads:[~2023-11-22  2:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-22  2:21 Cruz Zhao [this message]
2023-11-22 21:05 ` Namhyung Kim
2023-11-28  6:22   ` cruzzhao
2023-11-28 17:12     ` Ian Rogers
2023-12-05 17:54       ` Ian Rogers

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=20231122022154.12772-1-CruzZhao@linux.alibaba.com \
    --to=cruzzhao@linux.alibaba.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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®