linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] perf timechart improvements part 2
@ 2013-12-02 14:37 Stanislav Fomichev
  2013-12-02 14:37 ` [PATCH 1/5] perf timechart: add backtrace support to CPU info Stanislav Fomichev
                   ` (4 more replies)
  0 siblings, 5 replies; 23+ messages in thread
From: Stanislav Fomichev @ 2013-12-02 14:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: a.p.zijlstra, paulus, mingo, acme, stfomichev, namhyung, artagnon, jolsa

This patch series has the following features:
- adds backtrace info to the CPU overview chart
- adds pid info to the figures on CPU overview chart
- we now read number of CPUs from the perf.data header (this makes CPU overview
  more accurate since it shows idle cores)
- adds '-t' option to sort CPUs (on the CPU overview chart) topologically (draw
  adjacent SMT threads next to each other)
- adds '-e' option to highlight long events on the CPU overview chart

Stanislav Fomichev (5):
  perf timechart: add backtrace support to CPU info
  perf timechart: print pid along the name
  perf timechart: get number of CPUs from perf header
  perf timechart: add support for topology
  perf timechart: add emphasize option

 tools/perf/Documentation/perf-timechart.txt |   7 ++
 tools/perf/builtin-timechart.c              |  79 ++++++++++++--
 tools/perf/util/svghelper.c                 | 159 ++++++++++++++++++++++++++--
 tools/perf/util/svghelper.h                 |   6 +-
 4 files changed, 235 insertions(+), 16 deletions(-)

-- 
1.8.3.2


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/5] perf timechart: add backtrace support to CPU info
  2013-12-02 14:37 [PATCH 0/5] perf timechart improvements part 2 Stanislav Fomichev
@ 2013-12-02 14:37 ` Stanislav Fomichev
  2013-12-18 10:30   ` [tip:perf/core] perf timechart: Add " tip-bot for Stanislav Fomichev
  2013-12-02 14:37 ` [PATCH 2/5] perf timechart: print pid along the name Stanislav Fomichev
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 23+ messages in thread
From: Stanislav Fomichev @ 2013-12-02 14:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: a.p.zijlstra, paulus, mingo, acme, stfomichev, namhyung, artagnon, jolsa

Add backtrace info to the CPU usage timechart.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
---
 tools/perf/builtin-timechart.c | 10 ++++++++--
 tools/perf/util/svghelper.c    |  4 +++-
 tools/perf/util/svghelper.h    |  2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 0bda620a717d..d955095b6d63 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -837,8 +837,14 @@ static void draw_cpu_usage(struct timechart *tchart)
 		while (c) {
 			sample = c->samples;
 			while (sample) {
-				if (sample->type == TYPE_RUNNING)
-					svg_process(sample->cpu, sample->start_time, sample->end_time, "sample", c->comm);
+				if (sample->type == TYPE_RUNNING) {
+					svg_process(sample->cpu,
+						    sample->start_time,
+						    sample->end_time,
+						    "sample",
+						    c->comm,
+						    sample->backtrace);
+				}
 
 				sample = sample->next;
 			}
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 8b79d3ad1246..740f0328fc13 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -285,7 +285,7 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name)
+void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name, const char *backtrace)
 {
 	double width;
 
@@ -295,6 +295,8 @@ void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name
 
 	fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu));
 	fprintf(svgfile, "<title>%s %s</title>\n", name, time_to_string(end - start));
+	if (backtrace)
+		fprintf(svgfile, "<desc>Switched because:\n%s</desc>\n", backtrace);
 	fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n",
 		time2pixels(end)-time2pixels(start), SLOT_MULT+SLOT_HEIGHT, type);
 	width = time2pixels(end)-time2pixels(start);
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index fad79ceeac1a..7db6ae98bf2c 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -11,7 +11,7 @@ extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *back
 extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
 
 
-extern void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name);
+extern void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name, const char *backtrace);
 extern void svg_cstate(int cpu, u64 start, u64 end, int type);
 extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
 
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/5] perf timechart: print pid along the name
  2013-12-02 14:37 [PATCH 0/5] perf timechart improvements part 2 Stanislav Fomichev
  2013-12-02 14:37 ` [PATCH 1/5] perf timechart: add backtrace support to CPU info Stanislav Fomichev
@ 2013-12-02 14:37 ` Stanislav Fomichev
  2013-12-18 10:30   ` [tip:perf/core] perf timechart: Print " tip-bot for Stanislav Fomichev
  2013-12-02 14:37 ` [PATCH 3/5] perf timechart: get number of CPUs from perf header Stanislav Fomichev
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 23+ messages in thread
From: Stanislav Fomichev @ 2013-12-02 14:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: a.p.zijlstra, paulus, mingo, acme, stfomichev, namhyung, artagnon, jolsa

Add PID to the figures of CPU usage timechart.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
---
 tools/perf/builtin-timechart.c | 1 +
 tools/perf/util/svghelper.c    | 4 ++--
 tools/perf/util/svghelper.h    | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index d955095b6d63..99fe363f1de8 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -841,6 +841,7 @@ static void draw_cpu_usage(struct timechart *tchart)
 					svg_process(sample->cpu,
 						    sample->start_time,
 						    sample->end_time,
+						    p->pid,
 						    "sample",
 						    c->comm,
 						    sample->backtrace);
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 740f0328fc13..927851d05d03 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -285,7 +285,7 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name, const char *backtrace)
+void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace)
 {
 	double width;
 
@@ -294,7 +294,7 @@ void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name
 
 
 	fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu));
-	fprintf(svgfile, "<title>%s %s</title>\n", name, time_to_string(end - start));
+	fprintf(svgfile, "<title>%d %s running %s</title>\n", pid, name, time_to_string(end - start));
 	if (backtrace)
 		fprintf(svgfile, "<desc>Switched because:\n%s</desc>\n", backtrace);
 	fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n",
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index 7db6ae98bf2c..8b77ca631686 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -11,7 +11,7 @@ extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *back
 extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
 
 
-extern void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name, const char *backtrace);
+extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace);
 extern void svg_cstate(int cpu, u64 start, u64 end, int type);
 extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
 
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/5] perf timechart: get number of CPUs from perf header
  2013-12-02 14:37 [PATCH 0/5] perf timechart improvements part 2 Stanislav Fomichev
  2013-12-02 14:37 ` [PATCH 1/5] perf timechart: add backtrace support to CPU info Stanislav Fomichev
  2013-12-02 14:37 ` [PATCH 2/5] perf timechart: print pid along the name Stanislav Fomichev
@ 2013-12-02 14:37 ` Stanislav Fomichev
  2013-12-18 10:31   ` [tip:perf/core] perf timechart: Get " tip-bot for Stanislav Fomichev
  2013-12-02 14:37 ` [PATCH 4/5] perf timechart: add support for topology Stanislav Fomichev
  2013-12-16 19:38 ` [PATCH 0/5] perf timechart improvements part 2 Arnaldo Carvalho de Melo
  4 siblings, 1 reply; 23+ messages in thread
From: Stanislav Fomichev @ 2013-12-02 14:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: a.p.zijlstra, paulus, mingo, acme, stfomichev, namhyung, artagnon, jolsa

Print all CPUs, even if there were no events (use perf header to get number
of CPUs).
This is required to support topology in the next patch.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
---
 tools/perf/builtin-timechart.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 99fe363f1de8..db9c4c172587 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -531,12 +531,10 @@ static int process_sample_event(struct perf_tool *tool,
 			tchart->last_time = sample->time;
 	}
 
-	if (sample->cpu > tchart->numcpus)
-		tchart->numcpus = sample->cpu;
-
 	if (evsel->handler != NULL) {
 		tracepoint_handler f = evsel->handler;
-		return f(tchart, evsel, sample, cat_backtrace(event, sample, machine));
+		return f(tchart, evsel, sample,
+			 cat_backtrace(event, sample, machine));
 	}
 
 	return 0;
@@ -1038,8 +1036,6 @@ static void write_svg_file(struct timechart *tchart, const char *filename)
 	int count;
 	int thresh = TIME_THRESH;
 
-	tchart->numcpus++;
-
 	if (tchart->power_only)
 		tchart->proc_num = 0;
 
@@ -1069,6 +1065,25 @@ static void write_svg_file(struct timechart *tchart, const char *filename)
 	svg_close();
 }
 
+static int process_header(struct perf_file_section *section __maybe_unused,
+			  struct perf_header *ph,
+			  int feat,
+			  int fd __maybe_unused,
+			  void *data)
+{
+	struct timechart *tchart = data;
+
+	switch (feat) {
+	case HEADER_NRCPUS:
+		tchart->numcpus = ph->env.nr_cpus_avail;
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
 static int __cmd_timechart(struct timechart *tchart, const char *output_name)
 {
 	const struct perf_evsel_str_handler power_tracepoints[] = {
@@ -1094,6 +1109,11 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
 	if (session == NULL)
 		return -ENOMEM;
 
+	(void)perf_header__process_sections(&session->header,
+					    perf_data_file__fd(session->file),
+					    tchart,
+					    process_header);
+
 	if (!perf_session__has_traces(session, "timechart record"))
 		goto out_delete;
 
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/5] perf timechart: add support for topology
  2013-12-02 14:37 [PATCH 0/5] perf timechart improvements part 2 Stanislav Fomichev
                   ` (2 preceding siblings ...)
  2013-12-02 14:37 ` [PATCH 3/5] perf timechart: get number of CPUs from perf header Stanislav Fomichev
@ 2013-12-02 14:37 ` Stanislav Fomichev
  2013-12-18 10:31   ` [tip:perf/core] perf timechart: Add " tip-bot for Stanislav Fomichev
  2013-12-16 19:38 ` [PATCH 0/5] perf timechart improvements part 2 Arnaldo Carvalho de Melo
  4 siblings, 1 reply; 23+ messages in thread
From: Stanislav Fomichev @ 2013-12-02 14:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: a.p.zijlstra, paulus, mingo, acme, stfomichev, namhyung, artagnon, jolsa

Add -t switch to sort CPUs topologically.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
---
 tools/perf/Documentation/perf-timechart.txt |   3 +
 tools/perf/builtin-timechart.c              |  17 +++-
 tools/perf/util/svghelper.c                 | 132 +++++++++++++++++++++++++++-
 tools/perf/util/svghelper.h                 |   2 +
 4 files changed, 151 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
index 271dd4ed5b05..367c1be0551c 100644
--- a/tools/perf/Documentation/perf-timechart.txt
+++ b/tools/perf/Documentation/perf-timechart.txt
@@ -59,6 +59,9 @@ $ perf timechart
 -n::
 --proc-num::
         Print task info for at least given number of tasks.
+-t::
+--topology::
+        Sort CPUs according to topology.
 
 RECORD OPTIONS
 --------------
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index db9c4c172587..8bde57c5c908 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -58,7 +58,8 @@ struct timechart {
 				first_time, last_time;
 	bool			power_only,
 				tasks_only,
-				with_backtrace;
+				with_backtrace,
+				topology;
 };
 
 struct per_pidcomm;
