From: Jiri Olsa Date: Mon, 2 Nov 2015 11:10:25 +0000 (+0100) Subject: perf sched latency: Fix thread pid reuse issue X-Git-Tag: v4.14-rc1~4271^2~6^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0014de172d228e450377d1fd079d94e67128d27f;p=platform%2Fkernel%2Flinux-rpi.git perf sched latency: Fix thread pid reuse issue The latency subcommand holds a tree of working atoms sorted by thread's pid/tid. If there's new thread with same pid and tid, the old working atom is found and assert bug condition is hit in search function: thread_atoms_search: Assertion `!(thread != atoms->thread)' failed Changing the sort function to use thread object pointers together with pid and tid check. This way new thread will never find old one with same pid/tid. Link: http://lkml.kernel.org/n/tip-o4doazhhv0zax5zshkg8hnys@git.kernel.org Reported-by: Mohit Agrawal Signed-off-by: Jiri Olsa Acked-by: Namhyung Kim Cc: David Ahern Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1446462625-15807-1-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 0ee6d90..e3d3e32 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1203,12 +1203,13 @@ static void output_lat_thread(struct perf_sched *sched, struct work_atoms *work_ static int pid_cmp(struct work_atoms *l, struct work_atoms *r) { + if (l->thread == r->thread) + return 0; if (l->thread->tid < r->thread->tid) return -1; if (l->thread->tid > r->thread->tid) return 1; - - return 0; + return (int)(l->thread - r->thread); } static int avg_cmp(struct work_atoms *l, struct work_atoms *r)