aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-top.c2
-rw-r--r--tools/perf/builtin-trace.c12
-rw-r--r--tools/perf/tests/code-reading.c2
-rw-r--r--tools/perf/tests/hists_link.c4
-rw-r--r--tools/perf/util/event.c28
-rw-r--r--tools/perf/util/machine.c39
-rw-r--r--tools/perf/util/machine.h21
-rw-r--r--tools/perf/util/session.c2
-rw-r--r--tools/perf/util/thread.c6
-rw-r--r--tools/perf/util/thread.h4
10 files changed, 67 insertions, 53 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index a6ea956a533e..21db76d71ddf 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -856,7 +856,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx)
856 &sample, machine); 856 &sample, machine);
857 } else if (event->header.type < PERF_RECORD_MAX) { 857 } else if (event->header.type < PERF_RECORD_MAX) {
858 hists__inc_nr_events(&evsel->hists, event->header.type); 858 hists__inc_nr_events(&evsel->hists, event->header.type);
859 machine__process_event(machine, event); 859 machine__process_event(machine, event, &sample);
860 } else 860 } else
861 ++session->stats.nr_unknown_events; 861 ++session->stats.nr_unknown_events;
862next_event: 862next_event:
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index dc3da654ff12..95d639212d98 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1122,7 +1122,7 @@ static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *thre
1122} 1122}
1123 1123
1124static int trace__process_event(struct trace *trace, struct machine *machine, 1124static int trace__process_event(struct trace *trace, struct machine *machine,
1125 union perf_event *event) 1125 union perf_event *event, struct perf_sample *sample)
1126{ 1126{
1127 int ret = 0; 1127 int ret = 0;
1128 1128
@@ -1130,9 +1130,9 @@ static int trace__process_event(struct trace *trace, struct machine *machine,
1130 case PERF_RECORD_LOST: 1130 case PERF_RECORD_LOST:
1131 color_fprintf(trace->output, PERF_COLOR_RED, 1131 color_fprintf(trace->output, PERF_COLOR_RED,
1132 "LOST %" PRIu64 " events!\n", event->lost.lost); 1132 "LOST %" PRIu64 " events!\n", event->lost.lost);
1133 ret = machine__process_lost_event(machine, event); 1133 ret = machine__process_lost_event(machine, event, sample);
1134 default: 1134 default:
1135 ret = machine__process_event(machine, event); 1135 ret = machine__process_event(machine, event, sample);
1136 break; 1136 break;
1137 } 1137 }
1138 1138
@@ -1141,11 +1141,11 @@ static int trace__process_event(struct trace *trace, struct machine *machine,
1141 1141
1142static int trace__tool_process(struct perf_tool *tool, 1142static int trace__tool_process(struct perf_tool *tool,
1143 union perf_event *event, 1143 union perf_event *event,
1144 struct perf_sample *sample __maybe_unused, 1144 struct perf_sample *sample,
1145 struct machine *machine) 1145 struct machine *machine)
1146{ 1146{
1147 struct trace *trace = container_of(tool, struct trace, tool); 1147 struct trace *trace = container_of(tool, struct trace, tool);
1148 return trace__process_event(trace, machine, event); 1148 return trace__process_event(trace, machine, event, sample);
1149} 1149}
1150 1150
1151static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist) 1151static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
@@ -1751,7 +1751,7 @@ again:
1751 trace->base_time = sample.time; 1751 trace->base_time = sample.time;
1752 1752
1753 if (type != PERF_RECORD_SAMPLE) { 1753 if (type != PERF_RECORD_SAMPLE) {
1754 trace__process_event(trace, trace->host, event); 1754 trace__process_event(trace, trace->host, event, &sample);
1755 continue; 1755 continue;
1756 } 1756 }
1757 1757
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index e3fedfa2906e..49ccc3b2995e 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -276,7 +276,7 @@ static int process_event(struct machine *machine, struct perf_evlist *evlist,
276 return process_sample_event(machine, evlist, event, state); 276 return process_sample_event(machine, evlist, event, state);
277 277
278 if (event->header.type < PERF_RECORD_MAX) 278 if (event->header.type < PERF_RECORD_MAX)
279 return machine__process_event(machine, event); 279 return machine__process_event(machine, event, NULL);
280 280
281 return 0; 281 return 0;
282} 282}
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 4475b0ff76e5..6c337e653540 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -93,7 +93,7 @@ static struct machine *setup_fake_machine(struct machines *machines)
93 if (thread == NULL) 93 if (thread == NULL)
94 goto out; 94 goto out;
95 95
96 thread__set_comm(thread, fake_threads[i].comm); 96 thread__set_comm(thread, fake_threads[i].comm, 0);
97 } 97 }
98 98
99 for (i = 0; i < ARRAY_SIZE(fake_mmap_info); i++) { 99 for (i = 0; i < ARRAY_SIZE(fake_mmap_info); i++) {
@@ -110,7 +110,7 @@ static struct machine *setup_fake_machine(struct machines *machines)
110 strcpy(fake_mmap_event.mmap.filename, 110 strcpy(fake_mmap_event.mmap.filename,
111 fake_mmap_info[i].filename); 111 fake_mmap_info[i].filename);
112 112
113 machine__process_mmap_event(machine, &fake_mmap_event); 113 machine__process_mmap_event(machine, &fake_mmap_event, NULL);
114 } 114 }
115 115
116 for (i = 0; i < ARRAY_SIZE(fake_symbols); i++) { 116 for (i = 0; i < ARRAY_SIZE(fake_symbols); i++) {
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 7a2842ed53f3..c26b3539187b 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -512,18 +512,18 @@ size_t perf_event__fprintf_comm(union perf_event *event, FILE *fp)
512 512
513int perf_event__process_comm(struct perf_tool *tool __maybe_unused, 513int perf_event__process_comm(struct perf_tool *tool __maybe_unused,
514 union perf_event *event, 514 union perf_event *event,
515 struct perf_sample *sample __maybe_unused, 515 struct perf_sample *sample,
516 struct machine *machine) 516 struct machine *machine)
517{ 517{
518 return machine__process_comm_event(machine, event); 518 return machine__process_comm_event(machine, event, sample);
519} 519}
520 520
521int perf_event__process_lost(struct perf_tool *tool __maybe_unused, 521int perf_event__process_lost(struct perf_tool *tool __maybe_unused,
522 union perf_event *event, 522 union perf_event *event,
523 struct perf_sample *sample __maybe_unused, 523 struct perf_sample *sample,
524 struct machine *machine) 524 struct machine *machine)
525{ 525{
526 return machine__process_lost_event(machine, event); 526 return machine__process_lost_event(machine, event, sample);
527} 527}
528 528
529size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp) 529size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)
@@ -546,18 +546,18 @@ size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp)
546 546
547int perf_event__process_mmap(struct perf_tool *tool __maybe_unused, 547int perf_event__process_mmap(struct perf_tool *tool __maybe_unused,
548 union perf_event *event, 548 union perf_event *event,
549 struct perf_sample *sample __maybe_unused, 549 struct perf_sample *sample,
550 struct machine *machine) 550 struct machine *machine)
551{ 551{
552 return machine__process_mmap_event(machine, event); 552 return machine__process_mmap_event(machine, event, sample);
553} 553}
554 554
555int perf_event__process_mmap2(struct perf_tool *tool __maybe_unused, 555int perf_event__process_mmap2(struct perf_tool *tool __maybe_unused,
556 union perf_event *event, 556 union perf_event *event,
557 struct perf_sample *sample __maybe_unused, 557 struct perf_sample *sample,
558 struct machine *machine) 558 struct machine *machine)
559{ 559{
560 return machine__process_mmap2_event(machine, event); 560 return machine__process_mmap2_event(machine, event, sample);
561} 561}
562 562
563size_t perf_event__fprintf_task(union perf_event *event, FILE *fp) 563size_t perf_event__fprintf_task(union perf_event *event, FILE *fp)
@@ -569,18 +569,18 @@ size_t perf_event__fprintf_task(union perf_event *event, FILE *fp)
569 569
570int perf_event__process_fork(struct perf_tool *tool __maybe_unused, 570int perf_event__process_fork(struct perf_tool *tool __maybe_unused,
571 union perf_event *event, 571 union perf_event *event,
572 struct perf_sample *sample __maybe_unused, 572 struct perf_sample *sample,
573 struct machine *machine) 573 struct machine *machine)
574{ 574{
575 return machine__process_fork_event(machine, event); 575 return machine__process_fork_event(machine, event, sample);
576} 576}
577 577
578int perf_event__process_exit(struct perf_tool *tool __maybe_unused, 578int perf_event__process_exit(struct perf_tool *tool __maybe_unused,
579 union perf_event *event, 579 union perf_event *event,
580 struct perf_sample *sample __maybe_unused, 580 struct perf_sample *sample,
581 struct machine *machine) 581 struct machine *machine)
582{ 582{
583 return machine__process_exit_event(machine, event); 583 return machine__process_exit_event(machine, event, sample);
584} 584}
585 585
586size_t perf_event__fprintf(union perf_event *event, FILE *fp) 586size_t perf_event__fprintf(union perf_event *event, FILE *fp)
@@ -611,10 +611,10 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp)
611 611
612int perf_event__process(struct perf_tool *tool __maybe_unused, 612int perf_event__process(struct perf_tool *tool __maybe_unused,
613 union perf_event *event, 613 union perf_event *event,
614 struct perf_sample *sample __maybe_unused, 614 struct perf_sample *sample,
615 struct machine *machine) 615 struct machine *machine)
616{ 616{
617 return machine__process_event(machine, event); 617 return machine__process_event(machine, event, sample);
618} 618}
619 619
620void thread__find_addr_map(struct thread *self, 620void thread__find_addr_map(struct thread *self,
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index ea93425cce95..ce034c183a7e 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -40,7 +40,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid)
40 return -ENOMEM; 40 return -ENOMEM;
41 41
42 snprintf(comm, sizeof(comm), "[guest/%d]", pid); 42 snprintf(comm, sizeof(comm), "[guest/%d]", pid);
43 thread__set_comm(thread, comm); 43 thread__set_comm(thread, comm, 0);
44 } 44 }
45 45
46 return 0; 46 return 0;
@@ -331,7 +331,8 @@ struct thread *machine__find_thread(struct machine *machine, pid_t tid)
331 return __machine__findnew_thread(machine, 0, tid, false); 331 return __machine__findnew_thread(machine, 0, tid, false);
332} 332}
333 333
334int machine__process_comm_event(struct machine *machine, union perf_event *event) 334int machine__process_comm_event(struct machine *machine, union perf_event *event,
335 struct perf_sample *sample)
335{ 336{
336 struct thread *thread = machine__findnew_thread(machine, 337 struct thread *thread = machine__findnew_thread(machine,
337 event->comm.pid, 338 event->comm.pid,
@@ -340,7 +341,7 @@ int machine__process_comm_event(struct machine *machine, union perf_event *event
340 if (dump_trace) 341 if (dump_trace)
341 perf_event__fprintf_comm(event, stdout); 342 perf_event__fprintf_comm(event, stdout);
342 343
343 if (thread == NULL || thread__set_comm(thread, event->comm.comm)) { 344 if (thread == NULL || thread__set_comm(thread, event->comm.comm, sample->time)) {
344 dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); 345 dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
345 return -1; 346 return -1;
346 } 347 }
@@ -349,7 +350,7 @@ int machine__process_comm_event(struct machine *machine, union perf_event *event
349} 350}
350 351
351int machine__process_lost_event(struct machine *machine __maybe_unused, 352int machine__process_lost_event(struct machine *machine __maybe_unused,
352 union perf_event *event) 353 union perf_event *event, struct perf_sample *sample __maybe_unused)
353{ 354{
354 dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n", 355 dump_printf(": id:%" PRIu64 ": lost:%" PRIu64 "\n",
355 event->lost.id, event->lost.lost); 356 event->lost.id, event->lost.lost);
@@ -984,7 +985,8 @@ out_problem:
984} 985}
985 986
986int machine__process_mmap2_event(struct machine *machine, 987int machine__process_mmap2_event(struct machine *machine,
987 union perf_event *event) 988 union perf_event *event,
989 struct perf_sample *sample __maybe_unused)
988{ 990{
989 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 991 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
990 struct thread *thread; 992 struct thread *thread;
@@ -1031,7 +1033,8 @@ out_problem:
1031 return 0; 1033 return 0;
1032} 1034}
1033 1035
1034int machine__process_mmap_event(struct machine *machine, union perf_event *event) 1036int machine__process_mmap_event(struct machine *machine, union perf_event *event,
1037 struct perf_sample *sample __maybe_unused)
1035{ 1038{
1036 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 1039 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
1037 struct thread *thread; 1040 struct thread *thread;
@@ -1088,7 +1091,8 @@ static void machine__remove_thread(struct machine *machine, struct thread *th)
1088 list_add_tail(&th->node, &machine->dead_threads); 1091 list_add_tail(&th->node, &machine->dead_threads);
1089} 1092}
1090 1093
1091int machine__process_fork_event(struct machine *machine, union perf_event *event) 1094int machine__process_fork_event(struct machine *machine, union perf_event *event,
1095 struct perf_sample *sample)
1092{ 1096{
1093 struct thread *thread = machine__find_thread(machine, event->fork.tid); 1097 struct thread *thread = machine__find_thread(machine, event->fork.tid);
1094 struct thread *parent = machine__findnew_thread(machine, 1098 struct thread *parent = machine__findnew_thread(machine,
@@ -1105,7 +1109,7 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
1105 perf_event__fprintf_task(event, stdout); 1109 perf_event__fprintf_task(event, stdout);
1106 1110
1107 if (thread == NULL || parent == NULL || 1111 if (thread == NULL || parent == NULL ||
1108 thread__fork(thread, parent) < 0) { 1112 thread__fork(thread, parent, sample->time) < 0) {
1109 dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n"); 1113 dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
1110 return -1; 1114 return -1;
1111 } 1115 }
@@ -1113,8 +1117,8 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
1113 return 0; 1117 return 0;
1114} 1118}
1115 1119
1116int machine__process_exit_event(struct machine *machine __maybe_unused, 1120int machine__process_exit_event(struct machine *machine, union perf_event *event,
1117 union perf_event *event) 1121 struct perf_sample *sample __maybe_unused)
1118{ 1122{
1119 struct thread *thread = machine__find_thread(machine, event->fork.tid); 1123 struct thread *thread = machine__find_thread(machine, event->fork.tid);
1120 1124
@@ -1127,23 +1131,24 @@ int machine__process_exit_event(struct machine *machine __maybe_unused,
1127 return 0; 1131 return 0;
1128} 1132}
1129 1133
1130int machine__process_event(struct machine *machine, union perf_event *event) 1134int machine__process_event(struct machine *machine, union perf_event *event,
1135 struct perf_sample *sample)
1131{ 1136{
1132 int ret; 1137 int ret;
1133 1138
1134 switch (event->header.type) { 1139 switch (event->header.type) {
1135 case PERF_RECORD_COMM: 1140 case PERF_RECORD_COMM:
1136 ret = machine__process_comm_event(machine, event); break; 1141 ret = machine__process_comm_event(machine, event, sample); break;
1137 case PERF_RECORD_MMAP: 1142 case PERF_RECORD_MMAP:
1138 ret = machine__process_mmap_event(machine, event); break; 1143 ret = machine__process_mmap_event(machine, event, sample); break;
1139 case PERF_RECORD_MMAP2: 1144 case PERF_RECORD_MMAP2:
1140 ret = machine__process_mmap2_event(machine, event); break; 1145 ret = machine__process_mmap2_event(machine, event, sample); break;
1141 case PERF_RECORD_FORK: 1146 case PERF_RECORD_FORK:
1142 ret = machine__process_fork_event(machine, event); break; 1147 ret = machine__process_fork_event(machine, event, sample); break;
1143 case PERF_RECORD_EXIT: 1148 case PERF_RECORD_EXIT:
1144 ret = machine__process_exit_event(machine, event); break; 1149 ret = machine__process_exit_event(machine, event, sample); break;
1145 case PERF_RECORD_LOST: 1150 case PERF_RECORD_LOST:
1146 ret = machine__process_lost_event(machine, event); break; 1151 ret = machine__process_lost_event(machine, event, sample); break;
1147 default: 1152 default:
1148 ret = -1; 1153 ret = -1;
1149 break; 1154 break;
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
index 4c1f5d567f54..2389ba81fafe 100644
--- a/tools/perf/util/machine.h
+++ b/tools/perf/util/machine.h
@@ -40,13 +40,20 @@ struct map *machine__kernel_map(struct machine *machine, enum map_type type)
40 40
41struct thread *machine__find_thread(struct machine *machine, pid_t tid); 41struct thread *machine__find_thread(struct machine *machine, pid_t tid);
42 42
43int machine__process_comm_event(struct machine *machine, union perf_event *event); 43int machine__process_comm_event(struct machine *machine, union perf_event *event,
44int machine__process_exit_event(struct machine *machine, union perf_event *event); 44 struct perf_sample *sample);
45int machine__process_fork_event(struct machine *machine, union perf_event *event); 45int machine__process_exit_event(struct machine *machine, union perf_event *event,
46int machine__process_lost_event(struct machine *machine, union perf_event *event); 46 struct perf_sample *sample);
47int machine__process_mmap_event(struct machine *machine, union perf_event *event); 47int machine__process_fork_event(struct machine *machine, union perf_event *event,
48int machine__process_mmap2_event(struct machine *machine, union perf_event *event); 48 struct perf_sample *sample);
49int machine__process_event(struct machine *machine, union perf_event *event); 49int machine__process_lost_event(struct machine *machine, union perf_event *event,
50 struct perf_sample *sample);
51int machine__process_mmap_event(struct machine *machine, union perf_event *event,
52 struct perf_sample *sample);
53int machine__process_mmap2_event(struct machine *machine, union perf_event *event,
54 struct perf_sample *sample);
55int machine__process_event(struct machine *machine, union perf_event *event,
56 struct perf_sample *sample);
50 57
51typedef void (*machine__process_t)(struct machine *machine, void *data); 58typedef void (*machine__process_t)(struct machine *machine, void *data);
52 59
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 4ba7b548e055..3c1b30103d54 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1100,7 +1100,7 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se
1100{ 1100{
1101 struct thread *thread = perf_session__findnew(self, 0); 1101 struct thread *thread = perf_session__findnew(self, 0);
1102 1102
1103 if (thread == NULL || thread__set_comm(thread, "swapper")) { 1103 if (thread == NULL || thread__set_comm(thread, "swapper", 0)) {
1104 pr_err("problem inserting idle task.\n"); 1104 pr_err("problem inserting idle task.\n");
1105 thread = NULL; 1105 thread = NULL;
1106 } 1106 }
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 56760079565b..0ea73fe383f5 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -31,7 +31,8 @@ void thread__delete(struct thread *thread)
31 free(thread); 31 free(thread);
32} 32}
33 33
34int thread__set_comm(struct thread *thread, const char *comm) 34int thread__set_comm(struct thread *thread, const char *comm,
35 u64 timestamp __maybe_unused)
35{ 36{
36 int err; 37 int err;
37 38
@@ -73,7 +74,8 @@ void thread__insert_map(struct thread *thread, struct map *map)
73 map_groups__insert(&thread->mg, map); 74 map_groups__insert(&thread->mg, map);
74} 75}
75 76
76int thread__fork(struct thread *thread, struct thread *parent) 77int thread__fork(struct thread *thread, struct thread *parent,
78 u64 timestamp __maybe_unused)
77{ 79{
78 int i; 80 int i;
79 81
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index 6561ad21d9a7..4e9724270a64 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -33,11 +33,11 @@ static inline void thread__exited(struct thread *thread)
33 thread->dead = true; 33 thread->dead = true;
34} 34}
35 35
36int thread__set_comm(struct thread *self, const char *comm); 36int thread__set_comm(struct thread *thread, const char *comm, u64 timestamp);
37int thread__comm_len(struct thread *self); 37int thread__comm_len(struct thread *self);
38const char *thread__comm_str(const struct thread *thread); 38const char *thread__comm_str(const struct thread *thread);
39void thread__insert_map(struct thread *self, struct map *map); 39void thread__insert_map(struct thread *self, struct map *map);
40int thread__fork(struct thread *self, struct thread *parent); 40int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
41size_t thread__fprintf(struct thread *thread, FILE *fp); 41size_t thread__fprintf(struct thread *thread, FILE *fp);
42 42
43static inline struct map *thread__find_map(struct thread *self, 43static inline struct map *thread__find_map(struct thread *self,