@@ -1077,6 +1078,18 @@ static int process_header(struct perf_file_section *section __maybe_unused,
 	case HEADER_NRCPUS:
 		tchart->numcpus = ph->env.nr_cpus_avail;
 		break;
+
+	case HEADER_CPU_TOPOLOGY:
+		if (!tchart->topology)
+			break;
+
+		if (svg_build_topology_map(ph->env.sibling_cores,
+					   ph->env.nr_sibling_cores,
+					   ph->env.sibling_threads,
+					   ph->env.nr_sibling_threads))
+			fprintf(stderr, "problem building topology\n");
+		break;
+
 	default:
 		break;
 	}
@@ -1267,6 +1280,8 @@ int cmd_timechart(int argc, const char **argv,
 		    "Look for files with symbols relative to this directory"),
 	OPT_INTEGER('n', "proc-num", &tchart.proc_num,
 		    "min. number of tasks to print"),
+	OPT_BOOLEAN('t', "topology", &tchart.topology,
+		    "sort CPUs according to topology"),
 	OPT_END()
 	};
 	const char * const timechart_usage[] = {
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 927851d05d03..9468136735ca 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -17,8 +17,11 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#include <linux/bitops.h>
 
+#include "perf.h"
 #include "svghelper.h"
+#include "cpumap.h"
 
 static u64 first_time, last_time;
 static u64 turbo_frequency, max_freq;
@@ -39,9 +42,14 @@ static double cpu2slot(int cpu)
 	return 2 * cpu + 1;
 }
 
+static int *topology_map;
+
 static double cpu2y(int cpu)
 {
-	return cpu2slot(cpu) * SLOT_MULT;
+	if (topology_map)
+		return cpu2slot(topology_map[cpu]) * SLOT_MULT;
+	else
+		return cpu2slot(cpu) * SLOT_MULT;
 }
 
 static double time2pixels(u64 __time)
@@ -275,7 +283,7 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
 		time2pixels(last_time)-time2pixels(first_time),
 		cpu2y(cpu), SLOT_MULT+SLOT_HEIGHT);
 
-	sprintf(cpu_string, "CPU %i", (int)cpu+1);
+	sprintf(cpu_string, "CPU %i", (int)cpu);
 	fprintf(svgfile, "<text x=\"%4.8f\" y=\"%4.8f\">%s</text>\n",
 		10+time2pixels(first_time), cpu2y(cpu) + SLOT_HEIGHT/2, cpu_string);
 
@@ -568,3 +576,123 @@ void svg_close(void)
 		svgfile = NULL;
 	}
 }
+
+#define cpumask_bits(maskp) ((maskp)->bits)
+typedef struct { DECLARE_BITMAP(bits, MAX_NR_CPUS); } cpumask_t;
+
+struct topology {
+	cpumask_t *sib_core;
+	int sib_core_nr;
+	cpumask_t *sib_thr;
+	int sib_thr_nr;
+};
+
+static void scan_thread_topology(int *map, struct topology *t, int cpu, int *pos)
+{
+	int i;
+	int thr;
+
+	for (i = 0; i < t->sib_thr_nr; i++) {
+		if (!test_bit(cpu, cpumask_bits(&t->sib_thr[i])))
+			continue;
+
+		for_each_set_bit(thr,
+				 cpumask_bits(&t->sib_thr[i]),
+				 MAX_NR_CPUS)
+			if (map[thr] == -1)
+				map[thr] = (*pos)++;
+	}
+}
+
+static void scan_core_topology(int *map, struct topology *t)
+{
+	int pos = 0;
+	int i;
+	int cpu;
+
+	for (i = 0; i < t->sib_core_nr; i++)
+		for_each_set_bit(cpu,
+				 cpumask_bits(&t->sib_core[i]),
+				 MAX_NR_CPUS)
+			scan_thread_topology(map, t, cpu, &pos);
+}
+
+static int str_to_bitmap(char *s, cpumask_t *b)
+{
+	int i;
+	int ret = 0;
+	struct cpu_map *m;
+	int c;
+
+	m = cpu_map__new(s);
+	if (!m)
+		return -1;
+
+	for (i = 0; i < m->nr; i++) {
+		c = m->map[i];
+		if (c >= MAX_NR_CPUS) {
+			ret = -1;
+			break;
+		}
+
+		set_bit(c, cpumask_bits(b));
+	}
+
+	cpu_map__delete(m);
+
+	return ret;
+}
+
+int svg_build_topology_map(char *sib_core, int sib_core_nr,
+			   char *sib_thr, int sib_thr_nr)
+{
+	int i;
+	struct topology t;
+
+	t.sib_core_nr = sib_core_nr;
+	t.sib_thr_nr = sib_thr_nr;
+	t.sib_core = calloc(sib_core_nr, sizeof(cpumask_t));
+	t.sib_thr = calloc(sib_thr_nr, sizeof(cpumask_t));
+
+	if (!t.sib_core || !t.sib_thr) {
+		fprintf(stderr, "topology: no memory\n");
+		goto exit;
+	}
+
+	for (i = 0; i < sib_core_nr; i++) {
+		if (str_to_bitmap(sib_core, &t.sib_core[i])) {
+			fprintf(stderr, "topology: can't parse siblings map\n");
+			goto exit;
+		}
+
+		sib_core += strlen(sib_core) + 1;
+	}
+
+	for (i = 0; i < sib_thr_nr; i++) {
+		if (str_to_bitmap(sib_thr, &t.sib_thr[i])) {
+			fprintf(stderr, "topology: can't parse siblings map\n");
+			goto exit;
+		}
+
+		sib_thr += strlen(sib_thr) + 1;
+	}
+
+	topology_map = malloc(sizeof(int) * MAX_NR_CPUS);
+	if (!topology_map) {
+		fprintf(stderr, "topology: no memory\n");
+		goto exit;
+	}
+
+	for (i = 0; i < MAX_NR_CPUS; i++)
+		topology_map[i] = -1;
+
+	scan_core_topology(topology_map, &t);
+
+	return 0;
+
+exit:
+	free(t.sib_core);
+	free(t.sib_thr);
+
+	return -1;
+}
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index 8b77ca631686..1df4fb6c3a4a 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -23,6 +23,8 @@ extern void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, cha
 extern void svg_interrupt(u64 start, int row, const char *backtrace);
 extern void svg_text(int Yslot, u64 start, const char *text);
 extern void svg_close(void);
+extern int svg_build_topology_map(char *sib_core, int sib_core_nr,
+				  char *sib_thr, int sib_thr_nr);
 
 extern int svg_page_width;
 
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 0/5] perf timechart improvements part 2
  2013-12-02 14:37 [PATCH 0/5] perf timechart improvements part 2 Stanislav Fomichev
                   ` (3 preceding siblings ...)
  2013-12-02 14:37 ` [PATCH 4/5] perf timechart: add support for topology Stanislav Fomichev
@ 2013-12-16 19:38 ` Arnaldo Carvalho de Melo
  2013-12-17  9:38   ` [PATCH 5/5] perf timechart: add emphasize option Stanislav Fomichev
  4 siblings, 1 reply; 23+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-16 19:38 UTC (permalink / raw)
  To: Stanislav Fomichev
  Cc: linux-kernel, a.p.zijlstra, paulus, mingo, namhyung, artagnon, jolsa

Em Mon, Dec 02, 2013 at 06:37:32PM +0400, Stanislav Fomichev escreveu:
> This patch series has the following features:
> - adds backtrace info to the CPU overview chart
> - adds pid info to the figures on CPU overview chart
> - we now read number of CPUs from the perf.data header (this makes CPU overview
>   more accurate since it shows idle cores)
> - adds '-t' option to sort CPUs (on the CPU overview chart) topologically (draw
>   adjacent SMT threads next to each other)
> - adds '-e' option to highlight long events on the CPU overview chart
> 
> Stanislav Fomichev (5):
>   perf timechart: add backtrace support to CPU info
>   perf timechart: print pid along the name
>   perf timechart: get number of CPUs from perf header
>   perf timechart: add support for topology

>   perf timechart: add emphasize option

This one, 5/5, didn't made it to me or the mailing list, can you resend?

- Arnaldo

> 
>  tools/perf/Documentation/perf-timechart.txt |   7 ++
>  tools/perf/builtin-timechart.c              |  79 ++++++++++++--
>  tools/perf/util/svghelper.c                 | 159 ++++++++++++++++++++++++++--
>  tools/perf/util/svghelper.h                 |   6 +-
>  4 files changed, 235 insertions(+), 16 deletions(-)
> 
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 5/5] perf timechart: add emphasize option
  2013-12-16 19:38 ` [PATCH 0/5] perf timechart improvements part 2 Arnaldo Carvalho de Melo
@ 2013-12-17  9:38   ` Stanislav Fomichev
  2013-12-17 11:23     ` Ingo Molnar
  0 siblings, 1 reply; 23+ messages in thread
From: Stanislav Fomichev @ 2013-12-17  9:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, a.p.zijlstra, paulus, mingo, namhyung, artagnon, jolsa

This option highlights tasks (using different color) that run more than given
duration or tasks with given name.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
---
 tools/perf/Documentation/perf-timechart.txt |  4 ++++
 tools/perf/builtin-timechart.c              | 21 ++++++++++++++++++++-
 tools/perf/util/svghelper.c                 | 23 ++++++++++++++++++++---
 tools/perf/util/svghelper.h                 |  4 +++-
 4 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
index 367c1be0551c..aac589b0d377 100644
--- a/tools/perf/Documentation/perf-timechart.txt
+++ b/tools/perf/Documentation/perf-timechart.txt
@@ -62,6 +62,10 @@ $ perf timechart
 -t::
 --topology::
         Sort CPUs according to topology.
+-e::
+--emphasize::
+        Emphasize tasks which were running at least given number of
+        nanoseconds or tasks with given name.
 
 RECORD OPTIONS
 --------------
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 8bde57c5c908..c0dcb05909b2 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -841,7 +841,6 @@ static void draw_cpu_usage(struct timechart *tchart)
 						    sample->start_time,
 						    sample->end_time,
 						    p->pid,
-						    "sample",
 						    c->comm,
 						    sample->backtrace);
 				}
@@ -1252,6 +1251,23 @@ parse_process(const struct option *opt __maybe_unused, const char *arg,
 	return 0;
 }
 
+static int
+parse_emphasize(const struct option *opt __maybe_unused, const char *arg,
+		int __maybe_unused unset)
+{
+	unsigned long duration = strtoul(arg, NULL, 0);
+
+	if (svg_emphasize || svg_emphasize_name)
+		return -1;
+
+	if (duration)
+		svg_emphasize = duration;
+	else
+		svg_emphasize_name = strdup(arg);
+
+	return 0;
+}
+
 int cmd_timechart(int argc, const char **argv,
 		  const char *prefix __maybe_unused)
 {
@@ -1270,6 +1286,9 @@ int cmd_timechart(int argc, const char **argv,
 	OPT_STRING('i', "input", &input_name, "file", "input file name"),
 	OPT_STRING('o', "output", &output_name, "file", "output file name"),
 	OPT_INTEGER('w', "width", &svg_page_width, "page width"),
+	OPT_CALLBACK('e', "emphasize", NULL, "duration or name",
+		      "emphasize tasks. Pass duration in ns or process name.",
+		       parse_emphasize),
 	OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"),
 	OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only,
 		    "output processes data only"),
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 9468136735ca..f056a7450e5f 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -31,6 +31,8 @@ static u64 turbo_frequency, max_freq;
 #define SLOT_HEIGHT 25.0
 
 int svg_page_width = 1000;
+u64 svg_emphasize;
+const char *svg_emphasize_name;
 
 #define MIN_TEXT_SIZE 0.01
 
@@ -112,6 +114,7 @@ void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end)
 	fprintf(svgfile, "      rect.process  { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:1;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.process2 { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.sample   { fill:rgb(  0,  0,255); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
+	fprintf(svgfile, "      rect.sample_em{ fill:rgb(255,128,  0); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.blocked  { fill:rgb(255,  0,  0); fill-opacity:0.5; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.waiting  { fill:rgb(224,214,  0); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.WAITING  { fill:rgb(255,214, 48); fill-opacity:0.6; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
@@ -155,17 +158,24 @@ void svg_blocked(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 void svg_running(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 {
 	double text_size;
+	const char *type;
+
 	if (!svgfile)
 		return;
 
+	if (svg_emphasize && end - start > svg_emphasize)
+		type = "sample_em";
+	else
+		type = "sample";
 	fprintf(svgfile, "<g>\n");
 
 	fprintf(svgfile, "<title>#%d running %s</title>\n",
 		cpu, time_to_string(end - start));
 	if (backtrace)
 		fprintf(svgfile, "<desc>Switched because:\n%s</desc>\n", backtrace);
-	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"sample\"/>\n",
-		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT);
+	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"%s\"/>\n",
+		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT,
+		type);
 
 	text_size = (time2pixels(end)-time2pixels(start));
 	if (cpu > 9)
@@ -293,13 +303,20 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace)
+void svg_process(int cpu, u64 start, u64 end, int pid, const char *name, const char *backtrace)
 {
 	double width;
+	const char *type;
 
 	if (!svgfile)
 		return;
 
+	if (svg_emphasize && end - start >= svg_emphasize)
+		type = "sample_em";
+	else if (svg_emphasize_name && strstr(name, svg_emphasize_name))
+		type = "sample_em";
+	else
+		type = "sample";
 
 	fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu));
 	fprintf(svgfile, "<title>%d %s running %s</title>\n", pid, name, time_to_string(end - start));
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index 1df4fb6c3a4a..10b4187bff6a 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -11,7 +11,7 @@ extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *back
 extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
 
 
-extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace);
+extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *name, const char *backtrace);
 extern void svg_cstate(int cpu, u64 start, u64 end, int type);
 extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
 
@@ -27,5 +27,7 @@ extern int svg_build_topology_map(char *sib_core, int sib_core_nr,
 				  char *sib_thr, int sib_thr_nr);
 
 extern int svg_page_width;
+extern u64 svg_emphasize;
+extern const char *svg_emphasize_name;
 
 #endif /* __PERF_SVGHELPER_H */
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5] perf timechart: add emphasize option
  2013-12-17  9:38   ` [PATCH 5/5] perf timechart: add emphasize option Stanislav Fomichev
