Skip to content

Commit 13ce34d

Browse files
namhyungolsajiri
authored andcommitted
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>
1 parent bac1e4d commit 13ce34d

7 files changed

Lines changed: 8 additions & 5 deletions

File tree

tools/perf/builtin-inject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,
209209

210210
cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
211211

212-
thread = machine__findnew_thread(machine, sample->pid, sample->pid);
212+
thread = machine__findnew_thread(machine, sample->pid, sample->tid);
213213
if (thread == NULL) {
214214
pr_err("problem processing %d event, skipping it.\n",
215215
event->header.type);

tools/perf/builtin-kmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
235235
struct machine *machine)
236236
{
237237
struct thread *thread = machine__findnew_thread(machine, sample->pid,
238-
sample->pid);
238+
sample->tid);
239239

240240
if (thread == NULL) {
241241
pr_debug("problem processing %d event, skipping it.\n",

tools/perf/tests/code-reading.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static int process_sample_event(struct machine *machine,
256256
return -1;
257257
}
258258

259-
thread = machine__findnew_thread(machine, sample.pid, sample.pid);
259+
thread = machine__findnew_thread(machine, sample.pid, sample.tid);
260260
if (!thread) {
261261
pr_debug("machine__findnew_thread failed\n");
262262
return -1;

tools/perf/tests/hists_filter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
6969
evsel->hists.symbol_filter_str = NULL;
7070

7171
sample.pid = fake_samples[i].pid;
72+
sample.tid = fake_samples[i].pid;
7273
sample.ip = fake_samples[i].ip;
7374

7475
if (perf_event__preprocess_sample(&event, machine, &al,

tools/perf/tests/hists_link.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
8181
};
8282

8383
sample.pid = fake_common_samples[k].pid;
84+
sample.tid = fake_common_samples[k].pid;
8485
sample.ip = fake_common_samples[k].ip;
8586
if (perf_event__preprocess_sample(&event, machine, &al,
8687
&sample) < 0)
@@ -104,6 +105,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine)
104105
};
105106

106107
sample.pid = fake_samples[i][k].pid;
108+
sample.tid = fake_samples[i][k].pid;
107109
sample.ip = fake_samples[i][k].ip;
108110
if (perf_event__preprocess_sample(&event, machine, &al,
109111
&sample) < 0)

tools/perf/util/build-id.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
2525
struct addr_location al;
2626
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
2727
struct thread *thread = machine__findnew_thread(machine, sample->pid,
28-
sample->pid);
28+
sample->tid);
2929

3030
if (thread == NULL) {
3131
pr_err("problem processing %d event, skipping it.\n",

tools/perf/util/event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ int perf_event__preprocess_sample(const union perf_event *event,
788788
{
789789
u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
790790
struct thread *thread = machine__findnew_thread(machine, sample->pid,
791-
sample->pid);
791+
sample->tid);
792792

793793
if (thread == NULL)
794794
return -1;

0 commit comments

Comments
 (0)