diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 634d8cfb4693242cebd14e71163dd441d023f6e0..c8b3e6c330c3a7653fdc5ccfe44c89693f016901 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -2118,7 +2118,9 @@ static struct thread *timehist_get_thread(struct perf_sched *sched, pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu); } else { - thread = machine__findnew_thread(machine, sample->pid, sample->tid); + /* there were samples with tid 0 but non-zero pid */ + thread = machine__findnew_thread(machine, sample->pid, + sample->tid ?: sample->pid); if (thread == NULL) { pr_debug("Failed to get thread for tid %d. skipping sample.\n", sample->tid);