@ 2013-12-17 11:23     ` Ingo Molnar
  2013-12-17 12:15       ` [PATCH 5/5 v2] " Stanislav Fomichev
  0 siblings, 1 reply; 23+ messages in thread
From: Ingo Molnar @ 2013-12-17 11:23 UTC (permalink / raw)
  To: Stanislav Fomichev
  Cc: Arnaldo Carvalho de Melo, linux-kernel, a.p.zijlstra, paulus,
	mingo, namhyung, artagnon, jolsa


* Stanislav Fomichev <stfomichev@yandex-team.ru> wrote:

> This option highlights tasks (using different color) that run more than given
> duration or tasks with given name.

Please give a sample usage command line and a sample output. (the 
highlighting can be done using ASCII escape sequences in the changelog 
as well.)

> 
> Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
> ---
>  tools/perf/Documentation/perf-timechart.txt |  4 ++++
>  tools/perf/builtin-timechart.c              | 21 ++++++++++++++++++++-
>  tools/perf/util/svghelper.c                 | 23 ++++++++++++++++++++---
>  tools/perf/util/svghelper.h                 |  4 +++-
>  4 files changed, 47 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
> index 367c1be0551c..aac589b0d377 100644
> --- a/tools/perf/Documentation/perf-timechart.txt
> +++ b/tools/perf/Documentation/perf-timechart.txt
> @@ -62,6 +62,10 @@ $ perf timechart
>  -t::
>  --topology::
>          Sort CPUs according to topology.
> +-e::
> +--emphasize::

So -e comes with an option - the syntax to describe those in manpages 
is:

  -e::
  --emphasize=<duration_nsecs|task_name>::

or so.

> +        Emphasize tasks which were running at least given number of
> +        nanoseconds or tasks with given name.

So the information in the changelog, that 'emphasize' means 'highlight 
via coloring' is lost in the documentation of the option, making it 
rather hard for users to discover and appreciate this feature...

It's also not made clear that the option can take a numeric input, and 
if the input is numeric, it is interpreted as a task name.

So please make features more approachable!

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5 v2] perf timechart: add emphasize option
  2013-12-17 11:23     ` Ingo Molnar
@ 2013-12-17 12:15       ` Stanislav Fomichev
  2013-12-17 13:12         ` Ingo Molnar
  2013-12-17 13:38         ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 23+ messages in thread
From: Stanislav Fomichev @ 2013-12-17 12:15 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Arnaldo Carvalho de Melo, linux-kernel, a.p.zijlstra, paulus,
	mingo, namhyung, artagnon, jolsa

> Please give a sample usage command line and a sample output. (the 
> highlighting can be done using ASCII escape sequences in the changelog 
> as well.)
Highlighting is done in the generated SVG, so I can't really show it in
the log or documentation. But I added simple example with -e option.

>   -e::
>   --emphasize=<duration_nsecs|task_name>::
Thanks, added.

> It's also not made clear that the option can take a numeric input, and 
> if the input is numeric, it is interpreted as a task name.
> 
> So please make features more approachable!
Added more info to the documentation.

Attached new patch below.

---

This option highlights tasks (using different color) that run more than given
duration or tasks with given name.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
---
 tools/perf/Documentation/perf-timechart.txt | 14 ++++++++++++++
 tools/perf/builtin-timechart.c              | 21 ++++++++++++++++++++-
 tools/perf/util/svghelper.c                 | 23 ++++++++++++++++++++---
 tools/perf/util/svghelper.h                 |  4 +++-
 4 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
index 367c1be0551c..b81e91dd16ce 100644
--- a/tools/perf/Documentation/perf-timechart.txt
+++ b/tools/perf/Documentation/perf-timechart.txt
@@ -56,12 +56,26 @@ $ perf timechart
 
   Written 10.2 seconds of trace to output.svg.
 
+Record system-wide timechart:
+
+  $ perf timechart record
+
+  then generate timechart and highlight 'gcc' tasks:
+
+  $ perf timechart -e gcc
+
 -n::
 --proc-num::
         Print task info for at least given number of tasks.
 -t::
 --topology::
         Sort CPUs according to topology.
+-e::
+--emphasize=<duration_nsecs|task_name>::
+	Highlight tasks (using different color) that run more than given
+	duration or tasks with given name. If number is given it's interpreted
+	as number of nanoseconds. If non-numeric string is given it's
+	interpreted as task name.
 
 RECORD OPTIONS
 --------------
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 8bde57c5c908..c0dcb05909b2 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -841,7 +841,6 @@ static void draw_cpu_usage(struct timechart *tchart)
 						    sample->start_time,
 						    sample->end_time,
 						    p->pid,
-						    "sample",
 						    c->comm,
 						    sample->backtrace);
 				}
@@ -1252,6 +1251,23 @@ parse_process(const struct option *opt __maybe_unused, const char *arg,
 	return 0;
 }
 
+static int
+parse_emphasize(const struct option *opt __maybe_unused, const char *arg,
+		int __maybe_unused unset)
+{
+	unsigned long duration = strtoul(arg, NULL, 0);
+
+	if (svg_emphasize || svg_emphasize_name)
+		return -1;
+
+	if (duration)
+		svg_emphasize = duration;
+	else
+		svg_emphasize_name = strdup(arg);
+
+	return 0;
+}
+
 int cmd_timechart(int argc, const char **argv,
 		  const char *prefix __maybe_unused)
 {
@@ -1270,6 +1286,9 @@ int cmd_timechart(int argc, const char **argv,
 	OPT_STRING('i', "input", &input_name, "file", "input file name"),
 	OPT_STRING('o', "output", &output_name, "file", "output file name"),
 	OPT_INTEGER('w', "width", &svg_page_width, "page width"),
+	OPT_CALLBACK('e', "emphasize", NULL, "duration or name",
+		      "emphasize tasks. Pass duration in ns or process name.",
+		       parse_emphasize),
 	OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"),
 	OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only,
 		    "output processes data only"),
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 9468136735ca..f056a7450e5f 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -31,6 +31,8 @@ static u64 turbo_frequency, max_freq;
 #define SLOT_HEIGHT 25.0
 
 int svg_page_width = 1000;
+u64 svg_emphasize;
+const char *svg_emphasize_name;
 
 #define MIN_TEXT_SIZE 0.01
 
@@ -112,6 +114,7 @@ void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end)
 	fprintf(svgfile, "      rect.process  { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:1;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.process2 { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.sample   { fill:rgb(  0,  0,255); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
+	fprintf(svgfile, "      rect.sample_em{ fill:rgb(255,128,  0); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.blocked  { fill:rgb(255,  0,  0); fill-opacity:0.5; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.waiting  { fill:rgb(224,214,  0); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.WAITING  { fill:rgb(255,214, 48); fill-opacity:0.6; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
@@ -155,17 +158,24 @@ void svg_blocked(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 void svg_running(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 {
 	double text_size;
+	const char *type;
+
 	if (!svgfile)
 		return;
 
+	if (svg_emphasize && end - start > svg_emphasize)
+		type = "sample_em";
+	else
+		type = "sample";
 	fprintf(svgfile, "<g>\n");
 
 	fprintf(svgfile, "<title>#%d running %s</title>\n",
 		cpu, time_to_string(end - start));
 	if (backtrace)
 		fprintf(svgfile, "<desc>Switched because:\n%s</desc>\n", backtrace);
-	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"sample\"/>\n",
-		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT);
+	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"%s\"/>\n",
+		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT,
+		type);
 
 	text_size = (time2pixels(end)-time2pixels(start));
 	if (cpu > 9)
@@ -293,13 +303,20 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace)
+void svg_process(int cpu, u64 start, u64 end, int pid, const char *name, const char *backtrace)
 {
 	double width;
+	const char *type;
 
 	if (!svgfile)
 		return;
 
+	if (svg_emphasize && end - start >= svg_emphasize)
+		type = "sample_em";
+	else if (svg_emphasize_name && strstr(name, svg_emphasize_name))
+		type = "sample_em";
+	else
+		type = "sample";
 
 	fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu));
 	fprintf(svgfile, "<title>%d %s running %s</title>\n", pid, name, time_to_string(end - start));
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index 1df4fb6c3a4a..10b4187bff6a 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -11,7 +11,7 @@ extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *back
 extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
 
 
-extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace);
+extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *name, const char *backtrace);
 extern void svg_cstate(int cpu, u64 start, u64 end, int type);
 extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
 
@@ -27,5 +27,7 @@ extern int svg_build_topology_map(char *sib_core, int sib_core_nr,
 				  char *sib_thr, int sib_thr_nr);
 
 extern int svg_page_width;
+extern u64 svg_emphasize;
+extern const char *svg_emphasize_name;
 
 #endif /* __PERF_SVGHELPER_H */
-- 
1.8.3.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5 v2] perf timechart: add emphasize option
  2013-12-17 12:15       ` [PATCH 5/5 v2] " Stanislav Fomichev
