aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/builtin-inject.c2
-rw-r--r--tools/perf/builtin-kmem.c3
-rw-r--r--tools/perf/builtin-kvm.c2
-rw-r--r--tools/perf/builtin-lock.c3
-rw-r--r--tools/perf/builtin-sched.c20
-rw-r--r--tools/perf/builtin-script.c3
-rw-r--r--tools/perf/builtin-trace.c10
-rw-r--r--tools/perf/tests/code-reading.c4
-rw-r--r--tools/perf/tests/hists_link.c3
-rw-r--r--tools/perf/util/build-id.c7
-rw-r--r--tools/perf/util/event.c3
-rw-r--r--tools/perf/util/machine.c22
-rw-r--r--tools/perf/util/machine.h3
-rw-r--r--tools/perf/util/session.c2
14 files changed, 55 insertions, 32 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 1d8de2e4a407..0d4ae1dd7b60 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -198,7 +198,7 @@ static int perf_event__inject_buildid(struct perf_tool *tool,
198 198
199 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 199 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
200 200
201 thread = machine__findnew_thread(machine, event->ip.pid); 201 thread = machine__findnew_thread(machine, event->ip.pid, event->ip.pid);
202 if (thread == NULL) { 202 if (thread == NULL) {
203 pr_err("problem processing %d event, skipping it.\n", 203 pr_err("problem processing %d event, skipping it.\n",
204 event->header.type); 204 event->header.type);
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index b49f5c58e152..c32477837cb0 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -305,7 +305,8 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
305 struct perf_evsel *evsel, 305 struct perf_evsel *evsel,
306 struct machine *machine) 306 struct machine *machine)
307{ 307{
308 struct thread *thread = machine__findnew_thread(machine, event->ip.pid); 308 struct thread *thread = machine__findnew_thread(machine, event->ip.pid,
309 event->ip.pid);
309 310
310 if (thread == NULL) { 311 if (thread == NULL) {
311 pr_debug("problem processing %d event, skipping it.\n", 312 pr_debug("problem processing %d event, skipping it.\n",
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 6cd4de59be21..47b35407c2f2 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -815,7 +815,7 @@ static int process_sample_event(struct perf_tool *tool,
815 if (skip_sample(kvm, sample)) 815 if (skip_sample(kvm, sample))
816 return 0; 816 return 0;
817 817
818 thread = machine__findnew_thread(machine, sample->tid); 818 thread = machine__findnew_thread(machine, sample->pid, sample->tid);
819 if (thread == NULL) { 819 if (thread == NULL) {
820 pr_debug("problem processing %d event, skipping it.\n", 820 pr_debug("problem processing %d event, skipping it.\n",
821 event->header.type); 821 event->header.type);
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index 76543a4a7a30..ee33ba2f05dd 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -805,7 +805,8 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
805 struct perf_evsel *evsel, 805 struct perf_evsel *evsel,
806 struct machine *machine) 806 struct machine *machine)
807{ 807{
808 struct thread *thread = machine__findnew_thread(machine, sample->tid); 808 struct thread *thread = machine__findnew_thread(machine, sample->pid,
809 sample->tid);
809 810
810 if (thread == NULL) { 811 if (thread == NULL) {
811 pr_debug("problem processing %d event, skipping it.\n", 812 pr_debug("problem processing %d event, skipping it.\n",
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index f809cc7fb7d9..d8c51b2f263f 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -724,8 +724,10 @@ static int replay_fork_event(struct perf_sched *sched,
724{ 724{
725 struct thread *child, *parent; 725 struct thread *child, *parent;
726 726
727 child = machine__findnew_thread(machine, event->fork.tid); 727 child = machine__findnew_thread(machine, event->fork.pid,
728 parent = machine__findnew_thread(machine, event->fork.ptid); 728 event->fork.tid);
729 parent = machine__findnew_thread(machine, event->fork.ppid,
730 event->fork.ptid);
729 731
730 if (child == NULL || parent == NULL) { 732 if (child == NULL || parent == NULL) {
731 pr_debug("thread does not exist on fork event: child %p, parent %p\n", 733 pr_debug("thread does not exist on fork event: child %p, parent %p\n",
@@ -934,8 +936,8 @@ static int latency_switch_event(struct perf_sched *sched,
934 return -1; 936 return -1;
935 } 937 }
936 938
937 sched_out = machine__findnew_thread(machine, prev_pid); 939 sched_out = machine__findnew_thread(machine, 0, prev_pid);
938 sched_in = machine__findnew_thread(machine, next_pid); 940 sched_in = machine__findnew_thread(machine, 0, next_pid);
939 941
940 out_events = thread_atoms_search(&sched->atom_root, sched_out, &sched->cmp_pid); 942 out_events = thread_atoms_search(&sched->atom_root, sched_out, &sched->cmp_pid);
941 if (!out_events) { 943 if (!out_events) {
@@ -978,7 +980,7 @@ static int latency_runtime_event(struct perf_sched *sched,
978{ 980{
979 const u32 pid = perf_evsel__intval(evsel, sample, "pid"); 981 const u32 pid = perf_evsel__intval(evsel, sample, "pid");
980 const u64 runtime = perf_evsel__intval(evsel, sample, "runtime"); 982 const u64 runtime = perf_evsel__intval(evsel, sample, "runtime");
981 struct thread *thread = machine__findnew_thread(machine, pid); 983 struct thread *thread = machine__findnew_thread(machine, 0, pid);
982 struct work_atoms *atoms = thread_atoms_search(&sched->atom_root, thread, &sched->cmp_pid); 984 struct work_atoms *atoms = thread_atoms_search(&sched->atom_root, thread, &sched->cmp_pid);
983 u64 timestamp = sample->time; 985 u64 timestamp = sample->time;
984 int cpu = sample->cpu; 986 int cpu = sample->cpu;
@@ -1016,7 +1018,7 @@ static int latency_wakeup_event(struct perf_sched *sched,
1016 if (!success) 1018 if (!success)
1017 return 0; 1019 return 0;
1018 1020
1019 wakee = machine__findnew_thread(machine, pid); 1021 wakee = machine__findnew_thread(machine, 0, pid);
1020 atoms = thread_atoms_search(&sched->atom_root, wakee, &sched->cmp_pid); 1022 atoms = thread_atoms_search(&sched->atom_root, wakee, &sched->cmp_pid);
1021 if (!atoms) { 1023 if (!atoms) {
1022 if (thread_atoms_insert(sched, wakee)) 1024 if (thread_atoms_insert(sched, wakee))
@@ -1070,7 +1072,7 @@ static int latency_migrate_task_event(struct perf_sched *sched,
1070 if (sched->profile_cpu == -1) 1072 if (sched->profile_cpu == -1)
1071 return 0; 1073 return 0;
1072 1074
1073 migrant = machine__findnew_thread(machine, pid); 1075 migrant = machine__findnew_thread(machine, 0, pid);
1074 atoms = thread_atoms_search(&sched->atom_root, migrant, &sched->cmp_pid); 1076 atoms = thread_atoms_search(&sched->atom_root, migrant, &sched->cmp_pid);
1075 if (!atoms) { 1077 if (!atoms) {
1076 if (thread_atoms_insert(sched, migrant)) 1078 if (thread_atoms_insert(sched, migrant))
@@ -1289,8 +1291,8 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
1289 return -1; 1291 return -1;
1290 } 1292 }
1291 1293
1292 sched_out = machine__findnew_thread(machine, prev_pid); 1294 sched_out = machine__findnew_thread(machine, 0, prev_pid);
1293 sched_in = machine__findnew_thread(machine, next_pid); 1295 sched_in = machine__findnew_thread(machine, 0, next_pid);
1294 1296
1295 sched->curr_thread[this_cpu] = sched_in; 1297 sched->curr_thread[this_cpu] = sched_in;
1296 1298
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 2ad9d5b6fb3c..d82712f169b3 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -501,7 +501,8 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
501 struct machine *machine) 501 struct machine *machine)
502{ 502{
503 struct addr_location al; 503 struct addr_location al;
504 struct thread *thread = machine__findnew_thread(machine, event->ip.tid); 504 struct thread *thread = machine__findnew_thread(machine, event->ip.pid,
505 event->ip.tid);
505 506
506 if (thread == NULL) { 507 if (thread == NULL) {
507 pr_debug("problem processing %d event, skipping it.\n", 508 pr_debug("problem processing %d event, skipping it.\n",
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index b72afc73f9a7..88387c565687 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -521,7 +521,8 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
521 if (sc->filtered) 521 if (sc->filtered)
522 return 0; 522 return 0;
523 523
524 thread = machine__findnew_thread(&trace->host, sample->tid); 524 thread = machine__findnew_thread(&trace->host, sample->pid,
525 sample->tid);
525 ttrace = thread__trace(thread, trace->output); 526 ttrace = thread__trace(thread, trace->output);
526 if (ttrace == NULL) 527 if (ttrace == NULL)
527 return -1; 528 return -1;
@@ -572,7 +573,8 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
572 if (sc->filtered) 573 if (sc->filtered)
573 return 0; 574 return 0;
574 575
575 thread = machine__findnew_thread(&trace->host, sample->tid); 576 thread = machine__findnew_thread(&trace->host, sample->pid,
577 sample->tid);
576 ttrace = thread__trace(thread, trace->output); 578 ttrace = thread__trace(thread, trace->output);
577 if (ttrace == NULL) 579 if (ttrace == NULL)
578 return -1; 580 return -1;
@@ -628,7 +630,9 @@ static int trace__sched_stat_runtime(struct trace *trace, struct perf_evsel *evs
628{ 630{
629 u64 runtime = perf_evsel__intval(evsel, sample, "runtime"); 631 u64 runtime = perf_evsel__intval(evsel, sample, "runtime");
630 double runtime_ms = (double)runtime / NSEC_PER_MSEC; 632 double runtime_ms = (double)runtime / NSEC_PER_MSEC;
631 struct thread *thread = machine__findnew_thread(&trace->host, sample->tid); 633 struct thread *thread = machine__findnew_thread(&trace->host,
634 sample->pid,
635 sample->tid);
632 struct thread_trace *ttrace = thread__trace(thread, trace->output); 636 struct thread_trace *ttrace = thread__trace(thread, trace->output);
633 637
634 if (ttrace == NULL) 638 if (ttrace == NULL)
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index df9afd9cab4c..6fb781d5586c 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -257,7 +257,7 @@ static int process_sample_event(struct machine *machine,
257 return -1; 257 return -1;
258 } 258 }
259 259
260 thread = machine__findnew_thread(machine, sample.pid); 260 thread = machine__findnew_thread(machine, sample.pid, sample.pid);
261 if (!thread) { 261 if (!thread) {
262 pr_debug("machine__findnew_thread failed\n"); 262 pr_debug("machine__findnew_thread failed\n");
263 return -1; 263 return -1;
@@ -446,7 +446,7 @@ static int do_test_code_reading(bool try_kcore)
446 goto out_err; 446 goto out_err;
447 } 447 }
448 448
449 thread = machine__findnew_thread(machine, pid); 449 thread = machine__findnew_thread(machine, pid, pid);
450 if (!thread) { 450 if (!thread) {
451 pr_debug("machine__findnew_thread failed\n"); 451 pr_debug("machine__findnew_thread failed\n");
452 goto out_err; 452 goto out_err;
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 50bfb01183ea..87f9f7280c40 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -88,7 +88,8 @@ static struct machine *setup_fake_machine(struct machines *machines)
88 for (i = 0; i < ARRAY_SIZE(fake_threads); i++) { 88 for (i = 0; i < ARRAY_SIZE(fake_threads); i++) {
89 struct thread *thread; 89 struct thread *thread;
90 90
91 thread = machine__findnew_thread(machine, fake_threads[i].pid); 91 thread = machine__findnew_thread(machine, fake_threads[i].pid,
92 fake_threads[i].pid);
92 if (thread == NULL) 93 if (thread == NULL)
93 goto out; 94 goto out;
94 95
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 5295625c0c00..0f9d27a6bc8f 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -24,7 +24,8 @@ int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
24{ 24{
25 struct addr_location al; 25 struct addr_location al;
26 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 26 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
27 struct thread *thread = machine__findnew_thread(machine, event->ip.pid); 27 struct thread *thread = machine__findnew_thread(machine, event->ip.pid,
28 event->ip.pid);
28 29
29 if (thread == NULL) { 30 if (thread == NULL) {
30 pr_err("problem processing %d event, skipping it.\n", 31 pr_err("problem processing %d event, skipping it.\n",
@@ -47,7 +48,9 @@ static int perf_event__exit_del_thread(struct perf_tool *tool __maybe_unused,
47 __maybe_unused, 48 __maybe_unused,
48 struct machine *machine) 49 struct machine *machine)
49{ 50{
50 struct thread *thread = machine__findnew_thread(machine, event->fork.tid); 51 struct thread *thread = machine__findnew_thread(machine,
52 event->fork.pid,
53 event->fork.tid);
51 54
52 dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid, 55 dump_printf("(%d:%d):(%d:%d)\n", event->fork.pid, event->fork.tid,
53 event->fork.ppid, event->fork.ptid); 56 event->fork.ppid, event->fork.ptid);
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 49713ae46551..61cecf9caff1 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -686,7 +686,8 @@ int perf_event__preprocess_sample(const union perf_event *event,
686 struct perf_sample *sample) 686 struct perf_sample *sample)
687{ 687{
688 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 688 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
689 struct thread *thread = machine__findnew_thread(machine, event->ip.pid); 689 struct thread *thread = machine__findnew_thread(machine, event->ip.pid,
690 event->ip.pid);
690 691
691 if (thread == NULL) 692 if (thread == NULL)
692 return -1; 693 return -1;
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 59486c180626..1dca61f0512d 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -32,7 +32,8 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
32 return -ENOMEM; 32 return -ENOMEM;
33 33
34 if (pid != HOST_KERNEL_ID) { 34 if (pid != HOST_KERNEL_ID) {
35 struct thread *thread = machine__findnew_thread(machine, pid); 35 struct thread *thread = machine__findnew_thread(machine, 0,
36 pid);
36 char comm[64]; 37 char comm[64];
37 38
38 if (thread == NULL) 39 if (thread == NULL)
@@ -302,9 +303,10 @@ static struct thread *__machine__findnew_thread(struct machine *machine,
302 return th; 303 return th;
303} 304}
304 305
305struct thread *machine__findnew_thread(struct machine *machine, pid_t tid) 306struct thread *machine__findnew_thread(struct machine *machine, pid_t pid,
307 pid_t tid)
306{ 308{
307 return __machine__findnew_thread(machine, 0, tid, true); 309 return __machine__findnew_thread(machine, pid, tid, true);
308} 310}
309 311
310struct thread *machine__find_thread(struct machine *machine, pid_t tid) 312struct thread *machine__find_thread(struct machine *machine, pid_t tid)
@@ -314,7 +316,9 @@ struct thread *machine__find_thread(struct machine *machine, pid_t tid)
314 316
315int machine__process_comm_event(struct machine *machine, union perf_event *event) 317int machine__process_comm_event(struct machine *machine, union perf_event *event)
316{ 318{
317 struct thread *thread = machine__findnew_thread(machine, event->comm.tid); 319 struct thread *thread = machine__findnew_thread(machine,
320 event->comm.pid,
321 event->comm.tid);
318 322
319 if (dump_trace) 323 if (dump_trace)
320 perf_event__fprintf_comm(event, stdout); 324 perf_event__fprintf_comm(event, stdout);
@@ -1012,7 +1016,8 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
1012 return 0; 1016 return 0;
1013 } 1017 }
1014 1018
1015 thread = machine__findnew_thread(machine, event->mmap.pid); 1019 thread = machine__findnew_thread(machine, event->mmap.pid,
1020 event->mmap.pid);
1016 if (thread == NULL) 1021 if (thread == NULL)
1017 goto out_problem; 1022 goto out_problem;
1018 1023
@@ -1051,13 +1056,16 @@ static void machine__remove_thread(struct machine *machine, struct thread *th)
1051int machine__process_fork_event(struct machine *machine, union perf_event *event) 1056int machine__process_fork_event(struct machine *machine, union perf_event *event)
1052{ 1057{
1053 struct thread *thread = machine__find_thread(machine, event->fork.tid); 1058 struct thread *thread = machine__find_thread(machine, event->fork.tid);
1054 struct thread *parent = machine__findnew_thread(machine, event->fork.ptid); 1059 struct thread *parent = machine__findnew_thread(machine,
1060 event->fork.ppid,
1061 event->fork.ptid);
1055 1062
1056 /* if a thread currently exists for the thread id remove it */ 1063 /* if a thread currently exists for the thread id remove it */
1057 if (thread != NULL) 1064 if (thread != NULL)
1058 machine__remove_thread(machine, thread); 1065 machine__remove_thread(machine, thread);
1059 1066
1060 thread = machine__findnew_thread(machine, event->fork.tid); 1067 thread = machine__findnew_thread(machine, event->fork.pid,
1068 event->fork.tid);
1061 if (dump_trace) 1069 if (dump_trace)
1062 perf_event__fprintf_task(event, stdout); 1070 perf_event__fprintf_task(event, stdout);
1063 1071
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 603ffba999d9..0df925ba6a44 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -106,7 +106,8 @@ static inline bool machine__is_host(struct machine *machine)
106 return machine ? machine->pid == HOST_KERNEL_ID : false; 106 return machine ? machine->pid == HOST_KERNEL_ID : false;
107} 107}
108 108
109struct thread *machine__findnew_thread(struct machine *machine, pid_t tid); 109struct thread *machine__findnew_thread(struct machine *machine, pid_t pid,
110 pid_t tid);
110 111
111size_t machine__fprintf(struct machine *machine, FILE *fp); 112size_t machine__fprintf(struct machine *machine, FILE *fp);
112 113
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index de16a7736859..57b6f38f246a 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1099,7 +1099,7 @@ void perf_event_header__bswap(struct perf_event_header *self)
1099 1099
1100struct thread *perf_session__findnew(struct perf_session *session, pid_t pid) 1100struct thread *perf_session__findnew(struct perf_session *session, pid_t pid)
1101{ 1101{
1102 return machine__findnew_thread(&session->machines.host, pid); 1102 return machine__findnew_thread(&session->machines.host, 0, pid);
1103} 1103}
1104 1104
1105static struct thread *perf_session__register_idle_thread(struct perf_session *self) 1105static struct thread *perf_session__register_idle_thread(struct perf_session *self)