Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <moagrawa@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1446462625-15807-1-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
0014de17 98d3b258

+3 -2
+3 -2
tools/perf/builtin-sched.c
··· 1203 1203 1204 1204 static int pid_cmp(struct work_atoms *l, struct work_atoms *r) 1205 1205 { 1206 + if (l->thread == r->thread) 1207 + return 0; 1206 1208 if (l->thread->tid < r->thread->tid) 1207 1209 return -1; 1208 1210 if (l->thread->tid > r->thread->tid) 1209 1211 return 1; 1210 - 1211 - return 0; 1212 + return (int)(l->thread - r->thread); 1212 1213 } 1213 1214 1214 1215 static int avg_cmp(struct work_atoms *l, struct work_atoms *r)