Received: by 10.223.185.116 with SMTP id b49csp3345615wrg; Mon, 5 Mar 2018 19:49:05 -0800 (PST) X-Google-Smtp-Source: AG47ELtdDePVhXKVNGXOYF89z/RIb1AqrHcucdQjirvjzPB0udO2JHnN1p/RvfTduHgYuMoa/zZL X-Received: by 10.99.45.194 with SMTP id t185mr12699675pgt.267.1520308145749; Mon, 05 Mar 2018 19:49:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520308145; cv=none; d=google.com; s=arc-20160816; b=wDUYUngMP77rp5gi2QUFyxMeGWyEDzZHw/pwJlfZY0akL2xx1KqUAINXNQFSKfbms+ mqrSjBtA3nYr/MtV3lpAC5nOwgv8NSFDeT08P8dvLyCC52S5lo7XLiO3KBJANNdsCAkY IVg9OKLxHrPs+oa+FSXlHOFFgfLw/SD8djKj9mDfXoaPP4Ge+9XlftVZHP98Pc0IDnuO PLaMgKlzYhFN9tME2OqC4KiKsLN5HuiUs8ZH+sAGm3TBvyPl2eYGDZvcI1IYZuldo1++ Oa5BY8DlovWcM9Wz4WvwfvphpVxP/BJt2lOL+nKAmuv1zG49M6WKV7hdNEDzh7ES3vXx 5bmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Kq34QKJ3/tklwaG5HRF0GzgnWxsFwVb0bMQXikGm6cI=; b=ZDnNJrEanUWSn5nruGifWlS/HMK+unpH8bIAg5CBkq+AhYEIQGRIrYMHAqlNbAGt8s HVUMKFHHeN2xm9/AKzrIgfXgQZ27j2flzzVzPhgjZF8ca2qHx6qPOQMpd+9A9nUIzcM5 beHarjAmKgh65jAaEpyTnMdBOt1wTO+xDTpftqbW15Q8nQFFvwAUwjcYIwqTdlh3PnAz Xa2hTZ2aALaHxCops1tsEQE4HS6jvLL7Y/kYunw2X0Vc98a77y8PgoYOFSGFzs+cYXMl OFS24ovusFCAAXgMnhwgRiAIctsz84UdAMEICK7f8I0uUvroK8nABYZR6otaa9L77lm8 UnQA== 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 f4si9221297pgc.267.2018.03.05.19.48.51; Mon, 05 Mar 2018 19:49:05 -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 S932482AbeCFDry (ORCPT + 99 others); Mon, 5 Mar 2018 22:47:54 -0500 Received: from mga07.intel.com ([134.134.136.100]:42932 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932251AbeCFDrw (ORCPT ); Mon, 5 Mar 2018 22:47:52 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2018 19:47:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,430,1515484800"; d="scan'208";a="22835522" Received: from gvt-dell.bj.intel.com (HELO gvt-dell-host.bj.intel.com) ([10.238.154.59]) by orsmga008.jf.intel.com with ESMTP; 05 Mar 2018 19:47:50 -0800 From: changbin.du@intel.com To: acme@kernel.org, jolsa@redhat.com Cc: peterz@infradead.org, mingo@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Changbin Du Subject: [PATCH v2 2/2] perf sched map: re-annotate shortname if thread comm changed Date: Tue, 6 Mar 2018 11:37:37 +0800 Message-Id: <1520307457-23668-3-git-send-email-changbin.du@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520307457-23668-1-git-send-email-changbin.du@intel.com> References: <1520307457-23668-1-git-send-email-changbin.du@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Changbin Du 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 ... Cc: Namhyung Kim Cc: Jiri Olsa Signed-off-by: Changbin Du --- v2: add function perf_sched__process_comm() to process PERF_RECORD_COMM event. --- tools/perf/builtin-sched.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 5bfc8d5..7aa0600 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -257,6 +257,7 @@ struct thread_runtime { u64 migrations; char shortname[3]; + bool comm_changed; }; /* per event run time data */ @@ -1626,7 +1627,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 +1635,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 +1739,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 +3339,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, -- 2.7.4