Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: David Ahern <dsahern@gmail.com>
Acked-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1399856202-26221-1-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>

authored by

Namhyung Kim and committed by
Jiri Olsa
13ce34df bac1e4d1

+8 -5
+1 -1
tools/perf/builtin-inject.c
··· 209 209 210 210 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 211 211 212 - thread = machine__findnew_thread(machine, sample->pid, sample->pid); 212 + thread = machine__findnew_thread(machine, sample->pid, sample->tid); 213 213 if (thread == NULL) { 214 214 pr_err("problem processing %d event, skipping it.\n", 215 215 event->header.type);
+1 -1
tools/perf/builtin-kmem.c
··· 235 235 struct machine *machine) 236 236 { 237 237 struct thread *thread = machine__findnew_thread(machine, sample->pid, 238 - sample->pid); 238 + sample->tid); 239 239 240 240 if (thread == NULL) { 241 241 pr_debug("problem processing %d event, skipping it.\n",
+1 -1
tools/perf/tests/code-reading.c
··· 256 256 return -1; 257 257 } 258 258 259 - thread = machine__findnew_thread(machine, sample.pid, sample.pid); 259 + thread = machine__findnew_thread(machine, sample.pid, sample.tid); 260 260 if (!thread) { 261 261 pr_debug("machine__findnew_thread failed\n"); 262 262 return -1;
+1
tools/perf/tests/hists_filter.c
··· 69 69 evsel->hists.symbol_filter_str = NULL; 70 70 71 71 sample.pid = fake_samples[i].pid; 72 + sample.tid = fake_samples[i].pid; 72 73 sample.ip = fake_samples[i].ip; 73 74 74 75 if (perf_event__preprocess_sample(&event, machine, &al,
+2
tools/perf/tests/hists_link.c
··· 81 81 }; 82 82 83 83 sample.pid = fake_common_samples[k].pid; 84 + sample.tid = fake_common_samples[k].pid; 84 85 sample.ip = fake_common_samples[k].ip; 85 86 if (perf_event__preprocess_sample(&event, machine, &al, 86 87 &sample) < 0) ··· 105 104 }; 106 105 107 106 sample.pid = fake_samples[i][k].pid; 107 + sample.tid = fake_samples[i][k].pid; 108 108 sample.ip = fake_samples[i][k].ip; 109 109 if (perf_event__preprocess_sample(&event, machine, &al, 110 110 &sample) < 0)
+1 -1
tools/perf/util/build-id.c
··· 25 25 struct addr_location al; 26 26 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 27 27 struct thread *thread = machine__findnew_thread(machine, sample->pid, 28 - sample->pid); 28 + sample->tid); 29 29 30 30 if (thread == NULL) { 31 31 pr_err("problem processing %d event, skipping it.\n",
+1 -1
tools/perf/util/event.c
··· 788 788 { 789 789 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 790 790 struct thread *thread = machine__findnew_thread(machine, sample->pid, 791 - sample->pid); 791 + sample->tid); 792 792 793 793 if (thread == NULL) 794 794 return -1;