aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-annotate.c2
-rw-r--r--tools/perf/builtin-diff.c4
-rw-r--r--tools/perf/builtin-inject.c6
-rw-r--r--tools/perf/builtin-report.c4
-rw-r--r--tools/perf/builtin-sched.c2
-rw-r--r--tools/perf/builtin-script.c4
-rw-r--r--tools/perf/util/build-id.c2
-rw-r--r--tools/perf/util/event.c30
-rw-r--r--tools/perf/util/event.h6
9 files changed, 39 insertions, 21 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 9ea38540b873..cca2fb5c436f 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -246,7 +246,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
246 .sample = process_sample_event, 246 .sample = process_sample_event,
247 .mmap = perf_event__process_mmap, 247 .mmap = perf_event__process_mmap,
248 .comm = perf_event__process_comm, 248 .comm = perf_event__process_comm,
249 .fork = perf_event__process_task, 249 .fork = perf_event__process_fork,
250 .ordered_samples = true, 250 .ordered_samples = true,
251 .ordering_requires_timestamps = true, 251 .ordering_requires_timestamps = true,
252 }, 252 },
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index b4db51375199..380683de1df3 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -285,8 +285,8 @@ static struct perf_tool tool = {
285 .sample = diff__process_sample_event, 285 .sample = diff__process_sample_event,
286 .mmap = perf_event__process_mmap, 286 .mmap = perf_event__process_mmap,
287 .comm = perf_event__process_comm, 287 .comm = perf_event__process_comm,
288 .exit = perf_event__process_task, 288 .exit = perf_event__process_exit,
289 .fork = perf_event__process_task, 289 .fork = perf_event__process_fork,
290 .lost = perf_event__process_lost, 290 .lost = perf_event__process_lost,
291 .ordered_samples = true, 291 .ordered_samples = true,
292 .ordering_requires_timestamps = true, 292 .ordering_requires_timestamps = true,
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 4688bea95c12..386a5c0013ff 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -102,14 +102,14 @@ static int perf_event__repipe_mmap(struct perf_tool *tool,
102 return err; 102 return err;
103} 103}
104 104
105static int perf_event__repipe_task(struct perf_tool *tool, 105static int perf_event__repipe_fork(struct perf_tool *tool,
106 union perf_event *event, 106 union perf_event *event,
107 struct perf_sample *sample, 107 struct perf_sample *sample,
108 struct machine *machine) 108 struct machine *machine)
109{ 109{
110 int err; 110 int err;
111 111
112 err = perf_event__process_task(tool, event, sample, machine); 112 err = perf_event__process_fork(tool, event, sample, machine);
113 perf_event__repipe(tool, event, sample, machine); 113 perf_event__repipe(tool, event, sample, machine);
114 114
115 return err; 115 return err;
@@ -227,7 +227,7 @@ static int __cmd_inject(struct perf_inject *inject)
227 if (inject->build_ids) { 227 if (inject->build_ids) {
228 inject->tool.sample = perf_event__inject_buildid; 228 inject->tool.sample = perf_event__inject_buildid;
229 inject->tool.mmap = perf_event__repipe_mmap; 229 inject->tool.mmap = perf_event__repipe_mmap;
230 inject->tool.fork = perf_event__repipe_task; 230 inject->tool.fork = perf_event__repipe_fork;
231 inject->tool.tracing_data = perf_event__repipe_tracing_data; 231 inject->tool.tracing_data = perf_event__repipe_tracing_data;
232 } 232 }
233 233
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index a61725d89d3e..5104a40af563 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -556,8 +556,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
556 .sample = process_sample_event, 556 .sample = process_sample_event,
557 .mmap = perf_event__process_mmap, 557 .mmap = perf_event__process_mmap,
558 .comm = perf_event__process_comm, 558 .comm = perf_event__process_comm,
559 .exit = perf_event__process_task, 559 .exit = perf_event__process_exit,
560 .fork = perf_event__process_task, 560 .fork = perf_event__process_fork,
561 .lost = perf_event__process_lost, 561 .lost = perf_event__process_lost,
562 .read = process_read_event, 562 .read = process_read_event,
563 .attr = perf_event__process_attr, 563 .attr = perf_event__process_attr,
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 3488ead3b60c..3a25cd83b56e 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1672,7 +1672,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
1672 .sample = perf_sched__process_tracepoint_sample, 1672 .sample = perf_sched__process_tracepoint_sample,
1673 .comm = perf_event__process_comm, 1673 .comm = perf_event__process_comm,
1674 .lost = perf_event__process_lost, 1674 .lost = perf_event__process_lost,
1675 .fork = perf_event__process_task, 1675 .fork = perf_event__process_fork,
1676 .ordered_samples = true, 1676 .ordered_samples = true,
1677 }, 1677 },
1678 .cmp_pid = LIST_HEAD_INIT(sched.cmp_pid), 1678 .cmp_pid = LIST_HEAD_INIT(sched.cmp_pid),
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index fb9625083a2e..04ceb0779d39 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -520,8 +520,8 @@ static struct perf_tool perf_script = {
520 .sample = process_sample_event, 520 .sample = process_sample_event,
521 .mmap = perf_event__process_mmap, 521 .mmap = perf_event__process_mmap,
522 .comm = perf_event__process_comm, 522 .comm = perf_event__process_comm,
523 .exit = perf_event__process_task, 523 .exit = perf_event__process_exit,
524 .fork = perf_event__process_task, 524 .fork = perf_event__process_fork,
525 .attr = perf_event__process_attr, 525 .attr = perf_event__process_attr,
526 .event_type = perf_event__process_event_type, 526 .event_type = perf_event__process_event_type,
527 .tracing_data = perf_event__process_tracing_data, 527 .tracing_data = perf_event__process_tracing_data,
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 8e3a740ddbd4..6a6399955ef2 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -64,7 +64,7 @@ static int perf_event__exit_del_thread(struct perf_tool *tool __maybe_unused,
64struct perf_tool build_id__mark_dso_hit_ops = { 64struct perf_tool build_id__mark_dso_hit_ops = {
65 .sample = build_id__mark_dso_hit, 65 .sample = build_id__mark_dso_hit,
66 .mmap = perf_event__process_mmap, 66 .mmap = perf_event__process_mmap,
67 .fork = perf_event__process_task, 67 .fork = perf_event__process_fork,
68 .exit = perf_event__exit_del_thread, 68 .exit = perf_event__exit_del_thread,
69 .attr = perf_event__process_attr, 69 .attr = perf_event__process_attr,
70 .build_id = perf_event__process_build_id, 70 .build_id = perf_event__process_build_id,
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 6715b1938725..eaaee22628ea 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1,6 +1,7 @@
1#include <linux/types.h> 1#include <linux/types.h>
2#include "event.h" 2#include "event.h"
3#include "debug.h" 3#include "debug.h"
4#include "machine.h"
4#include "sort.h" 5#include "sort.h"
5#include "string.h" 6#include "string.h"
6#include "strlist.h" 7#include "strlist.h"
@@ -702,10 +703,10 @@ size_t perf_event__fprintf_task(union perf_event *event, FILE *fp)
702 event->fork.ppid, event->fork.ptid); 703 event->fork.ppid, event->fork.ptid);
703} 704}
704 705
705int perf_event__process_task(struct perf_tool *tool __maybe_unused, 706int perf_event__process_fork(struct perf_tool *tool __maybe_unused,
706 union perf_event *event, 707 union perf_event *event,
707 struct perf_sample *sample __maybe_unused, 708 struct perf_sample *sample __maybe_unused,
708 struct machine *machine) 709 struct machine *machine)
709{ 710{
710 struct thread *thread = machine__findnew_thread(machine, event->fork.tid); 711 struct thread *thread = machine__findnew_thread(machine, event->fork.tid);
711 struct thread *parent = machine__findnew_thread(machine, event->fork.ptid); 712 struct thread *parent = machine__findnew_thread(machine, event->fork.ptid);
@@ -713,11 +714,6 @@ int perf_event__process_task(struct perf_tool *tool __maybe_unused,
713 if (dump_trace) 714 if (dump_trace)
714 perf_event__fprintf_task(event, stdout); 715 perf_event__fprintf_task(event, stdout);
715 716
716 if (event->header.type == PERF_RECORD_EXIT) {
717 machine__remove_thread(machine, thread);
718 return 0;
719 }
720
721 if (thread == NULL || parent == NULL || 717 if (thread == NULL || parent == NULL ||
722 thread__fork(thread, parent) < 0) { 718 thread__fork(thread, parent) < 0) {
723 dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n"); 719 dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
@@ -727,6 +723,22 @@ int perf_event__process_task(struct perf_tool *tool __maybe_unused,
727 return 0; 723 return 0;
728} 724}
729 725
726int perf_event__process_exit(struct perf_tool *tool __maybe_unused,
727 union perf_event *event,
728 struct perf_sample *sample __maybe_unused,
729 struct machine *machine)
730{
731 struct thread *thread = machine__find_thread(machine, event->fork.tid);
732
733 if (dump_trace)
734 perf_event__fprintf_task(event, stdout);
735
736 if (thread != NULL)
737 machine__remove_thread(machine, thread);
738
739 return 0;
740}
741
730size_t perf_event__fprintf(union perf_event *event, FILE *fp) 742size_t perf_event__fprintf(union perf_event *event, FILE *fp)
731{ 743{
732 size_t ret = fprintf(fp, "PERF_RECORD_%s", 744 size_t ret = fprintf(fp, "PERF_RECORD_%s",
@@ -761,8 +773,10 @@ int perf_event__process(struct perf_tool *tool, union perf_event *event,
761 perf_event__process_mmap(tool, event, sample, machine); 773 perf_event__process_mmap(tool, event, sample, machine);
762 break; 774 break;
763 case PERF_RECORD_FORK: 775 case PERF_RECORD_FORK:
776 perf_event__process_fork(tool, event, sample, machine);
777 break;
764 case PERF_RECORD_EXIT: 778 case PERF_RECORD_EXIT:
765 perf_event__process_task(tool, event, sample, machine); 779 perf_event__process_exit(tool, event, sample, machine);
766 break; 780 break;
767 case PERF_RECORD_LOST: 781 case PERF_RECORD_LOST:
768 perf_event__process_lost(tool, event, sample, machine); 782 perf_event__process_lost(tool, event, sample, machine);
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index 21b99e741a87..da97aff5bd75 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -191,7 +191,11 @@ int perf_event__process_mmap(struct perf_tool *tool,
191 union perf_event *event, 191 union perf_event *event,
192 struct perf_sample *sample, 192 struct perf_sample *sample,
193 struct machine *machine); 193 struct machine *machine);
194int perf_event__process_task(struct perf_tool *tool, 194int perf_event__process_fork(struct perf_tool *tool,
195 union perf_event *event,
196 struct perf_sample *sample,
197 struct machine *machine);
198int perf_event__process_exit(struct perf_tool *tool,
195 union perf_event *event, 199 union perf_event *event,
196 struct perf_sample *sample, 200 struct perf_sample *sample,
197 struct machine *machine); 201 struct machine *machine);