aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/machine.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/machine.c')
-rw-r--r--tools/perf/util/machine.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 7ff682770fdb..f1a4c833121e 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1387,6 +1387,24 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
1387 event->fork.ptid); 1387 event->fork.ptid);
1388 int err = 0; 1388 int err = 0;
1389 1389
1390 if (dump_trace)
1391 perf_event__fprintf_task(event, stdout);
1392
1393 /*
1394 * There may be an existing thread that is not actually the parent,
1395 * either because we are processing events out of order, or because the
1396 * (fork) event that would have removed the thread was lost. Assume the
1397 * latter case and continue on as best we can.
1398 */
1399 if (parent->pid_ != (pid_t)event->fork.ppid) {
1400 dump_printf("removing erroneous parent thread %d/%d\n",
1401 parent->pid_, parent->tid);
1402 machine__remove_thread(machine, parent);
1403 thread__put(parent);
1404 parent = machine__findnew_thread(machine, event->fork.ppid,
1405 event->fork.ptid);
1406 }
1407
1390 /* if a thread currently exists for the thread id remove it */ 1408 /* if a thread currently exists for the thread id remove it */
1391 if (thread != NULL) { 1409 if (thread != NULL) {
1392 machine__remove_thread(machine, thread); 1410 machine__remove_thread(machine, thread);
@@ -1395,8 +1413,6 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
1395 1413
1396 thread = machine__findnew_thread(machine, event->fork.pid, 1414 thread = machine__findnew_thread(machine, event->fork.pid,
1397 event->fork.tid); 1415 event->fork.tid);
1398 if (dump_trace)
1399 perf_event__fprintf_task(event, stdout);
1400 1416
1401 if (thread == NULL || parent == NULL || 1417 if (thread == NULL || parent == NULL ||
1402 thread__fork(thread, parent, sample->time) < 0) { 1418 thread__fork(thread, parent, sample->time) < 0) {