perf tools: Use tid for finding thread
Namhyung Kim
maintainerPATCH 1/1 perf tools: Use tid for finding thread
I believe that passing pid (instead of tid) as the 3rd arg of the machine__find*_thread() was to find a main thread so that it can search proper map group for symbols. However with the map sharing patch applied, it now can do it in any thread.
It fixes a bug when each thread has different name, it only reports a main thread for samples in other threads.
--- tools/perf/builtin-inject.c | 2 +- tools/perf/builtin-kmem.c | 2 +- tools/perf/tests/code-reading.c | 2 +- tools/perf/util/build-id.c | 2 +- tools/perf/util/event.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
tools/perf/builtin-inject.c +1 -1
@@ -209,7 +209,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; - thread =machine__findnew_thread (machine, sample->pid, sample->pid); + thread =machine__findnew_thread (machine, sample->pid, sample->tid);if (thread ==NULL ) {pr_err ("problem processing %d event, skipping it.\n" , event->header.type);
tools/perf/builtin-kmem.c +1 -1
@@ -235,7 +235,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused, struct machine *machine) {struct thread *thread =machine__findnew_thread (machine, sample->pid, - sample->pid); + sample->tid);if (thread ==NULL ) { pr_debug("problem processing %d event, skipping it.\n",
tools/perf/tests/code-reading.c +1 -1
@@ -256,7 +256,7 @@ static int process_sample_event(struct machine *machine,return -1 ; } - thread =machine__findnew_thread (machine, sample.pid, sample.pid); + thread =machine__findnew_thread (machine, sample.pid, sample.tid);if (!thread) {pr_debug ("machine__findnew_thread failed\n" );return -1 ;
tools/perf/util/build-id.c +1 -1
@@ -25,7 +25,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,struct addr_location al;u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;struct thread *thread =machine__findnew_thread (machine, sample->pid, - sample->pid); + sample->tid);if (thread ==NULL ) { pr_err("problem processing %d event, skipping it.\n",
tools/perf/util/event.c +1 -1
@@ -788,7 +788,7 @@ int perf_event__preprocess_sample(const union perf_event *event, {u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;struct thread *thread =machine__findnew_thread (machine, sample->pid, - sample->pid); + sample->tid);if (thread ==NULL )return -1 ;
Signature · 1 line
1.9.2
Quoted 6 lines · Namhyung Kim
I believe that passing pid (instead of tid) as the 3rd arg of the machine__find*_thread() was to find a main thread so that it can search proper map group for symbols. However with the map sharing patch applied, it now can do it in any thread.
Your patch makes the code more meaningful for sure.
The pid, pid looked like a bug to me at first, but then I realized, that yes, it is
look for the main thread.
Quoted 84 lines
It fixes a bug when each thread has different name, it only reports a main thread for samples in other threads.
Cc Adrian Hunter <[email protected]>Cc David Ahern <[email protected]>Cc Stephane Eranian <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/builtin-inject.c | 2 +- tools/perf/builtin-kmem.c | 2 +- tools/perf/tests/code-reading.c | 2 +- tools/perf/util/build-id.c | 2 +- tools/perf/util/event.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)tools/perf/builtin-inject.c +1
-1@@ -209,7 +209,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool, cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; - thread =machine__findnew_thread (machine, sample->pid, sample->pid); + thread =machine__findnew_thread (machine, sample->pid, sample->tid);if (thread ==NULL ) {pr_err ("problem processing %d event, skipping it.\n" , event->header.type);tools/perf/builtin-kmem.c +1
-1@@ -235,7 +235,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused, struct machine *machine) {struct thread *thread =machine__findnew_thread (machine, sample->pid, - sample->pid); + sample->tid);if (thread ==NULL ) { pr_debug("problem processing %d event, skipping it.\n",tools/perf/tests/code-reading.c +1
-1@@ -256,7 +256,7 @@ static int process_sample_event(struct machine *machine,return -1 ; } - thread =machine__findnew_thread (machine, sample.pid, sample.pid); + thread =machine__findnew_thread (machine, sample.pid, sample.tid);if (!thread) {pr_debug ("machine__findnew_thread failed\n" );return -1 ;tools/perf/util/build-id.c +1
-1@@ -25,7 +25,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,struct addr_location al;u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;struct thread *thread =machine__findnew_thread (machine, sample->pid, - sample->pid); + sample->tid);if (thread ==NULL ) { pr_err("problem processing %d event, skipping it.\n",tools/perf/util/event.c +1
-2@@ -788,7 +788,7 @@ int perf_event__preprocess_sample(const union perf_event *event, {u8 cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ;struct thread *thread =machine__findnew_thread (machine, sample->pid, - sample->pid); + sample->tid);if (thread ==NULL )return -1 ; --1.9.2
Quoted 5 lines · Namhyung Kim
I believe that passing pid (instead of tid) as the 3rd arg of the machine__find*_thread() was to find a main thread so that it can search proper map group for symbols. However with the map sharing patch applied, it now can do it in any thread.
Quoted 7 lines
It fixes a bug when each thread has different name, it only reports a main thread for samples in other threads.
Cc Adrian Hunter <[email protected]>Cc David Ahern <[email protected]>Cc Stephane Eranian <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
Quoted 7 lines · Namhyung Kim
I believe that passing pid (instead of tid) as the 3rd arg of the machine__find*_thread() was to find a main thread so that it can search proper map group for symbols. However with the map sharing patch applied, it now can do it in any thread.
It fixes a bug when each thread has different name, it only reports a main thread for samples in other threads.
and breaks tests 14 and 26 ;-)
...
14: Test matching and linking multiple hists : FAILED! 15: Try 'use perf' in python, checking link problems : Ok 16: Test breakpoint overflow signal handler : Ok 17: Test breakpoint overflow sampling : Ok 18: Test number of exit event of a simple workload : Ok 19: Test software clock events have valid period values : Ok 20: Test converting perf time to TSC : Ok 21: Test object code reading : Ok 22: Test sample parsing : Ok 23: Test using a dummy software event to keep tracking : Ok 24: Test parsing with no sample_id_all bit set : Ok 25: Test dwarf unwind : Ok 26: Test filtering hist entries : FAILED!
...
jirka
Namhyung Kim
maintainerQuoted 25 lines · Jiri Olsa
Quoted 7 lines · Namhyung Kim
I believe that passing pid (instead of tid) as the 3rd arg of the machine__find*_thread() was to find a main thread so that it can search proper map group for symbols. However with the map sharing patch applied, it now can do it in any thread.
It fixes a bug when each thread has different name, it only reports a main thread for samples in other threads.
and breaks tests 14 and 26 ;-)
...
14: Test matching and linking multiple hists : FAILED! 15: Try 'use perf' in python, checking link problems : Ok 16: Test breakpoint overflow signal handler : Ok 17: Test breakpoint overflow sampling : Ok 18: Test number of exit event of a simple workload : Ok 19: Test software clock events have valid period values : Ok 20: Test converting perf time to TSC : Ok 21: Test object code reading : Ok 22: Test sample parsing : Ok 23: Test using a dummy software event to keep tracking : Ok 24: Test parsing with no sample_id_all bit set : Ok 25: Test dwarf unwind : Ok 26: Test filtering hist entries : FAILED!
Quoted 1 line
...
Forgot to set sample->tid for those cases. Will fix.
Thanks,
Namhyung