From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752104AbcLFDlb (ORCPT ); Mon, 5 Dec 2016 22:41:31 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:36401 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752014AbcLFDl1 (ORCPT ); Mon, 5 Dec 2016 22:41:27 -0500 From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Andi Kleen , Minchan Kim Subject: [PATCH 03/10] perf sched timehist: Handle zero sample->tid properly Date: Tue, 6 Dec 2016 12:40:03 +0900 Message-Id: <20161206034010.6499-4-namhyung@kernel.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161206034010.6499-1-namhyung@kernel.org> References: <20161206034010.6499-1-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 6991686bcaa5..e34a71166b4a 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.10.1