@ 2013-12-17 13:12         ` Ingo Molnar
  2013-12-17 13:38         ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2013-12-17 13:12 UTC (permalink / raw)
  To: Stanislav Fomichev
  Cc: Arnaldo Carvalho de Melo, linux-kernel, a.p.zijlstra, paulus,
	mingo, namhyung, artagnon, jolsa


* Stanislav Fomichev <stfomichev@yandex-team.ru> wrote:

> > Please give a sample usage command line and a sample output. (the 
> > highlighting can be done using ASCII escape sequences in the changelog 
> > as well.)
> Highlighting is done in the generated SVG, so I can't really show it in
> the log or documentation. But I added simple example with -e option.
> 
> >   -e::
> >   --emphasize=<duration_nsecs|task_name>::
> Thanks, added.
> 
> > It's also not made clear that the option can take a numeric input, and 
> > if the input is numeric, it is interpreted as a task name.
> > 
> > So please make features more approachable!
> Added more info to the documentation.
> 
> Attached new patch below.
> 
> ---
> 
> This option highlights tasks (using different color) that run more than given
> duration or tasks with given name.
> 
> Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
> ---
>  tools/perf/Documentation/perf-timechart.txt | 14 ++++++++++++++
>  tools/perf/builtin-timechart.c              | 21 ++++++++++++++++++++-
>  tools/perf/util/svghelper.c                 | 23 ++++++++++++++++++++---
>  tools/perf/util/svghelper.h                 |  4 +++-
>  4 files changed, 57 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
> index 367c1be0551c..b81e91dd16ce 100644
> --- a/tools/perf/Documentation/perf-timechart.txt
> +++ b/tools/perf/Documentation/perf-timechart.txt
> @@ -56,12 +56,26 @@ $ perf timechart
>  
>    Written 10.2 seconds of trace to output.svg.
>  
> +Record system-wide timechart:
> +
> +  $ perf timechart record
> +
> +  then generate timechart and highlight 'gcc' tasks:
> +
> +  $ perf timechart -e gcc
> +
>  -n::
>  --proc-num::
>          Print task info for at least given number of tasks.
>  -t::
>  --topology::
>          Sort CPUs according to topology.
> +-e::
> +--emphasize=<duration_nsecs|task_name>::
> +	Highlight tasks (using different color) that run more than given
> +	duration or tasks with given name. If number is given it's interpreted
> +	as number of nanoseconds. If non-numeric string is given it's
> +	interpreted as task name.

Looks good to me, thanks!

Acked-by: Ingo Molnar <mingo@kernel.org>

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5 v2] perf timechart: add emphasize option
  2013-12-17 12:15       ` [PATCH 5/5 v2] " Stanislav Fomichev
  2013-12-17 13:12         ` Ingo Molnar
@ 2013-12-17 13:38         ` Arnaldo Carvalho de Melo
  2013-12-17 13:41           ` Ingo Molnar
  1 sibling, 1 reply; 23+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-17 13:38 UTC (permalink / raw)
  To: Stanislav Fomichev
  Cc: Ingo Molnar, linux-kernel, a.p.zijlstra, paulus, mingo, namhyung,
	artagnon, jolsa

Em Tue, Dec 17, 2013 at 04:15:22PM +0400, Stanislav Fomichev escreveu:
> > Please give a sample usage command line and a sample output. (the 
> > highlighting can be done using ASCII escape sequences in the changelog 
> > as well.)
> Highlighting is done in the generated SVG, so I can't really show it in
> the log or documentation. But I added simple example with -e option.
> 
> >   -e::
> >   --emphasize=<duration_nsecs|task_name>::
> Thanks, added.

I also wonder how to allocate single letter options here... can we live
with just --emphasize for now? Wouldn't at some point we maybe want to
use -e in 'perf timechart' to pick some specific event, and then, to
make it consistent with the other tools, -e would then be used?

- Arnaldo
 
> > It's also not made clear that the option can take a numeric input, and 
> > if the input is numeric, it is interpreted as a task name.
> > 
> > So please make features more approachable!
> Added more info to the documentation.
> 
> Attached new patch below.
> 
> ---
> 
> This option highlights tasks (using different color) that run more than given
> duration or tasks with given name.
> 
> Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
> ---
>  tools/perf/Documentation/perf-timechart.txt | 14 ++++++++++++++
>  tools/perf/builtin-timechart.c              | 21 ++++++++++++++++++++-
>  tools/perf/util/svghelper.c                 | 23 ++++++++++++++++++++---
>  tools/perf/util/svghelper.h                 |  4 +++-
>  4 files changed, 57 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
> index 367c1be0551c..b81e91dd16ce 100644
> --- a/tools/perf/Documentation/perf-timechart.txt
> +++ b/tools/perf/Documentation/perf-timechart.txt
> @@ -56,12 +56,26 @@ $ perf timechart
>  
>    Written 10.2 seconds of trace to output.svg.
>  
> +Record system-wide timechart:
> +
> +  $ perf timechart record
> +
> +  then generate timechart and highlight 'gcc' tasks:
> +
> +  $ perf timechart -e gcc
> +
>  -n::
>  --proc-num::
>          Print task info for at least given number of tasks.
>  -t::
>  --topology::
>          Sort CPUs according to topology.
> +-e::
> +--emphasize=<duration_nsecs|task_name>::
> +	Highlight tasks (using different color) that run more than given
> +	duration or tasks with given name. If number is given it's interpreted
> +	as number of nanoseconds. If non-numeric string is given it's
> +	interpreted as task name.
>  
>  RECORD OPTIONS
>  --------------
> diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
> index 8bde57c5c908..c0dcb05909b2 100644
> --- a/tools/perf/builtin-timechart.c
> +++ b/tools/perf/builtin-timechart.c
> @@ -841,7 +841,6 @@ static void draw_cpu_usage(struct timechart *tchart)
>  						    sample->start_time,
>  						    sample->end_time,
>  						    p->pid,
> -						    "sample",
>  						    c->comm,
>  						    sample->backtrace);
>  				}
> @@ -1252,6 +1251,23 @@ parse_process(const struct option *opt __maybe_unused, const char *arg,
>  	return 0;
>  }
>  
> +static int
> +parse_emphasize(const struct option *opt __maybe_unused, const char *arg,
> +		int __maybe_unused unset)
> +{
> +	unsigned long duration = strtoul(arg, NULL, 0);
> +
> +	if (svg_emphasize || svg_emphasize_name)
> +		return -1;
> +
> +	if (duration)
> +		svg_emphasize = duration;
> +	else
> +		svg_emphasize_name = strdup(arg);
> +
> +	return 0;
> +}
> +
>  int cmd_timechart(int argc, const char **argv,
>  		  const char *prefix __maybe_unused)
>  {
> @@ -1270,6 +1286,9 @@ int cmd_timechart(int argc, const char **argv,
>  	OPT_STRING('i', "input", &input_name, "file", "input file name"),
>  	OPT_STRING('o', "output", &output_name, "file", "output file name"),
>  	OPT_INTEGER('w', "width", &svg_page_width, "page width"),
> +	OPT_CALLBACK('e', "emphasize", NULL, "duration or name",
> +		      "emphasize tasks. Pass duration in ns or process name.",
> +		       parse_emphasize),
>  	OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"),
>  	OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only,
>  		    "output processes data only"),
> diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
> index 9468136735ca..f056a7450e5f 100644
> --- a/tools/perf/util/svghelper.c
> +++ b/tools/perf/util/svghelper.c
> @@ -31,6 +31,8 @@ static u64 turbo_frequency, max_freq;
>  #define SLOT_HEIGHT 25.0
>  
>  int svg_page_width = 1000;
> +u64 svg_emphasize;
> +const char *svg_emphasize_name;
>  
>  #define MIN_TEXT_SIZE 0.01
>  
> @@ -112,6 +114,7 @@ void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end)
>  	fprintf(svgfile, "      rect.process  { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:1;   stroke:rgb(  0,  0,  0); } \n");
>  	fprintf(svgfile, "      rect.process2 { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
>  	fprintf(svgfile, "      rect.sample   { fill:rgb(  0,  0,255); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
> +	fprintf(svgfile, "      rect.sample_em{ fill:rgb(255,128,  0); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
>  	fprintf(svgfile, "      rect.blocked  { fill:rgb(255,  0,  0); fill-opacity:0.5; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
>  	fprintf(svgfile, "      rect.waiting  { fill:rgb(224,214,  0); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
>  	fprintf(svgfile, "      rect.WAITING  { fill:rgb(255,214, 48); fill-opacity:0.6; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
> @@ -155,17 +158,24 @@ void svg_blocked(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
>  void svg_running(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
>  {
>  	double text_size;
> +	const char *type;
> +
>  	if (!svgfile)
>  		return;
>  
> +	if (svg_emphasize && end - start > svg_emphasize)
> +		type = "sample_em";
> +	else
> +		type = "sample";
>  	fprintf(svgfile, "<g>\n");
>  
>  	fprintf(svgfile, "<title>#%d running %s</title>\n",
>  		cpu, time_to_string(end - start));
>  	if (backtrace)
>  		fprintf(svgfile, "<desc>Switched because:\n%s</desc>\n", backtrace);
> -	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"sample\"/>\n",
> -		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT);
> +	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"%s\"/>\n",
> +		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT,
> +		type);
>  
>  	text_size = (time2pixels(end)-time2pixels(start));
>  	if (cpu > 9)
> @@ -293,13 +303,20 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
>  	fprintf(svgfile, "</g>\n");
>  }
>  
> -void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace)
> +void svg_process(int cpu, u64 start, u64 end, int pid, const char *name, const char *backtrace)
>  {
>  	double width;
> +	const char *type;
>  
>  	if (!svgfile)
>  		return;
>  
> +	if (svg_emphasize && end - start >= svg_emphasize)
> +		type = "sample_em";
> +	else if (svg_emphasize_name && strstr(name, svg_emphasize_name))
> +		type = "sample_em";
> +	else
> +		type = "sample";
>  
>  	fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu));
>  	fprintf(svgfile, "<title>%d %s running %s</title>\n", pid, name, time_to_string(end - start));
> diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
> index 1df4fb6c3a4a..10b4187bff6a 100644
> --- a/tools/perf/util/svghelper.h
> +++ b/tools/perf/util/svghelper.h
> @@ -11,7 +11,7 @@ extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *back
>  extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
>  
>  
> -extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace);
> +extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *name, const char *backtrace);
>  extern void svg_cstate(int cpu, u64 start, u64 end, int type);
>  extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
>  
> @@ -27,5 +27,7 @@ extern int svg_build_topology_map(char *sib_core, int sib_core_nr,
>  				  char *sib_thr, int sib_thr_nr);
>  
>  extern int svg_page_width;
> +extern u64 svg_emphasize;
> +extern const char *svg_emphasize_name;
>  
>  #endif /* __PERF_SVGHELPER_H */
> -- 
> 1.8.3.2
> 

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5 v2] perf timechart: add emphasize option
  2013-12-17 13:38         ` Arnaldo Carvalho de Melo
