public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf sched latency: Fix removed thread issue
@ 2015-11-02 11:10 Jiri Olsa
  2015-11-02 22:27 ` Namhyung Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jiri Olsa @ 2015-11-02 11:10 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, David Ahern, Ingo Molnar, Namhyung Kim, Peter Zijlstra,
	Mohit Agrawal

If machine's thread gets excited (EXIT event is received),
we set thread->dead = true and it is later on removed from
machine's tree if the pid is reused on new thread.

The latency subcommand holds 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.

I think we could change this to the sort based on timestamp
of thread creation, once it's added within Namhyung's thread
patchset.

Reported-by: Mohit Agrawal <moagrawa@redhat.com>
Link: http://lkml.kernel.org/n/tip-o4doazhhv0zax5zshkg8hnys@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-sched.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 0ee6d900e100..e3d3e32c0a93 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)
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-11-08  7:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-02 11:10 [PATCH] perf sched latency: Fix removed thread issue Jiri Olsa
2015-11-02 22:27 ` Namhyung Kim
2015-11-03  8:04   ` Jiri Olsa
2015-11-02 22:53 ` Arnaldo Carvalho de Melo
2015-11-03  7:41   ` Jiri Olsa
2015-11-03 18:33     ` Arnaldo Carvalho de Melo
2015-11-04  7:34       ` Jiri Olsa
2015-11-08  7:31 ` [tip:perf/urgent] perf sched latency: Fix thread pid reuse issue tip-bot for Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox