All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: a.p.zijlstra@chello.nl, dsahern@gmail.com, acme@redhat.com,
	tglx@linutronix.de, jolsa@kernel.org, mingo@kernel.org,
	hpa@zytor.com, namhyung@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip:perf/core] perf sched map: Color given cpus
Date: Wed, 13 Apr 2016 22:45:41 -0700	[thread overview]
Message-ID: <tip-cf294f24f8c83bca6aa8e96b5cc4f78bed887f92@git.kernel.org> (raw)
In-Reply-To: <1460467771-26532-8-git-send-email-jolsa@kernel.org>

Commit-ID:  cf294f24f8c83bca6aa8e96b5cc4f78bed887f92
Gitweb:     http://git.kernel.org/tip/cf294f24f8c83bca6aa8e96b5cc4f78bed887f92
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Tue, 12 Apr 2016 15:29:30 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 13 Apr 2016 10:11:51 -0300

perf sched map: Color given cpus

Adding --color-cpus option to display selected cpus with background
color (red by default).  It helps on navigating through the perf sched
map output.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460467771-26532-8-git-send-email-jolsa@kernel.org
[ Added entry to man page ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-sched.txt |  3 +++
 tools/perf/builtin-sched.c              | 36 ++++++++++++++++++++++++++++++---
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documentation/perf-sched.txt
index 67913de..58bff6c 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -57,6 +57,9 @@ OPTIONS for 'perf sched map'
 	Show only CPUs with activity. Helps visualizing on high core
 	count systems.
 
+--color-cpus::
+	Highlight the given cpus.
+
 --color-pids::
 	Highlight the given pids.
 
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index b5361a1d..7de04b2 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -125,6 +125,7 @@ struct trace_sched_handler {
 };
 
 #define COLOR_PIDS PERF_COLOR_BLUE
+#define COLOR_CPUS PERF_COLOR_BG_RED
 
 struct perf_sched_map {
 	DECLARE_BITMAP(comp_cpus_mask, MAX_CPUS);
@@ -132,6 +133,8 @@ struct perf_sched_map {
 	bool			 comp;
 	struct thread_map	*color_pids;
 	const char		*color_pids_str;
+	struct cpu_map		*color_cpus;
+	const char		*color_cpus_str;
 };
 
 struct perf_sched {
@@ -1461,14 +1464,18 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,
 		int cpu = sched->map.comp ? sched->map.comp_cpus[i] : i;
 		struct thread *curr_thread = sched->curr_thread[cpu];
 		const char *pid_color = color;
+		const char *cpu_color = color;
 
 		if (curr_thread && thread__has_color(curr_thread))
 			pid_color = COLOR_PIDS;
 
+		if (sched->map.color_cpus && cpu_map__has(sched->map.color_cpus, cpu))
+			cpu_color = COLOR_CPUS;
+
 		if (cpu != this_cpu)
-			color_fprintf(stdout, color, " ");
+			color_fprintf(stdout, cpu_color, " ");
 		else
-			color_fprintf(stdout, color, "*");
+			color_fprintf(stdout, cpu_color, "*");
 
 		if (sched->curr_thread[cpu])
 			color_fprintf(stdout, pid_color, "%2s ", sched->curr_thread[cpu]->shortname);
@@ -1753,7 +1760,8 @@ static int setup_map_cpus(struct perf_sched *sched)
 
 	if (sched->map.comp) {
 		sched->map.comp_cpus = zalloc(sched->max_cpu * sizeof(int));
-		return sched->map.comp_cpus ? 0 : -1;
+		if (!sched->map.comp_cpus)
+			return -1;
 	}
 
 	return 0;
@@ -1776,6 +1784,23 @@ static int setup_color_pids(struct perf_sched *sched)
 	return 0;
 }
 
+static int setup_color_cpus(struct perf_sched *sched)
+{
+	struct cpu_map *map;
+
+	if (!sched->map.color_cpus_str)
+		return 0;
+
+	map = cpu_map__new(sched->map.color_cpus_str);
+	if (!map) {
+		pr_err("failed to get thread map from %s\n", sched->map.color_cpus_str);
+		return -1;
+	}
+
+	sched->map.color_cpus = map;
+	return 0;
+}
+
 static int perf_sched__map(struct perf_sched *sched)
 {
 	if (setup_map_cpus(sched))
@@ -1784,6 +1809,9 @@ static int perf_sched__map(struct perf_sched *sched)
 	if (setup_color_pids(sched))
 		return -1;
 
+	if (setup_color_cpus(sched))
+		return -1;
+
 	setup_pager();
 	if (perf_sched__read_events(sched))
 		return -1;
@@ -1941,6 +1969,8 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused)
 		    "map output in compact mode"),
 	OPT_STRING(0, "color-pids", &sched.map.color_pids_str, "pids",
 		   "highlight given pids in map"),
+	OPT_STRING(0, "color-cpus", &sched.map.color_cpus_str, "cpus",
+                    "highlight given CPUs in map"),
 	OPT_END()
 	};
 	const char * const latency_usage[] = {

  reply	other threads:[~2016-04-14  5:45 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-12 13:29 [PATCH 0/8] perf tools: Add sched map changes Jiri Olsa
2016-04-12 13:29 ` [PATCH 1/8] perf tools: Add thread_map__has function Jiri Olsa
2016-04-14  5:43   ` [tip:perf/core] perf thread_map: Add has() method tip-bot for Jiri Olsa
2016-04-12 13:29 ` [PATCH 2/8] perf tools: Add cpu_map__has function Jiri Olsa
2016-04-14  5:43   ` [tip:perf/core] perf cpu_map: Add has() method tip-bot for Jiri Olsa
2016-04-12 13:29 ` [PATCH 3/8] perf tools sched: Add compact display option Jiri Olsa
2016-04-12 14:09   ` Arnaldo Carvalho de Melo
2016-04-12 14:18     ` Arnaldo Carvalho de Melo
2016-04-14  5:44   ` [tip:perf/core] perf " tip-bot for Jiri Olsa
2016-04-12 13:29 ` [PATCH 4/8] perf tools sched: Use color_fprintf for output Jiri Olsa
2016-04-14  5:44   ` [tip:perf/core] perf " tip-bot for Jiri Olsa
2016-04-12 13:29 ` [PATCH 5/8] perf tools sched: Make thread_map__new_by_tid_str global Jiri Olsa
2016-04-14  5:44   ` [tip:perf/core] perf thread_map: Make new_by_tid_str constructor public tip-bot for Jiri Olsa
2016-04-12 13:29 ` [PATCH 6/8] perf tools sched: Collor given pids Jiri Olsa
2016-04-14  5:45   ` [tip:perf/core] perf sched map: Color " tip-bot for Jiri Olsa
2016-04-12 13:29 ` [PATCH 7/8] perf tools sched: Collor given cpus Jiri Olsa
2016-04-14  5:45   ` tip-bot for Jiri Olsa [this message]
2016-04-12 13:29 ` [PATCH 8/8] perf tools sched: Display only " Jiri Olsa
2016-04-14  5:46   ` [tip:perf/core] perf sched map: " tip-bot for Jiri Olsa
2016-04-12 14:38 ` [PATCH 0/8] perf tools: Add sched map changes Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-cf294f24f8c83bca6aa8e96b5cc4f78bed887f92@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.