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


Groups > linux.kernel > #1373118 > unrolled thread

[PATCH 1/3] perf tools: Introduce trim function

Started byJiri Olsa <jolsa@kernel.org>
First post2016-04-07 09:20 +0200
Last post2016-04-13 09:20 +0200
Articles 7 — 5 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/3] perf tools: Introduce trim function Jiri Olsa <jolsa@kernel.org> - 2016-04-07 09:20 +0200
    [PATCH 3/3] perf script: Process event update events Jiri Olsa <jolsa@kernel.org> - 2016-04-07 09:20 +0200
      [tip:perf/core] perf script: Process event update events tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-04-13 09:20 +0200
    Re: [PATCH 1/3] perf tools: Introduce trim function Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-04-07 16:00 +0200
      Re: [PATCH 1/3] perf tools: Introduce trim function Jiri Olsa <jolsa@redhat.com> - 2016-04-07 16:10 +0200
        Re: [PATCH 1/3] perf tools: Introduce trim function Milian Wolff <milian.wolff@kdab.com> - 2016-04-07 18:00 +0200
    [tip:perf/core] perf tools: Introduce trim function tip-bot for Jiri Olsa <tipbot@zytor.com> - 2016-04-13 09:20 +0200

#1373118 — [PATCH 1/3] perf tools: Introduce trim function

FromJiri Olsa <jolsa@kernel.org>
Date2016-04-07 09:20 +0200
Subject[PATCH 1/3] perf tools: Introduce trim function
Message-ID<rlcop-hp-3@gated-at.bofh.it>
To be used in cases for both sides trim.

Link: http://lkml.kernel.org/n/tip-7fuk01zwjefo0aoqo42co0vy@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/browsers/hists.c | 3 +--
 tools/perf/ui/stdio/hist.c     | 3 +--
 tools/perf/util/util.h         | 5 +++++
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 2a83414159a6..e70df2e54d66 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1607,9 +1607,8 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
 
 			ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
 			dummy_hpp.buf[ret] = '\0';
-			rtrim(dummy_hpp.buf);
 
-			start = ltrim(dummy_hpp.buf);
+			start = trim(dummy_hpp.buf);
 			ret = strlen(start);
 
 			if (start != dummy_hpp.buf)
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 7aff5acf3265..560eb47d56f9 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -569,9 +569,8 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
 			first_col = false;
 
 			fmt->header(fmt, hpp, hists_to_evsel(hists));
-			rtrim(hpp->buf);
 
-			header_width += fprintf(fp, "%s", ltrim(hpp->buf));
+			header_width += fprintf(fp, "%s", trim(hpp->buf));
 		}
 	}
 
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 8298d607c738..3bf3de86d429 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -254,6 +254,11 @@ int hex2u64(const char *ptr, u64 *val);
 char *ltrim(char *s);
 char *rtrim(char *s);
 
+static inline char *trim(char *s)
+{
+	return ltrim(rtrim(s));
+}
+
 void dump_stack(void);
 void sighandler_dump_stack(int sig);
 
-- 
2.4.11

[toc] | [next] | [standalone]


#1373119 — [PATCH 3/3] perf script: Process event update events

FromJiri Olsa <jolsa@kernel.org>
Date2016-04-07 09:20 +0200
Subject[PATCH 3/3] perf script: Process event update events
Message-ID<rlcoq-hp-19@gated-at.bofh.it>
In reply to#1373118
Andreas reported following command produces no output:

  $ cat test.py
  #!/usr/bin/env python

  def stat__krava(cpu, thread, time, val, ena, run):
      print "event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" % \
            ("krava", cpu, thread, time, val, ena, run)
  $ perf stat -a -I 1000 -e cycles,"cpu/config=0x6530160,name=krava/" record | perf script -s test.py

The reason is that perf script does not process event update
events and will never get the event name update thus the
python callback is never called.

The fix is just to add already existing callback we use
in the perf stat report.

Reported-by: Andreas Hollmann <hollmann@in.tum.de>
Link: http://lkml.kernel.org/n/tip-5tyy9xeoiyg1nvy32tkjrlv1@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/builtin-script.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 3770c3dffe5e..59009aa7e2ca 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1961,6 +1961,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 			.exit		 = perf_event__process_exit,
 			.fork		 = perf_event__process_fork,
 			.attr		 = process_attr,
+			.event_update   = perf_event__process_event_update,
 			.tracing_data	 = perf_event__process_tracing_data,
 			.build_id	 = perf_event__process_build_id,
 			.id_index	 = perf_event__process_id_index,
