Received: by 10.223.185.111 with SMTP id b44csp51498wrg; Fri, 9 Mar 2018 00:40:01 -0800 (PST) X-Google-Smtp-Source: AG47ELs46NOLEeJVAKQT61tNFpMXwbO/ztgw0TaG3mTExPITRRl7D0/MlPlNM7FbMLqxRjKqR4uY X-Received: by 10.99.117.89 with SMTP id f25mr23196930pgn.18.1520584801525; Fri, 09 Mar 2018 00:40:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520584801; cv=none; d=google.com; s=arc-20160816; b=Bfa+QAZ5SVba5qeOF5dHy2JFdhwF5BHez/5aPymd55l/LYoI5FB/mfVAo7AuGcm87G C9J9+n3gsqA7WSGjgWIYTVQklmBkocwvmguaWw5z75ybNo3Se4csuJNYEuCYxgq4hPkq OzElovneOQ6HQEERS6Fdts0So1tiCgO025b6cx7BGdLgf14PtXDrkB+Gz1lE6qq7YCo0 Da4RuCaOcOwM0OcPMhy29I/AtAdInqVr90OXa8lwRtM7oIquJfhzXnQzUpVWnQFDiIWe sfSvUKra7QETHa2t20j4c/lK6WkrRDCtcsdIYjS764XoVuA08Pc6VZGyJngIAzqHDmMS 1w7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=IJrInRL8d/DPFX1oIclYswmpxOkGdIlSiOw929DrVNU=; b=Hw/SIM/kZTGYwNmY14B6Q0nfnAn8vF8bQE/v9BhjO3zd+Bc8SbSjtoMJtQhq2yP2xh zpiT0kd4olqu9eY69Ft7xwyY1voU6p5kCI1GWHisGoFPEn19beQ17Vjiu2ojfhCiD3Mm UeNthKSIoQ7n9Foe8792WX+642UluMta1qD1lDlSG4rDdoCTqAdq5eBJRAzApm8lZCFk amfrAfpuAQG5B/1/60Ag06e6kopxPzBuXBoMgRFCzvehtKCIa68/vdsZIm55GoA5E/n0 UXPpbqrMSWxocFPfRLwRGxevv/OppdbjTs/yLa0/qyRyLoDXlPncl/SU5QzlPXwUcrO/ b2Rg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si410137pgr.797.2018.03.09.00.39.46; Fri, 09 Mar 2018 00:40:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752182AbeCIIiD (ORCPT + 99 others); Fri, 9 Mar 2018 03:38:03 -0500 Received: from terminus.zytor.com ([198.137.202.136]:49561 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbeCIIiC (ORCPT ); Fri, 9 Mar 2018 03:38:02 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w298bf3m023177; Fri, 9 Mar 2018 00:37:41 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w298beLW023174; Fri, 9 Mar 2018 00:37:40 -0800 Date: Fri, 9 Mar 2018 00:37:40 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Changbin Du Message-ID: Cc: namhyung@kernel.org, mingo@kernel.org, tglx@linutronix.de, peterz@infradead.org, jolsa@kernel.org, acme@redhat.com, hpa@zytor.com, changbin.du@intel.com, linux-kernel@vger.kernel.org Reply-To: tglx@linutronix.de, peterz@infradead.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, changbin.du@intel.com, hpa@zytor.com, acme@redhat.com, namhyung@kernel.org, mingo@kernel.org In-Reply-To: <1520307457-23668-3-git-send-email-changbin.du@intel.com> References: <1520307457-23668-3-git-send-email-changbin.du@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf sched map: Re-annotate shortname if thread comm changed Git-Commit-ID: 99a3c3a91382a7e5e841a98467a8409b47b540f0 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 99a3c3a91382a7e5e841a98467a8409b47b540f0 Gitweb: https://git.kernel.org/tip/99a3c3a91382a7e5e841a98467a8409b47b540f0 Author: Changbin Du AuthorDate: Tue, 6 Mar 2018 11:37:37 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 7 Mar 2018 10:22:26 -0300 perf sched map: Re-annotate shortname if thread comm changed This is to show the real name of thread that created via fork-exec. See below example for shortname *A0*. $ sudo ./perf sched map *A0 80393.050639 secs A0 => perf:22368 *. A0 80393.050748 secs . => swapper:0 . *. 80393.050887 secs *B0 . . 80393.052735 secs B0 => rcu_sched:8 *. . . 80393.052743 secs . *C0 . 80393.056264 secs C0 => kworker/2:1H:287 . *A0 . 80393.056270 secs . *D0 . 80393.056769 secs D0 => ksoftirqd/2:22 - . *A0 . 80393.056804 secs + . *A0 . 80393.056804 secs A0 => pi:22368 . *. . 80393.056854 secs *B0 . . 80393.060727 secs ... Signed-off-by: Changbin Du Acked-by: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1520307457-23668-3-git-send-email-changbin.du@intel.com [ Optimally pack struct thread_runtime when adding the new bool member ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-sched.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 0a632a6b6228..4dfdee668b0c 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -256,6 +256,8 @@ struct thread_runtime { int last_state; char shortname[3]; + bool comm_changed; + u64 migrations; }; @@ -1626,7 +1628,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, timestamp__scnprintf_usec(timestamp, stimestamp, sizeof(stimestamp)); color_fprintf(stdout, color, " %12s secs ", stimestamp); - if (new_shortname || (verbose > 0 && sched_in->tid)) { + if (new_shortname || tr->comm_changed || (verbose > 0 && sched_in->tid)) { const char *pid_color = color; if (thread__has_color(sched_in)) @@ -1634,6 +1636,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel, color_fprintf(stdout, pid_color, "%s => %s:%d", tr->shortname, thread__comm_str(sched_in), sched_in->tid); + tr->comm_changed = false; } if (sched->map.comp && new_cpu) @@ -1737,6 +1740,37 @@ static int perf_sched__process_tracepoint_sample(struct perf_tool *tool __maybe_ return err; } +static int perf_sched__process_comm(struct perf_tool *tool __maybe_unused, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine) +{ + struct thread *thread; + struct thread_runtime *tr; + int err; + + err = perf_event__process_comm(tool, event, sample, machine); + if (err) + return err; + + thread = machine__find_thread(machine, sample->pid, sample->tid); + if (!thread) { + pr_err("Internal error: can't find thread\n"); + return -1; + } + + tr = thread__get_runtime(thread); + if (tr == NULL) { + thread__put(thread); + return -1; + } + + tr->comm_changed = true; + thread__put(thread); + + return 0; +} + static int perf_sched__read_events(struct perf_sched *sched) { const struct perf_evsel_str_handler handlers[] = { @@ -3306,7 +3340,7 @@ int cmd_sched(int argc, const char **argv) struct perf_sched sched = { .tool = { .sample = perf_sched__process_tracepoint_sample, - .comm = perf_event__process_comm, + .comm = perf_sched__process_comm, .namespaces = perf_event__process_namespaces, .lost = perf_event__process_lost, .fork = perf_sched__process_fork_event,