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>

authored by Adrian Hunter and committed by Arnaldo Carvalho de Melo b25756df 256d92bc

Changed files
+7
tools
perf
util
+7
tools/perf/util/session.c
··· 1527 1527 return machine__findnew_thread(&session->machines.host, -1, pid); 1528 1528 } 1529 1529 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 + */ 1530 1537 int perf_session__register_idle_thread(struct perf_session *session) 1531 1538 { 1532 1539 struct thread *thread;