From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932792AbcLGQxy (ORCPT ); Wed, 7 Dec 2016 11:53:54 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:37063 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932407AbcLGQxs (ORCPT ); Wed, 7 Dec 2016 11:53:48 -0500 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Namhyung Kim , Andi Kleen , David Ahern , Jiri Olsa , Minchan Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 08/10] perf sched timehist: Handle zero sample->tid properly Date: Wed, 7 Dec 2016 13:53:33 -0300 Message-Id: <20161207165335.22835-9-acme@kernel.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161207165335.22835-1-acme@kernel.org> References: <20161207165335.22835-1-acme@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim Sometimes samples have tid of 0 but non-0 pid. It ends up having a new thread of 0 tid/pid (instead of referring idle task) since tid is used to search matching task. But I guess it's wrong to use 0 as a tid when pid is set. This patch uses tid only if it has a non-zero value or same as pid (of 0). Signed-off-by: Namhyung Kim Cc: Andi Kleen Cc: David Ahern Cc: Jiri Olsa Cc: Minchan Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20161206034010.6499-4-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-sched.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 634d8cfb4693..c8b3e6c330c3 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); -- 2.9.3