-- 
2.4.11

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


#1377573 — [tip:perf/core] perf script: Process event update events

Fromtip-bot for Jiri Olsa <tipbot@zytor.com>
Date2016-04-13 09:20 +0200
Subject[tip:perf/core] perf script: Process event update events
Message-ID<rnnfI-5N9-25@gated-at.bofh.it>
In reply to#1373119
Commit-ID:  91daee306a51ca7b4d3ca7fdcf7472b0ed2c80c1
Gitweb:     http://git.kernel.org/tip/91daee306a51ca7b4d3ca7fdcf7472b0ed2c80c1
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 7 Apr 2016 09:11:13 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 8 Apr 2016 09:58:12 -0300

perf script: Process event update events

Andreas reported following command produces no output:

  # cat test.py
  #!/usr/bin/env python

  def stat__krava(cpu, thread, time, val, ena, run):
      print "event %s cpu %d, thread %d, time %d, val %d, ena %d, run %d" % \
            ("krava", cpu, thread, time, val, ena, run)
  # perf stat -a -I 1000 -e cycles,"cpu/config=0x6530160,name=krava/" record | perf script -s test.py
  ^C
  #

The reason is that 'perf script' does not process event update events and
will never get the event name update thus the python callback is never
called.

The fix is just to add already existing callback we use in 'perf stat
report'.

Committer note:

After the patch:

  # perf stat -a -I 1000 -e cycles,"cpu/config=0x6530160,name=krava/" record | perf script -s test.py
  event krava cpu -1, thread -1, time 1000239179, val 1789051, ena 4000690920, run 4000690920
  event krava cpu -1, thread -1, time 2000479061, val 2391338, ena 4000879596, run 4000879596
  event krava cpu -1, thread -1, time 3000740802, val 1939121, ena 4000977209, run 4000977209
  event krava cpu -1, thread -1, time 4001006730, val 2356115, ena 4001000489, run 4001000489
  ^C
  #

Reported-by: Andreas Hollmann <hollmann@in.tum.de>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460013073-18444-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-script.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 3770c3d..59009aa 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1961,6 +1961,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 			.exit		 = perf_event__process_exit,
 			.fork		 = perf_event__process_fork,
 			.attr		 = process_attr,
+			.event_update   = perf_event__process_event_update,
 			.tracing_data	 = perf_event__process_tracing_data,
 			.build_id	 = perf_event__process_build_id,
 			.id_index	 = perf_event__process_id_index,

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


#1373412

FromArnaldo Carvalho de Melo <acme@kernel.org>
Date2016-04-07 16:00 +0200
Message-ID<rliDw-4Fv-19@gated-at.bofh.it>
In reply to#1373118
Em Thu, Apr 07, 2016 at 09:11:11AM +0200, Jiri Olsa escreveu:
> To be used in cases for both sides trim.
> 
> Link: http://lkml.kernel.org/n/tip-7fuk01zwjefo0aoqo42co0vy@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Thanks, applied.

Will try Milian's 'perf trace' callchain patch soon, any updates on that one?

- Arnaldo

>  tools/perf/ui/browsers/hists.c | 3 +--
>  tools/perf/ui/stdio/hist.c     | 3 +--
>  tools/perf/util/util.h         | 5 +++++
>  3 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
> index 2a83414159a6..e70df2e54d66 100644
> --- a/tools/perf/ui/browsers/hists.c
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -1607,9 +1607,8 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
>  
>  			ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
>  			dummy_hpp.buf[ret] = '\0';
> -			rtrim(dummy_hpp.buf);
>  
> -			start = ltrim(dummy_hpp.buf);
> +			start = trim(dummy_hpp.buf);
>  			ret = strlen(start);
>  
>  			if (start != dummy_hpp.buf)
> diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
> index 7aff5acf3265..560eb47d56f9 100644
> --- a/tools/perf/ui/stdio/hist.c
> +++ b/tools/perf/ui/stdio/hist.c
> @@ -569,9 +569,8 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
>  			first_col = false;
>  
>  			fmt->header(fmt, hpp, hists_to_evsel(hists));
> -			rtrim(hpp->buf);
>  
> -			header_width += fprintf(fp, "%s", ltrim(hpp->buf));
> +			header_width += fprintf(fp, "%s", trim(hpp->buf));
>  		}
>  	}
>  
> diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
> index 8298d607c738..3bf3de86d429 100644
> --- a/tools/perf/util/util.h
> +++ b/tools/perf/util/util.h
> @@ -254,6 +254,11 @@ int hex2u64(const char *ptr, u64 *val);
>  char *ltrim(char *s);
>  char *rtrim(char *s);
>  
> +static inline char *trim(char *s)
> +{
> +	return ltrim(rtrim(s));
> +}
> +
>  void dump_stack(void);
>  void sighandler_dump_stack(int sig);
>  
> -- 
> 2.4.11

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


