linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Adrian Hunter <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, adrian.hunter@intel.com,
	jolsa@kernel.org, acme@redhat.com, tglx@linutronix.de,
	mingo@kernel.org, hpa@zytor.com
Subject: [tip:perf/urgent] perf session: Add comment for perf_session__register_idle_thread()
Date: Thu, 3 Jan 2019 05:26:27 -0800	[thread overview]
Message-ID: <tip-b25756df5b28cd7b6e91200fc5012e7c76e8ec69@git.kernel.org> (raw)
In-Reply-To: <20181221120620.9659-9-adrian.hunter@intel.com>

Commit-ID:  b25756df5b28cd7b6e91200fc5012e7c76e8ec69
Gitweb:     https://git.kernel.org/tip/b25756df5b28cd7b6e91200fc5012e7c76e8ec69
Author:     Adrian Hunter <adrian.hunter@intel.com>
AuthorDate: Fri, 21 Dec 2018 14:06:20 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 2 Jan 2019 11:05:06 -0300

perf session: Add comment for perf_session__register_idle_thread()

Add a comment to perf_session__register_idle_thread() to bring attention to
a pitfall with the idle task thread structure. The pitfall is that there
should really be a 'struct thread' for the idle task of each cpu, but there
is only one that can have pid == tid == 0.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/r/20181221120620.9659-9-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/session.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 78a067777144..5456c84c7dd1 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1527,6 +1527,13 @@ struct thread *perf_session__findnew(struct perf_session *session, pid_t pid)
 	return machine__findnew_thread(&session->machines.host, -1, pid);
 }
 
+/*
+ * Threads are identified by pid and tid, and the idle task has pid == tid == 0.
+ * So here a single thread is created for that, but actually there is a separate
+ * idle task per cpu, so there should be one 'struct thread' per cpu, but there
+ * is only 1. That causes problems for some tools, requiring workarounds. For
+ * example get_idle_thread() in builtin-sched.c, or thread_stack__per_cpu().
+ */
 int perf_session__register_idle_thread(struct perf_session *session)
 {
 	struct thread *thread;

      reply	other threads:[~2019-01-03 13:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-21 12:06 [PATCH 0/8] perf thread-stack: Fix thread stack processing for the idle task Adrian Hunter
2018-12-21 12:06 ` [PATCH 1/8] perf thread-stack: Simplify some code in thread_stack__process() Adrian Hunter
2019-01-03 13:22   ` [tip:perf/urgent] " tip-bot for Adrian Hunter
2018-12-21 12:06 ` [PATCH 2/8] perf thread-stack: Tidy thread_stack__bottom() usage Adrian Hunter
2019-01-03 13:23   ` [tip:perf/urgent] " tip-bot for Adrian Hunter
2018-12-21 12:06 ` [PATCH 3/8] perf thread-stack: Avoid direct reference to the thread's stack Adrian Hunter
2019-01-02 13:47   ` Arnaldo Carvalho de Melo
2019-01-03 13:23   ` [tip:perf/urgent] " tip-bot for Adrian Hunter
2018-12-21 12:06 ` [PATCH 4/8] perf thread-stack: Allow for a thread stack array Adrian Hunter
2019-01-03 13:24   ` [tip:perf/urgent] " tip-bot for Adrian Hunter
2018-12-21 12:06 ` [PATCH 5/8] perf thread-stack: Factor out thread_stack__init() Adrian Hunter
2019-01-03 13:24   ` [tip:perf/urgent] " tip-bot for Adrian Hunter
2018-12-21 12:06 ` [PATCH 6/8] perf thread-stack: Allocate an array of thread stacks Adrian Hunter
2019-01-01 18:28   ` Jiri Olsa
2019-01-02 13:43     ` Arnaldo Carvalho de Melo
2019-01-03 13:25   ` [tip:perf/urgent] " tip-bot for Adrian Hunter
2018-12-21 12:06 ` [PATCH 8/8] perf session: Add comment for perf_session__register_idle_thread() Adrian Hunter
2019-01-03 13:26   ` tip-bot for Adrian Hunter [this message]

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=tip-b25756df5b28cd7b6e91200fc5012e7c76e8ec69@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).