@ 2013-12-17 13:41           ` Ingo Molnar
  2013-12-17 13:59             ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 23+ messages in thread
From: Ingo Molnar @ 2013-12-17 13:41 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Stanislav Fomichev, linux-kernel, a.p.zijlstra, paulus, mingo,
	namhyung, artagnon, jolsa


* Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:

> Em Tue, Dec 17, 2013 at 04:15:22PM +0400, Stanislav Fomichev escreveu:
> > > Please give a sample usage command line and a sample output. (the 
> > > highlighting can be done using ASCII escape sequences in the changelog 
> > > as well.)
> > Highlighting is done in the generated SVG, so I can't really show it in
> > the log or documentation. But I added simple example with -e option.
> > 
> > >   -e::
> > >   --emphasize=<duration_nsecs|task_name>::
> > Thanks, added.
> 
> I also wonder how to allocate single letter options here... can we live
> with just --emphasize for now? Wouldn't at some point we maybe want to
> use -e in 'perf timechart' to pick some specific event, and then, to
> make it consistent with the other tools, -e would then be used?

I wanted to raise a similar argument too - so if we don't have to do 
-e then maybe '--grep' would be the better option name?

If it becomes popular then the pattern matching can be improved, 
without having to change the option name and such.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5 v2] perf timechart: add emphasize option
  2013-12-17 13:41           ` Ingo Molnar
@ 2013-12-17 13:59             ` Arnaldo Carvalho de Melo
  2013-12-17 14:06               ` Ingo Molnar
  0 siblings, 1 reply; 23+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-17 13:59 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Stanislav Fomichev, linux-kernel, a.p.zijlstra, paulus, mingo,
	namhyung, artagnon, jolsa

Em Tue, Dec 17, 2013 at 02:41:37PM +0100, Ingo Molnar escreveu:
> * Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:
> > Em Tue, Dec 17, 2013 at 04:15:22PM +0400, Stanislav Fomichev escreveu:
> > > > Please give a sample usage command line and a sample output. (the 
> > > > highlighting can be done using ASCII escape sequences in the changelog 
> > > > as well.)
> > > Highlighting is done in the generated SVG, so I can't really show it in
> > > the log or documentation. But I added simple example with -e option.

> > > >   -e::
> > > >   --emphasize=<duration_nsecs|task_name>::
> > > Thanks, added.

> > I also wonder how to allocate single letter options here... can we live
> > with just --emphasize for now? Wouldn't at some point we maybe want to
> > use -e in 'perf timechart' to pick some specific event, and then, to
> > make it consistent with the other tools, -e would then be used?
 
> I wanted to raise a similar argument too - so if we don't have to do 
> -e then maybe '--grep' would be the better option name?
 
> If it becomes popular then the pattern matching can be improved, 
> without having to change the option name and such.

Humm, 'grep' is a filter, i.e. something that removes parts of the data
being perused, while this case it will not filter anything, it will just
make something that matches some search criteria to stand out from the
rest, that is still there, so perhaps --emphasize is Ok albeit kinda
long...

Do we have any other command line tool that has a long standing
semantics of "highlighting" or "emphasizing" parts of a data stream?

- Arnaldo

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5 v2] perf timechart: add emphasize option
  2013-12-17 13:59             ` Arnaldo Carvalho de Melo
@ 2013-12-17 14:06               ` Ingo Molnar
  2013-12-17 14:15                 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 23+ messages in thread
From: Ingo Molnar @ 2013-12-17 14:06 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Stanislav Fomichev, linux-kernel, a.p.zijlstra, paulus, mingo,
	namhyung, artagnon, jolsa


* Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:

> Em Tue, Dec 17, 2013 at 02:41:37PM +0100, Ingo Molnar escreveu:
> > * Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:
> > > Em Tue, Dec 17, 2013 at 04:15:22PM +0400, Stanislav Fomichev escreveu:
> > > > > Please give a sample usage command line and a sample output. (the 
> > > > > highlighting can be done using ASCII escape sequences in the changelog 
> > > > > as well.)
> > > > Highlighting is done in the generated SVG, so I can't really show it in
> > > > the log or documentation. But I added simple example with -e option.
> 
> > > > >   -e::
> > > > >   --emphasize=<duration_nsecs|task_name>::
> > > > Thanks, added.
> 
> > > I also wonder how to allocate single letter options here... can we live
> > > with just --emphasize for now? Wouldn't at some point we maybe want to
> > > use -e in 'perf timechart' to pick some specific event, and then, to
> > > make it consistent with the other tools, -e would then be used?
>  
> > I wanted to raise a similar argument too - so if we don't have to do 
> > -e then maybe '--grep' would be the better option name?
>  
> > If it becomes popular then the pattern matching can be improved, 
> > without having to change the option name and such.
> 
> Humm, 'grep' is a filter, i.e. something that removes parts of the 
> data being perused, while this case it will not filter anything, it 
> will just make something that matches some search criteria to stand 
> out from the rest, that is still there, so perhaps --emphasize is Ok 
> albeit kinda long...

So I frequently use grep with -C 1000 --color=always to also show the 
context. But --grep-context sounds too long.

Maybe --highlight ?

> Do we have any other command line tool that has a long standing 
> semantics of "highlighting" or "emphasizing" parts of a data stream?

Yeah, grep's -C, -A, -B options. (--context, --context-after, 
--context-before), combined with the --color option to highlight.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5 v2] perf timechart: add emphasize option
  2013-12-17 14:06               ` Ingo Molnar
@ 2013-12-17 14:15                 ` Arnaldo Carvalho de Melo
  2013-12-17 14:26                   ` Ingo Molnar
                                     ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Arnaldo Carvalho de Melo @ 2013-12-17 14:15 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Stanislav Fomichev, linux-kernel, a.p.zijlstra, paulus, mingo,
	namhyung, artagnon, jolsa

Em Tue, Dec 17, 2013 at 03:06:08PM +0100, Ingo Molnar escreveu:
> * Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:
> > Em Tue, Dec 17, 2013 at 02:41:37PM +0100, Ingo Molnar escreveu:
> > > * Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:
> > > > Em Tue, Dec 17, 2013 at 04:15:22PM +0400, Stanislav Fomichev escreveu:
> > > > > > Please give a sample usage command line and a sample output. (the 
> > > > > > highlighting can be done using ASCII escape sequences in the changelog 
> > > > > > as well.)
> > > > > Highlighting is done in the generated SVG, so I can't really show it in
> > > > > the log or documentation. But I added simple example with -e option.

> > > > > >   -e::
> > > > > >   --emphasize=<duration_nsecs|task_name>::
> > > > > Thanks, added.

> > > > I also wonder how to allocate single letter options here... can we live
> > > > with just --emphasize for now? Wouldn't at some point we maybe want to
> > > > use -e in 'perf timechart' to pick some specific event, and then, to
> > > > make it consistent with the other tools, -e would then be used?

> > > I wanted to raise a similar argument too - so if we don't have to do 
> > > -e then maybe '--grep' would be the better option name?

> > > If it becomes popular then the pattern matching can be improved, 
> > > without having to change the option name and such.

> > Humm, 'grep' is a filter, i.e. something that removes parts of the 
> > data being perused, while this case it will not filter anything, it 
> > will just make something that matches some search criteria to stand 
> > out from the rest, that is still there, so perhaps --emphasize is Ok 
> > albeit kinda long...
> 
> So I frequently use grep with -C 1000 --color=always to also show the 
> context. But --grep-context sounds too long.

Just tried it here, and on fedora 18 one doesn't even needs the
--color=always, but then basic grep usage doesn't imply showing contexts
and highlighting, i.e. grep grew into a swiss knife, like many others
:-\
 
> Maybe --highlight ?

That is ok for me, I think it is better than --emphasize
 
> > Do we have any other command line tool that has a long standing 
> > semantics of "highlighting" or "emphasizing" parts of a data stream?
> 
> Yeah, grep's -C, -A, -B options. (--context, --context-after, 
> --context-before), combined with the --color option to highlight.

I don't feel like there is a direct mapping of what he wants to achieve
to reusing the 'grep' keyword, at least it didn't sound natural at first
sight to me. :-)

- Arnaldo

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5 v2] perf timechart: add emphasize option
  2013-12-17 14:15                 ` Arnaldo Carvalho de Melo
@ 2013-12-17 14:26                   ` Ingo Molnar
  2013-12-17 15:03                   ` David Ahern
  2013-12-17 15:53                   ` Stanislav Fomichev
  2 siblings, 0 replies; 23+ messages in thread
From: Ingo Molnar @ 2013-12-17 14:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Stanislav Fomichev, linux-kernel, a.p.zijlstra, paulus, mingo,
	namhyung, artagnon, jolsa


* Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:

> Em Tue, Dec 17, 2013 at 03:06:08PM +0100, Ingo Molnar escreveu:
> > * Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:
> > > Em Tue, Dec 17, 2013 at 02:41:37PM +0100, Ingo Molnar escreveu:
> > > > * Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:
> > > > > Em Tue, Dec 17, 2013 at 04:15:22PM +0400, Stanislav Fomichev escreveu:
> > > > > > > Please give a sample usage command line and a sample output. (the 
> > > > > > > highlighting can be done using ASCII escape sequences in the changelog 
> > > > > > > as well.)
> > > > > > Highlighting is done in the generated SVG, so I can't really show it in
> > > > > > the log or documentation. But I added simple example with -e option.
> 
> > > > > > >   -e::
> > > > > > >   --emphasize=<duration_nsecs|task_name>::
> > > > > > Thanks, added.
> 
> > > > > I also wonder how to allocate single letter options here... can we live
> > > > > with just --emphasize for now? Wouldn't at some point we maybe want to
> > > > > use -e in 'perf timechart' to pick some specific event, and then, to
> > > > > make it consistent with the other tools, -e would then be used?
> 
> > > > I wanted to raise a similar argument too - so if we don't have to do 
> > > > -e then maybe '--grep' would be the better option name?
> 
> > > > If it becomes popular then the pattern matching can be improved, 
> > > > without having to change the option name and such.
> 
> > > Humm, 'grep' is a filter, i.e. something that removes parts of the 
> > > data being perused, while this case it will not filter anything, it 
> > > will just make something that matches some search criteria to stand 
> > > out from the rest, that is still there, so perhaps --emphasize is Ok 
> > > albeit kinda long...
> > 
> > So I frequently use grep with -C 1000 --color=always to also show the 
> > context. But --grep-context sounds too long.
> 
> Just tried it here, and on fedora 18 one doesn't even needs the
> --color=always [...]

That's only needed if you look at it through 'less' and such. (at 
which point 'less -R' is your friend.)

> > > Do we have any other command line tool that has a long standing 
> > > semantics of "highlighting" or "emphasizing" parts of a data 
> > > stream?
> > 
> > Yeah, grep's -C, -A, -B options. (--context, --context-after, 
> > --context-before), combined with the --color option to highlight.
> 
> I don't feel like there is a direct mapping of what he wants to 
> achieve to reusing the 'grep' keyword, at least it didn't sound 
> natural at first sight to me. :-)

Yeah, agreed.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5 v2] perf timechart: add emphasize option
  2013-12-17 14:15                 ` Arnaldo Carvalho de Melo
  2013-12-17 14:26                   ` Ingo Molnar
@ 2013-12-17 15:03                   ` David Ahern
  2013-12-17 15:53                   ` Stanislav Fomichev
  2 siblings, 0 replies; 23+ messages in thread
From: David Ahern @ 2013-12-17 15:03 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ingo Molnar
  Cc: Stanislav Fomichev, linux-kernel, a.p.zijlstra, paulus, mingo,
	namhyung, artagnon, jolsa

On 12/17/13, 7:15 AM, Arnaldo Carvalho de Melo wrote:
> Just tried it here, and on fedora 18 one doesn't even needs the
> --color=always,

Default aliases:

$ alias
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5 v2] perf timechart: add emphasize option
  2013-12-17 14:15                 ` Arnaldo Carvalho de Melo
  2013-12-17 14:26                   ` Ingo Molnar
  2013-12-17 15:03                   ` David Ahern
