Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1278234 > unrolled thread

[PATCH 3/3] perf script: Align event name properly

Started byJiri Olsa <jolsa@kernel.org>
First post2015-11-26 15:00 +0100
Last post2015-11-26 15:40 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3/3] perf script: Align event name properly Jiri Olsa <jolsa@kernel.org> - 2015-11-26 15:00 +0100
    Re: [PATCH 3/3] perf script: Align event name properly David Ahern <dsahern@gmail.com> - 2015-11-26 15:30 +0100
      Re: [PATCH 3/3] perf script: Align event name properly David Ahern <dsahern@gmail.com> - 2015-11-26 15:40 +0100
      Re: [PATCH 3/3] perf script: Align event name properly Jiri Olsa <jolsa@redhat.com> - 2015-11-26 15:40 +0100

#1278234 — [PATCH 3/3] perf script: Align event name properly

FromJiri Olsa <jolsa@kernel.org>
Date2015-11-26 15:00 +0100
Subject[PATCH 3/3] perf script: Align event name properly
Message-ID<qz5fB-5UD-11@gated-at.bofh.it>
Adding code to align event names, so we get aligned output
in case of multiple events with different names.

Before:
  $ perf script
  :13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010
  :13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P:     7f5a5f719f00
  :13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P:     7f5a5f719f00
  :13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810
  :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
  :13757 13757 163918.155264: cpu/mem-snp-hitm/P:           601080
  ...

After:
  $ perf script
  :13757 13757 163918.228831:       cpu/mem-snp-none/P: ffffffff81a841c0
  :13757 13757 163918.228834: cpu/mem-loads,ldlat=30/P:     7f5a5f719f08
  :13757 13757 163918.228837: cpu/mem-loads,ldlat=30/P:     7f5a5f719f08
  :13758 13758 163918.228837:       cpu/mem-snp-none/P: ffff88085f4ad800
  :13758 13758 163918.154093:         cpu/mem-stores/P: ffff88085bb53f28
  :13757 13757 163918.155264:       cpu/mem-snp-hitm/P:           601080
  ...

Link: http://lkml.kernel.org/n/tip-hsrwmiogt9menjsg7uaxqvq2@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-script.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 3c3f8d0e3064..10a96da0ea56 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -594,9 +594,24 @@ struct perf_script {
 	bool			show_task_events;
 	bool			show_mmap_events;
 	bool			show_switch_events;
+	int			name_width;
 };
 
-static void process_event(struct perf_script *script __maybe_unused, union perf_event *event,
+static int perf_evlist__max_name_len(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel;
+	int max = 0;
+
+	evlist__for_each(evlist, evsel) {
+		int len = strlen(perf_evsel__name(evsel));
+
+		max = MAX(len, max);
+	}
+
+	return max;
+}
+
+static void process_event(struct perf_script *script, union perf_event *event,
 			  struct perf_sample *sample, struct perf_evsel *evsel,
 			  struct addr_location *al)
 {
@@ -613,7 +628,12 @@ static void process_event(struct perf_script *script __maybe_unused, union perf_
 
 	if (PRINT_FIELD(EVNAME)) {
 		const char *evname = perf_evsel__name(evsel);
-		printf("%s: ", evname ? evname : "[unknown]");
+
+		if (!script->name_width)
+			script->name_width = perf_evlist__max_name_len(script->session->evlist);
+
+		printf("%*s: ", script->name_width,
+		       evname ? evname : "[unknown]");
 	}
 
 	if (print_flags)
-- 
2.4.3

--
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/

[toc] | [next] | [standalone]


#1278258

FromDavid Ahern <dsahern@gmail.com>
Date2015-11-26 15:30 +0100
Message-ID<qz5IB-6m2-9@gated-at.bofh.it>
In reply to#1278234
On 11/26/15 6:55 AM, Jiri Olsa wrote:
> Adding code to align event names, so we get aligned output
> in case of multiple events with different names.
>
> Before:
>    $ perf script
>    :13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010
>    :13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P:     7f5a5f719f00
>    :13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P:     7f5a5f719f00
>    :13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810
>    :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
>    :13757 13757 163918.155264: cpu/mem-snp-hitm/P:           601080
>    ...
>

What's up with the ":13757" for the process name?

Patches LGTM

Acked-by: David Ahern <dsahern@gmail.com>

--
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/

[toc] | [prev] | [next] | [standalone]


#1278263

FromDavid Ahern <dsahern@gmail.com>
Date2015-11-26 15:40 +0100
Message-ID<qz5Si-6pj-9@gated-at.bofh.it>
In reply to#1278258
On 11/26/15 7:30 AM, Jiri Olsa wrote:
> On Thu, Nov 26, 2015 at 07:25:17AM -0700, David Ahern wrote:
>> On 11/26/15 6:55 AM, Jiri Olsa wrote:
>>> Adding code to align event names, so we get aligned output
>>> in case of multiple events with different names.
>>>
>>> Before:
>>>    $ perf script
>>>    :13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010
>>>    :13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P:     7f5a5f719f00
>>>    :13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P:     7f5a5f719f00
>>>    :13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810
>>>    :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
>>>    :13757 13757 163918.155264: cpu/mem-snp-hitm/P:           601080
>>>    ...
>>>
>>
>> What's up with the ":13757" for the process name?
>
> hum, fallback if the name's not resolved? I'll check..

right, but I thought those were fixed. How is there a SAMPLE for a task 
without a COMM.

--
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/

[toc] | [prev] | [next] | [standalone]


#1278264

FromJiri Olsa <jolsa@redhat.com>
Date2015-11-26 15:40 +0100
Message-ID<qz5Si-6pj-11@gated-at.bofh.it>
In reply to#1278258
On Thu, Nov 26, 2015 at 07:25:17AM -0700, David Ahern wrote:
> On 11/26/15 6:55 AM, Jiri Olsa wrote:
> >Adding code to align event names, so we get aligned output
> >in case of multiple events with different names.
> >
> >Before:
> >   $ perf script
> >   :13757 13757 163918.230829: cpu/mem-snp-none/P: ffff88085f20d010
> >   :13757 13757 163918.230832: cpu/mem-loads,ldlat=30/P:     7f5a5f719f00
> >   :13757 13757 163918.230835: cpu/mem-loads,ldlat=30/P:     7f5a5f719f00
> >   :13758 13758 163918.230838: cpu/mem-snp-none/P: ffff88085f4ad810
> >   :13758 13758 163918.154093: cpu/mem-stores/P: ffff88085bb53f28
> >   :13757 13757 163918.155264: cpu/mem-snp-hitm/P:           601080
> >   ...
> >
> 
> What's up with the ":13757" for the process name?

hum, fallback if the name's not resolved? I'll check..

thanks,
jirka

> 
> Patches LGTM
> 
> Acked-by: David Ahern <dsahern@gmail.com>
> 
--
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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web