diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 9c380a2caa54..6b6050d6830d 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1277,21 +1277,28 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event
 	struct thread *thread = machine__find_thread(machine,
 						     event->fork.pid,
 						     event->fork.tid);
-	struct thread *parent = machine__findnew_thread(machine,
-							event->fork.ppid,
-							event->fork.ptid);
+	struct thread *parent;
 
 	/* if a thread currently exists for the thread id remove it */
 	if (thread != NULL)
 		machine__remove_thread(machine, thread);
 
-	thread = machine__findnew_thread(machine, event->fork.pid,
-					 event->fork.tid);
+	thread = machine__findnew_thread(machine, event->fork.pid, event->fork.tid);
 	if (dump_trace)
 		perf_event__fprintf_task(event, stdout);
 
-	if (thread == NULL || parent == NULL ||
-	    thread__fork(thread, parent, sample->time) < 0) {
+	if (thread == NULL)
+		goto out_err;
+
+	if (event->fork.pid != event->fork.tid)
+		return 0;
+
+	parent = machine__findnew_thread(machine, event->fork.ppid, event->fork.ptid);
+	if (parent == NULL)
+		goto out_err;
+
+	if (thread__fork(thread, parent, sample->time) < 0) {
+out_err:
 		dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
 		return -1;
 	}