@ 2013-12-17 15:53                   ` Stanislav Fomichev
  2013-12-18 10:33                     ` [tip:perf/core] perf timechart: Add --highlight option tip-bot for Stanislav Fomichev
  2 siblings, 1 reply; 23+ messages in thread
From: Stanislav Fomichev @ 2013-12-17 15:53 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, linux-kernel, a.p.zijlstra, paulus, mingo, namhyung,
	artagnon, jolsa

> > Maybe --highlight ?
> 
> That is ok for me, I think it is better than --emphasize
I actually didn't use highlight because its short counterpart (-h) is
help :-)
New patch with --highlight instead of --emphasize and -e below.

---
This option highlights tasks (using different color) that run more than given
duration or tasks with given name.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
---
 tools/perf/Documentation/perf-timechart.txt | 13 +++++++++++++
 tools/perf/builtin-timechart.c              | 21 ++++++++++++++++++++-
 tools/perf/util/svghelper.c                 | 23 ++++++++++++++++++++---
 tools/perf/util/svghelper.h                 |  4 +++-
 4 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
index 367c1be0551c..faf713d4d0c5 100644
--- a/tools/perf/Documentation/perf-timechart.txt
+++ b/tools/perf/Documentation/perf-timechart.txt
@@ -56,12 +56,25 @@ $ perf timechart
 
   Written 10.2 seconds of trace to output.svg.
 
+Record system-wide timechart:
+
+  $ perf timechart record
+
+  then generate timechart and highlight 'gcc' tasks:
+
+  $ perf timechart --highlight gcc
+
 -n::
 --proc-num::
         Print task info for at least given number of tasks.
 -t::
 --topology::
         Sort CPUs according to topology.
+--highlight=<duration_nsecs|task_name>::
+	Highlight tasks (using different color) that run more than given
+	duration or tasks with given name. If number is given it's interpreted
+	as number of nanoseconds. If non-numeric string is given it's
+	interpreted as task name.
 
 RECORD OPTIONS
 --------------
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 8bde57c5c908..20d4212fa337 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -841,7 +841,6 @@ static void draw_cpu_usage(struct timechart *tchart)
 						    sample->start_time,
 						    sample->end_time,
 						    p->pid,
-						    "sample",
 						    c->comm,
 						    sample->backtrace);
 				}
@@ -1252,6 +1251,23 @@ parse_process(const struct option *opt __maybe_unused, const char *arg,
 	return 0;
 }
 
+static int
+parse_highlight(const struct option *opt __maybe_unused, const char *arg,
+		int __maybe_unused unset)
+{
+	unsigned long duration = strtoul(arg, NULL, 0);
+
+	if (svg_highlight || svg_highlight_name)
+		return -1;
+
+	if (duration)
+		svg_highlight = duration;
+	else
+		svg_highlight_name = strdup(arg);
+
+	return 0;
+}
+
 int cmd_timechart(int argc, const char **argv,
 		  const char *prefix __maybe_unused)
 {
@@ -1270,6 +1286,9 @@ int cmd_timechart(int argc, const char **argv,
 	OPT_STRING('i', "input", &input_name, "file", "input file name"),
 	OPT_STRING('o', "output", &output_name, "file", "output file name"),
 	OPT_INTEGER('w', "width", &svg_page_width, "page width"),
+	OPT_CALLBACK(0, "highlight", NULL, "duration or task name",
+		      "highlight tasks. Pass duration in ns or process name.",
+		       parse_highlight),
 	OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"),
 	OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only,
 		    "output processes data only"),
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 9468136735ca..56a84f2cc46d 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -31,6 +31,8 @@ static u64 turbo_frequency, max_freq;
 #define SLOT_HEIGHT 25.0
 
 int svg_page_width = 1000;
+u64 svg_highlight;
+const char *svg_highlight_name;
 
 #define MIN_TEXT_SIZE 0.01
 
@@ -112,6 +114,7 @@ void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end)
 	fprintf(svgfile, "      rect.process  { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:1;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.process2 { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.sample   { fill:rgb(  0,  0,255); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
+	fprintf(svgfile, "      rect.sample_hi{ fill:rgb(255,128,  0); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.blocked  { fill:rgb(255,  0,  0); fill-opacity:0.5; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.waiting  { fill:rgb(224,214,  0); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.WAITING  { fill:rgb(255,214, 48); fill-opacity:0.6; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
@@ -155,17 +158,24 @@ void svg_blocked(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 void svg_running(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 {
 	double text_size;
+	const char *type;
+
 	if (!svgfile)
 		return;
 
+	if (svg_highlight && end - start > svg_highlight)
+		type = "sample_hi";
+	else
+		type = "sample";
 	fprintf(svgfile, "<g>\n");
 
 	fprintf(svgfile, "<title>#%d running %s</title>\n",
 		cpu, time_to_string(end - start));
 	if (backtrace)
 		fprintf(svgfile, "<desc>Switched because:\n%s</desc>\n", backtrace);
-	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"sample\"/>\n",
-		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT);
+	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"%s\"/>\n",
+		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT,
+		type);
 
 	text_size = (time2pixels(end)-time2pixels(start));
 	if (cpu > 9)
@@ -293,13 +303,20 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace)
+void svg_process(int cpu, u64 start, u64 end, int pid, const char *name, const char *backtrace)
 {
 	double width;
+	const char *type;
 
 	if (!svgfile)
 		return;
 
+	if (svg_highlight && end - start >= svg_highlight)
+		type = "sample_hi";
+	else if (svg_highlight_name && strstr(name, svg_highlight_name))
+		type = "sample_hi";
+	else
+		type = "sample";
 
 	fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu));
 	fprintf(svgfile, "<title>%d %s running %s</title>\n", pid, name, time_to_string(end - start));
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index 1df4fb6c3a4a..f7b4d6e699ea 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -11,7 +11,7 @@ extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *back
 extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
 
 
-extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace);
+extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *name, const char *backtrace);
 extern void svg_cstate(int cpu, u64 start, u64 end, int type);
 extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
 
@@ -27,5 +27,7 @@ extern int svg_build_topology_map(char *sib_core, int sib_core_nr,
 				  char *sib_thr, int sib_thr_nr);
 
 extern int svg_page_width;
+extern u64 svg_highlight;
+extern const char *svg_highlight_name;
 
 #endif /* __PERF_SVGHELPER_H */
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [tip:perf/core] perf timechart: Add backtrace support to CPU info
  2013-12-02 14:37 ` [PATCH 1/5] perf timechart: add backtrace support to CPU info Stanislav Fomichev
@ 2013-12-18 10:30   ` tip-bot for Stanislav Fomichev
  0 siblings, 0 replies; 23+ messages in thread
From: tip-bot for Stanislav Fomichev @ 2013-12-18 10:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, mingo, hpa, mingo, a.p.zijlstra,
	namhyung, jolsa, stfomichev, artagnon, tglx

Commit-ID:  8b6dcca017aa53fe13066411a653b5997c158a2c
Gitweb:     http://git.kernel.org/tip/8b6dcca017aa53fe13066411a653b5997c158a2c
Author:     Stanislav Fomichev <stfomichev@yandex-team.ru>
AuthorDate: Mon, 2 Dec 2013 18:37:33 +0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 16 Dec 2013 16:33:14 -0300

perf timechart: Add backtrace support to CPU info

Add backtrace info to the CPU usage timechart.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>
Link: http://lkml.kernel.org/r/1385995056-20158-2-git-send-email-stfomichev@yandex-team.ru
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-timechart.c | 10 ++++++++--
 tools/perf/util/svghelper.c    |  4 +++-
 tools/perf/util/svghelper.h    |  2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 0bda620..d955095 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -837,8 +837,14 @@ static void draw_cpu_usage(struct timechart *tchart)
 		while (c) {
 			sample = c->samples;
 			while (sample) {
-				if (sample->type == TYPE_RUNNING)
-					svg_process(sample->cpu, sample->start_time, sample->end_time, "sample", c->comm);
+				if (sample->type == TYPE_RUNNING) {
+					svg_process(sample->cpu,
+						    sample->start_time,
+						    sample->end_time,
+						    "sample",
+						    c->comm,
+						    sample->backtrace);
+				}
 
 				sample = sample->next;
 			}
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 8b79d3a..740f032 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -285,7 +285,7 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name)
+void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name, const char *backtrace)
 {
 	double width;
 
@@ -295,6 +295,8 @@ void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name
 
 	fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu));
 	fprintf(svgfile, "<title>%s %s</title>\n", name, time_to_string(end - start));
+	if (backtrace)
+		fprintf(svgfile, "<desc>Switched because:\n%s</desc>\n", backtrace);
 	fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n",
 		time2pixels(end)-time2pixels(start), SLOT_MULT+SLOT_HEIGHT, type);
 	width = time2pixels(end)-time2pixels(start);
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index fad79ce..7db6ae9 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -11,7 +11,7 @@ extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *back
 extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
 
 
-extern void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name);
+extern void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name, const char *backtrace);
 extern void svg_cstate(int cpu, u64 start, u64 end, int type);
 extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
 

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [tip:perf/core] perf timechart: Print pid along the name
  2013-12-02 14:37 ` [PATCH 2/5] perf timechart: print pid along the name Stanislav Fomichev
@ 2013-12-18 10:30   ` tip-bot for Stanislav Fomichev
  0 siblings, 0 replies; 23+ messages in thread
From: tip-bot for Stanislav Fomichev @ 2013-12-18 10:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, mingo, hpa, mingo, a.p.zijlstra,
	namhyung, jolsa, stfomichev, artagnon, tglx

Commit-ID:  de996228dedc74d9e72b749bbc8225f5e2bf19d8
Gitweb:     http://git.kernel.org/tip/de996228dedc74d9e72b749bbc8225f5e2bf19d8
Author:     Stanislav Fomichev <stfomichev@yandex-team.ru>
AuthorDate: Mon, 2 Dec 2013 18:37:34 +0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 16 Dec 2013 16:33:57 -0300

perf timechart: Print pid along the name

Add PID to the figures of CPU usage timechart.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>
Link: http://lkml.kernel.org/r/1385995056-20158-3-git-send-email-stfomichev@yandex-team.ru
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-timechart.c | 1 +
 tools/perf/util/svghelper.c    | 4 ++--
 tools/perf/util/svghelper.h    | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index d955095..99fe363 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -841,6 +841,7 @@ static void draw_cpu_usage(struct timechart *tchart)
 					svg_process(sample->cpu,
 						    sample->start_time,
 						    sample->end_time,
+						    p->pid,
 						    "sample",
 						    c->comm,
 						    sample->backtrace);
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 740f032..927851d 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -285,7 +285,7 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name, const char *backtrace)
+void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace)
 {
 	double width;
 
@@ -294,7 +294,7 @@ void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name
 
 
 	fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu));