#1373415

FromJiri Olsa <jolsa@redhat.com>
Date2016-04-07 16:10 +0200
Message-ID<rliNb-52c-7@gated-at.bofh.it>
In reply to#1373412
On Thu, Apr 07, 2016 at 10:50:47AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Apr 07, 2016 at 09:11:11AM +0200, Jiri Olsa escreveu:
> > To be used in cases for both sides trim.
> > 
> > Link: http://lkml.kernel.org/n/tip-7fuk01zwjefo0aoqo42co0vy@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> 
> Thanks, applied.
> 
> Will try Milian's 'perf trace' callchain patch soon, any updates on that one?

nope, nothing yet

jirka

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


#1373505

FromMilian Wolff <milian.wolff@kdab.com>
Date2016-04-07 18:00 +0200
Message-ID<rlkvF-692-45@gated-at.bofh.it>
In reply to#1373415

[Multipart message — attachments visible in raw view] — view raw

On Thursday, April 7, 2016 4:03:21 PM CEST Jiri Olsa wrote:
> On Thu, Apr 07, 2016 at 10:50:47AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Thu, Apr 07, 2016 at 09:11:11AM +0200, Jiri Olsa escreveu:
> > > To be used in cases for both sides trim.
> > > 
> > > Link:
> > > http://lkml.kernel.org/n/tip-7fuk01zwjefo0aoqo42co0vy@git.kernel.org
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > 
> > Thanks, applied.
> > 
> > Will try Milian's 'perf trace' callchain patch soon, any updates on that
> > one?
> nope, nothing yet

I'll send a working solution based on Jiri's fix later when I'm back home. In 
the meantime, please have a look at my other patch regarding `perf inject` 
merging of trace events for sys_enter/exit.

Thanks

-- 
Milian Wolff | milian.wolff@kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts

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


#1377577 — [tip:perf/core] perf tools: Introduce trim function

Fromtip-bot for Jiri Olsa <tipbot@zytor.com>
Date2016-04-13 09:20 +0200
Subject[tip:perf/core] perf tools: Introduce trim function
Message-ID<rnnfI-5N9-23@gated-at.bofh.it>
In reply to#1373118
Commit-ID:  7d6a7e782558323364bc0ae59f3523175c10b258
Gitweb:     http://git.kernel.org/tip/7d6a7e782558323364bc0ae59f3523175c10b258
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 7 Apr 2016 09:11:11 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 7 Apr 2016 10:21:49 -0300

perf tools: Introduce trim function

To be used in cases for both sides trim.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andreas Hollmann <hollmann@in.tum.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460013073-18444-1-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/browsers/hists.c | 3 +--
 tools/perf/ui/stdio/hist.c     | 3 +--
 tools/perf/util/util.h         | 5 +++++
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 2a83414..e70df2e 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1607,9 +1607,8 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
 
 			ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
 			dummy_hpp.buf[ret] = '\0';
-			rtrim(dummy_hpp.buf);
 
-			start = ltrim(dummy_hpp.buf);
+			start = trim(dummy_hpp.buf);
 			ret = strlen(start);
 
 			if (start != dummy_hpp.buf)
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 7aff5ac..560eb47 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -569,9 +569,8 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
 			first_col = false;
 
 			fmt->header(fmt, hpp, hists_to_evsel(hists));
-			rtrim(hpp->buf);
 
-			header_width += fprintf(fp, "%s", ltrim(hpp->buf));
+			header_width += fprintf(fp, "%s", trim(hpp->buf));
 		}
 	}
 
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 8298d60..3bf3de8 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -254,6 +254,11 @@ int hex2u64(const char *ptr, u64 *val);
 char *ltrim(char *s);
 char *rtrim(char *s);
 
+static inline char *trim(char *s)
+{
+	return ltrim(rtrim(s));
+}
+
 void dump_stack(void);
 void sighandler_dump_stack(int sig);
 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web