Skip to content

Commit b25756d

Browse files
ahunter6acmel
authored andcommitted
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 <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 256d92b commit b25756d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/perf/util/session.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,13 @@ struct thread *perf_session__findnew(struct perf_session *session, pid_t pid)
15271527
return machine__findnew_thread(&session->machines.host, -1, pid);
15281528
}
15291529

1530+
/*
1531+
* Threads are identified by pid and tid, and the idle task has pid == tid == 0.
1532+
* So here a single thread is created for that, but actually there is a separate
1533+
* idle task per cpu, so there should be one 'struct thread' per cpu, but there
1534+
* is only 1. That causes problems for some tools, requiring workarounds. For
1535+
* example get_idle_thread() in builtin-sched.c, or thread_stack__per_cpu().
1536+
*/
15301537
int perf_session__register_idle_thread(struct perf_session *session)
15311538
{
15321539
struct thread *thread;

0 commit comments

Comments
 (0)