-	fprintf(svgfile, "<title>%s %s</title>\n", name, time_to_string(end - start));
+	fprintf(svgfile, "<title>%d %s running %s</title>\n", pid, name, time_to_string(end - start));
 	if (backtrace)
 		fprintf(svgfile, "<desc>Switched because:\n%s</desc>\n", backtrace);
 	fprintf(svgfile, "<rect x=\"0\" width=\"%4.8f\" y=\"0\" height=\"%4.1f\" class=\"%s\"/>\n",
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index 7db6ae9..8b77ca6 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -11,7 +11,7 @@ extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *back
 extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
 
 
-extern void svg_process(int cpu, u64 start, u64 end, const char *type, const char *name, const char *backtrace);
+extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace);
 extern void svg_cstate(int cpu, u64 start, u64 end, int type);
 extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
 

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [tip:perf/core] perf timechart: Get number of CPUs from perf header
  2013-12-02 14:37 ` [PATCH 3/5] perf timechart: get number of CPUs from perf header Stanislav Fomichev
@ 2013-12-18 10:31   ` tip-bot for Stanislav Fomichev
  0 siblings, 0 replies; 23+ messages in thread
From: tip-bot for Stanislav Fomichev @ 2013-12-18 10:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, mingo, hpa, mingo, a.p.zijlstra,
	namhyung, jolsa, stfomichev, artagnon, tglx

Commit-ID:  58b9a18ecd251cbd6e666ad792023ab77c7d100e
Gitweb:     http://git.kernel.org/tip/58b9a18ecd251cbd6e666ad792023ab77c7d100e
Author:     Stanislav Fomichev <stfomichev@yandex-team.ru>
AuthorDate: Mon, 2 Dec 2013 18:37:35 +0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 16 Dec 2013 16:34:27 -0300

perf timechart: Get number of CPUs from perf header

Print all CPUs, even if there were no events (use perf header to get
number of CPUs).

This is required to support topology in the next patch.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>
Link: http://lkml.kernel.org/r/1385995056-20158-4-git-send-email-stfomichev@yandex-team.ru
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-timechart.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 99fe363..db9c4c1 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -531,12 +531,10 @@ static int process_sample_event(struct perf_tool *tool,
 			tchart->last_time = sample->time;
 	}
 
-	if (sample->cpu > tchart->numcpus)
-		tchart->numcpus = sample->cpu;
-
 	if (evsel->handler != NULL) {
 		tracepoint_handler f = evsel->handler;
-		return f(tchart, evsel, sample, cat_backtrace(event, sample, machine));
+		return f(tchart, evsel, sample,
+			 cat_backtrace(event, sample, machine));
 	}
 
 	return 0;
@@ -1038,8 +1036,6 @@ static void write_svg_file(struct timechart *tchart, const char *filename)
 	int count;
 	int thresh = TIME_THRESH;
 
-	tchart->numcpus++;
-
 	if (tchart->power_only)
 		tchart->proc_num = 0;
 
@@ -1069,6 +1065,25 @@ static void write_svg_file(struct timechart *tchart, const char *filename)
 	svg_close();
 }
 
+static int process_header(struct perf_file_section *section __maybe_unused,
+			  struct perf_header *ph,
+			  int feat,
+			  int fd __maybe_unused,
+			  void *data)
+{
+	struct timechart *tchart = data;
+
+	switch (feat) {
+	case HEADER_NRCPUS:
+		tchart->numcpus = ph->env.nr_cpus_avail;
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
 static int __cmd_timechart(struct timechart *tchart, const char *output_name)
 {
 	const struct perf_evsel_str_handler power_tracepoints[] = {
@@ -1094,6 +1109,11 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
 	if (session == NULL)
 		return -ENOMEM;
 
+	(void)perf_header__process_sections(&session->header,
+					    perf_data_file__fd(session->file),
+					    tchart,
+					    process_header);
+
 	if (!perf_session__has_traces(session, "timechart record"))
 		goto out_delete;
 

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [tip:perf/core] perf timechart: Add support for topology
  2013-12-02 14:37 ` [PATCH 4/5] perf timechart: add support for topology Stanislav Fomichev
@ 2013-12-18 10:31   ` tip-bot for Stanislav Fomichev
  0 siblings, 0 replies; 23+ messages in thread
From: tip-bot for Stanislav Fomichev @ 2013-12-18 10:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, mingo, hpa, mingo, a.p.zijlstra,
	namhyung, jolsa, stfomichev, artagnon, tglx

Commit-ID:  c507999790438cde78b5618fa64daefd697035af
Gitweb:     http://git.kernel.org/tip/c507999790438cde78b5618fa64daefd697035af
Author:     Stanislav Fomichev <stfomichev@yandex-team.ru>
AuthorDate: Mon, 2 Dec 2013 18:37:36 +0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 16 Dec 2013 16:34:53 -0300

perf timechart: Add support for topology

Add -t switch to sort CPUs topologically.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>
Link: http://lkml.kernel.org/r/1385995056-20158-5-git-send-email-stfomichev@yandex-team.ru
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-timechart.txt |   3 +
 tools/perf/builtin-timechart.c              |  17 +++-
 tools/perf/util/svghelper.c                 | 132 +++++++++++++++++++++++++++-
 tools/perf/util/svghelper.h                 |   2 +
 4 files changed, 151 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
index 271dd4e..367c1be 100644
--- a/tools/perf/Documentation/perf-timechart.txt
+++ b/tools/perf/Documentation/perf-timechart.txt
@@ -59,6 +59,9 @@ $ perf timechart
 -n::
 --proc-num::
         Print task info for at least given number of tasks.
+-t::
+--topology::
+        Sort CPUs according to topology.
 
 RECORD OPTIONS
 --------------
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index db9c4c1..8bde57c 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -58,7 +58,8 @@ struct timechart {
 				first_time, last_time;
 	bool			power_only,
 				tasks_only,
-				with_backtrace;
+				with_backtrace,
+				topology;
 };
 
 struct per_pidcomm;
@@ -1077,6 +1078,18 @@ static int process_header(struct perf_file_section *section __maybe_unused,
 	case HEADER_NRCPUS:
 		tchart->numcpus = ph->env.nr_cpus_avail;
 		break;
+
+	case HEADER_CPU_TOPOLOGY:
+		if (!tchart->topology)
+			break;
+
+		if (svg_build_topology_map(ph->env.sibling_cores,
+					   ph->env.nr_sibling_cores,
+					   ph->env.sibling_threads,
+					   ph->env.nr_sibling_threads))
+			fprintf(stderr, "problem building topology\n");
+		break;
+
 	default:
 		break;
 	}
@@ -1267,6 +1280,8 @@ int cmd_timechart(int argc, const char **argv,
 		    "Look for files with symbols relative to this directory"),
 	OPT_INTEGER('n', "proc-num", &tchart.proc_num,
 		    "min. number of tasks to print"),
+	OPT_BOOLEAN('t', "topology", &tchart.topology,
+		    "sort CPUs according to topology"),
 	OPT_END()
 	};
 	const char * const timechart_usage[] = {
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 927851d..9468136 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -17,8 +17,11 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#include <linux/bitops.h>
 
+#include "perf.h"
 #include "svghelper.h"
+#include "cpumap.h"
 
 static u64 first_time, last_time;
 static u64 turbo_frequency, max_freq;
@@ -39,9 +42,14 @@ static double cpu2slot(int cpu)
 	return 2 * cpu + 1;
 }
 
+static int *topology_map;
+
 static double cpu2y(int cpu)
 {
-	return cpu2slot(cpu) * SLOT_MULT;
+	if (topology_map)
+		return cpu2slot(topology_map[cpu]) * SLOT_MULT;
+	else
+		return cpu2slot(cpu) * SLOT_MULT;
 }
 
 static double time2pixels(u64 __time)
@@ -275,7 +283,7 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
 		time2pixels(last_time)-time2pixels(first_time),
 		cpu2y(cpu), SLOT_MULT+SLOT_HEIGHT);
 
-	sprintf(cpu_string, "CPU %i", (int)cpu+1);
+	sprintf(cpu_string, "CPU %i", (int)cpu);
 	fprintf(svgfile, "<text x=\"%4.8f\" y=\"%4.8f\">%s</text>\n",
 		10+time2pixels(first_time), cpu2y(cpu) + SLOT_HEIGHT/2, cpu_string);
 
@@ -568,3 +576,123 @@ void svg_close(void)
 		svgfile = NULL;
 	}
 }
+
+#define cpumask_bits(maskp) ((maskp)->bits)
+typedef struct { DECLARE_BITMAP(bits, MAX_NR_CPUS); } cpumask_t;
+
+struct topology {
+	cpumask_t *sib_core;
+	int sib_core_nr;
+	cpumask_t *sib_thr;
+	int sib_thr_nr;
+};
+
+static void scan_thread_topology(int *map, struct topology *t, int cpu, int *pos)
+{
+	int i;
+	int thr;
+
+	for (i = 0; i < t->sib_thr_nr; i++) {
+		if (!test_bit(cpu, cpumask_bits(&t->sib_thr[i])))
+			continue;
+
+		for_each_set_bit(thr,
+				 cpumask_bits(&t->sib_thr[i]),
+				 MAX_NR_CPUS)
+			if (map[thr] == -1)
+				map[thr] = (*pos)++;
+	}
+}
+
+static void scan_core_topology(int *map, struct topology *t)
+{
+	int pos = 0;
+	int i;
+	int cpu;
+
+	for (i = 0; i < t->sib_core_nr; i++)
+		for_each_set_bit(cpu,
+				 cpumask_bits(&t->sib_core[i]),
+				 MAX_NR_CPUS)
+			scan_thread_topology(map, t, cpu, &pos);
+}
+
+static int str_to_bitmap(char *s, cpumask_t *b)
+{
+	int i;
+	int ret = 0;
+	struct cpu_map *m;
+	int c;
+
+	m = cpu_map__new(s);
+	if (!m)
+		return -1;
+
+	for (i = 0; i < m->nr; i++) {
+		c = m->map[i];
+		if (c >= MAX_NR_CPUS) {
+			ret = -1;
+			break;
+		}
+
+		set_bit(c, cpumask_bits(b));
+	}
+
+	cpu_map__delete(m);
+
+	return ret;
+}
+
+int svg_build_topology_map(char *sib_core, int sib_core_nr,
+			   char *sib_thr, int sib_thr_nr)
+{
+	int i;
+	struct topology t;
+
+	t.sib_core_nr = sib_core_nr;
+	t.sib_thr_nr = sib_thr_nr;
+	t.sib_core = calloc(sib_core_nr, sizeof(cpumask_t));
+	t.sib_thr = calloc(sib_thr_nr, sizeof(cpumask_t));
+
+	if (!t.sib_core || !t.sib_thr) {
+		fprintf(stderr, "topology: no memory\n");
+		goto exit;
+	}
+
+	for (i = 0; i < sib_core_nr; i++) {
+		if (str_to_bitmap(sib_core, &t.sib_core[i])) {
+			fprintf(stderr, "topology: can't parse siblings map\n");
+			goto exit;
+		}
+
+		sib_core += strlen(sib_core) + 1;
+	}
+
+	for (i = 0; i < sib_thr_nr; i++) {
+		if (str_to_bitmap(sib_thr, &t.sib_thr[i])) {
+			fprintf(stderr, "topology: can't parse siblings map\n");
+			goto exit;
+		}
+
+		sib_thr += strlen(sib_thr) + 1;
+	}
+
+	topology_map = malloc(sizeof(int) * MAX_NR_CPUS);
+	if (!topology_map) {
+		fprintf(stderr, "topology: no memory\n");
+		goto exit;
+	}
+
+	for (i = 0; i < MAX_NR_CPUS; i++)
+		topology_map[i] = -1;
+
+	scan_core_topology(topology_map, &t);
+
+	return 0;
+
+exit:
+	free(t.sib_core);
+	free(t.sib_thr);
+
+	return -1;
+}
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index 8b77ca6..1df4fb6 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -23,6 +23,8 @@ extern void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, cha
 extern void svg_interrupt(u64 start, int row, const char *backtrace);
 extern void svg_text(int Yslot, u64 start, const char *text);
 extern void svg_close(void);
+extern int svg_build_topology_map(char *sib_core, int sib_core_nr,
+				  char *sib_thr, int sib_thr_nr);
 
 extern int svg_page_width;
 

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [tip:perf/core] perf timechart: Add --highlight option
  2013-12-17 15:53                   ` Stanislav Fomichev
@ 2013-12-18 10:33                     ` tip-bot for Stanislav Fomichev
  0 siblings, 0 replies; 23+ messages in thread
From: tip-bot for Stanislav Fomichev @ 2013-12-18 10:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, namhyung,
	jolsa, stfomichev, artagnon, tglx

Commit-ID:  e57a2dffbc7e28cef5f4659b98a9d5595010ab4d
Gitweb:     http://git.kernel.org/tip/e57a2dffbc7e28cef5f4659b98a9d5595010ab4d
Author:     Stanislav Fomichev <stfomichev@yandex-team.ru>
AuthorDate: Tue, 17 Dec 2013 19:53:49 +0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 17 Dec 2013 16:33:55 -0300

perf timechart: Add --highlight option

This option highlights tasks (using different color) that run more than
given duration or tasks with given name.

Signed-off-by: Stanislav Fomichev <stfomichev@yandex-team.ru>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>
Link: http://lkml.kernel.org/r/20131217155349.GA13021@stfomichev-desktop
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-timechart.txt | 13 +++++++++++++
 tools/perf/builtin-timechart.c              | 21 ++++++++++++++++++++-
 tools/perf/util/svghelper.c                 | 23 ++++++++++++++++++++---
 tools/perf/util/svghelper.h                 |  4 +++-
 4 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
index 367c1be..bc5990c 100644
--- a/tools/perf/Documentation/perf-timechart.txt
+++ b/tools/perf/Documentation/perf-timechart.txt
@@ -56,12 +56,25 @@ $ perf timechart
 
   Written 10.2 seconds of trace to output.svg.
 
+Record system-wide timechart:
+
+  $ perf timechart record
+
+  then generate timechart and highlight 'gcc' tasks:
+
+  $ perf timechart --highlight gcc
+
 -n::
 --proc-num::
         Print task info for at least given number of tasks.
 -t::
 --topology::
         Sort CPUs according to topology.
+--highlight=<duration_nsecs|task_name>::
+	Highlight tasks (using different color) that run more than given
+	duration or tasks with given name. If number is given it's interpreted
+	as number of nanoseconds. If non-numeric string is given it's
+	interpreted as task name.
 
 RECORD OPTIONS
 --------------
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 8bde57c..20d4212 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -841,7 +841,6 @@ static void draw_cpu_usage(struct timechart *tchart)
 						    sample->start_time,
 						    sample->end_time,
 						    p->pid,
-						    "sample",
 						    c->comm,
 						    sample->backtrace);
 				}
@@ -1252,6 +1251,23 @@ parse_process(const struct option *opt __maybe_unused, const char *arg,
 	return 0;
 }
 
+static int
+parse_highlight(const struct option *opt __maybe_unused, const char *arg,
+		int __maybe_unused unset)
+{
+	unsigned long duration = strtoul(arg, NULL, 0);
+
+	if (svg_highlight || svg_highlight_name)
+		return -1;
+
+	if (duration)
+		svg_highlight = duration;
+	else
+		svg_highlight_name = strdup(arg);
+
+	return 0;
+}
+
 int cmd_timechart(int argc, const char **argv,
 		  const char *prefix __maybe_unused)
 {
@@ -1270,6 +1286,9 @@ int cmd_timechart(int argc, const char **argv,
 	OPT_STRING('i', "input", &input_name, "file", "input file name"),
 	OPT_STRING('o', "output", &output_name, "file", "output file name"),
 	OPT_INTEGER('w', "width", &svg_page_width, "page width"),
+	OPT_CALLBACK(0, "highlight", NULL, "duration or task name",
+		      "highlight tasks. Pass duration in ns or process name.",
+		       parse_highlight),
 	OPT_BOOLEAN('P', "power-only", &tchart.power_only, "output power data only"),
 	OPT_BOOLEAN('T', "tasks-only", &tchart.tasks_only,
 		    "output processes data only"),
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index 9468136..56a84f2 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -31,6 +31,8 @@ static u64 turbo_frequency, max_freq;
 #define SLOT_HEIGHT 25.0
 
 int svg_page_width = 1000;
+u64 svg_highlight;
+const char *svg_highlight_name;
 
 #define MIN_TEXT_SIZE 0.01
 
@@ -112,6 +114,7 @@ void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end)
 	fprintf(svgfile, "      rect.process  { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:1;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.process2 { fill:rgb(180,180,180); fill-opacity:0.9; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.sample   { fill:rgb(  0,  0,255); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
+	fprintf(svgfile, "      rect.sample_hi{ fill:rgb(255,128,  0); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.blocked  { fill:rgb(255,  0,  0); fill-opacity:0.5; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.waiting  { fill:rgb(224,214,  0); fill-opacity:0.8; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
 	fprintf(svgfile, "      rect.WAITING  { fill:rgb(255,214, 48); fill-opacity:0.6; stroke-width:0;   stroke:rgb(  0,  0,  0); } \n");
@@ -155,17 +158,24 @@ void svg_blocked(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 void svg_running(int Yslot, int cpu, u64 start, u64 end, const char *backtrace)
 {
 	double text_size;
+	const char *type;
+
 	if (!svgfile)
 		return;
 
+	if (svg_highlight && end - start > svg_highlight)
+		type = "sample_hi";
+	else
+		type = "sample";
 	fprintf(svgfile, "<g>\n");
 
 	fprintf(svgfile, "<title>#%d running %s</title>\n",
 		cpu, time_to_string(end - start));
 	if (backtrace)
 		fprintf(svgfile, "<desc>Switched because:\n%s</desc>\n", backtrace);
-	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"sample\"/>\n",
-		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT);
+	fprintf(svgfile, "<rect x=\"%4.8f\" width=\"%4.8f\" y=\"%4.1f\" height=\"%4.1f\" class=\"%s\"/>\n",
+		time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT,
+		type);
 
 	text_size = (time2pixels(end)-time2pixels(start));
 	if (cpu > 9)
@@ -293,13 +303,20 @@ void svg_cpu_box(int cpu, u64 __max_freq, u64 __turbo_freq)
 	fprintf(svgfile, "</g>\n");
 }
 
-void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace)
+void svg_process(int cpu, u64 start, u64 end, int pid, const char *name, const char *backtrace)
 {
 	double width;
+	const char *type;
 
 	if (!svgfile)
 		return;
 
+	if (svg_highlight && end - start >= svg_highlight)
+		type = "sample_hi";
+	else if (svg_highlight_name && strstr(name, svg_highlight_name))
+		type = "sample_hi";
+	else
+		type = "sample";
 
 	fprintf(svgfile, "<g transform=\"translate(%4.8f,%4.8f)\">\n", time2pixels(start), cpu2y(cpu));
 	fprintf(svgfile, "<title>%d %s running %s</title>\n", pid, name, time_to_string(end - start));
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index 1df4fb6..f7b4d6e 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -11,7 +11,7 @@ extern void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *back
 extern void svg_cpu_box(int cpu, u64 max_frequency, u64 turbo_frequency);
 
 
-extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *type, const char *name, const char *backtrace);
+extern void svg_process(int cpu, u64 start, u64 end, int pid, const char *name, const char *backtrace);
 extern void svg_cstate(int cpu, u64 start, u64 end, int type);
 extern void svg_pstate(int cpu, u64 start, u64 end, u64 freq);
 
@@ -27,5 +27,7 @@ extern int svg_build_topology_map(char *sib_core, int sib_core_nr,
 				  char *sib_thr, int sib_thr_nr);
 
 extern int svg_page_width;
+extern u64 svg_highlight;
+extern const char *svg_highlight_name;
 
 #endif /* __PERF_SVGHELPER_H */

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2013-12-18 10:38 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-02 14:37 [PATCH 0/5] perf timechart improvements part 2 Stanislav Fomichev
2013-12-02 14:37 ` [PATCH 1/5] perf timechart: add backtrace support to CPU info Stanislav Fomichev
2013-12-18 10:30   ` [tip:perf/core] perf timechart: Add " tip-bot for Stanislav Fomichev
2013-12-02 14:37 ` [PATCH 2/5] perf timechart: print pid along the name Stanislav Fomichev
2013-12-18 10:30   ` [tip:perf/core] perf timechart: Print " tip-bot for Stanislav Fomichev
2013-12-02 14:37 ` [PATCH 3/5] perf timechart: get number of CPUs from perf header Stanislav Fomichev
2013-12-18 10:31   ` [tip:perf/core] perf timechart: Get " tip-bot for Stanislav Fomichev
2013-12-02 14:37 ` [PATCH 4/5] perf timechart: add support for topology Stanislav Fomichev
2013-12-18 10:31   ` [tip:perf/core] perf timechart: Add " tip-bot for Stanislav Fomichev
2013-12-16 19:38 ` [PATCH 0/5] perf timechart improvements part 2 Arnaldo Carvalho de Melo
2013-12-17  9:38   ` [PATCH 5/5] perf timechart: add emphasize option Stanislav Fomichev
2013-12-17 11:23     ` Ingo Molnar
2013-12-17 12:15       ` [PATCH 5/5 v2] " Stanislav Fomichev
2013-12-17 13:12         ` Ingo Molnar
2013-12-17 13:38         ` Arnaldo Carvalho de Melo
2013-12-17 13:41           ` Ingo Molnar
2013-12-17 13:59             ` Arnaldo Carvalho de Melo
2013-12-17 14:06               ` Ingo Molnar
2013-12-17 14:15                 ` Arnaldo Carvalho de Melo
2013-12-17 14:26                   ` Ingo Molnar
2013-12-17 15:03                   ` David Ahern
2013-12-17 15:53                   ` Stanislav Fomichev
2013-12-18 10:33                     ` [tip:perf/core] perf timechart: Add --highlight option tip-bot for Stanislav Fomichev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).