linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] perf report: Support --header-only for pipe mode
@ 2020-12-10  6:13 Namhyung Kim
  2020-12-10  6:13 ` [PATCH 2/2] perf evlist: Support pipe mode display Namhyung Kim
  2020-12-13 23:00 ` [PATCH 1/2] perf report: Support --header-only for pipe mode Jiri Olsa
  0 siblings, 2 replies; 6+ messages in thread
From: Namhyung Kim @ 2020-12-10  6:13 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, Mark Rutland, Alexander Shishkin,
	LKML, Stephane Eranian, Ian Rogers

The --header-only checks file header and prints the feature data.  But
as pipe mode doesn't have it in the header it prints almost nothing.
Change it to process first few records until it founds HEADER_FEATURE.

Before:
  $ perf record -o- true | perf report -i- --header-only
  # ========
  # captured on    : Thu Dec 10 14:34:59 2020
  # header version : 1
  # data offset    : 0
  # data size      : 0
  # feat offset    : 0
  # ========
  #

After:
  $ perf record -o- true | perf report -i- --header-only
  # ========
  # captured on    : Thu Dec 10 14:49:11 2020
  # header version : 1
  # data offset    : 0
  # data size      : 0
  # feat offset    : 0
  # ========
  #
  # hostname : balhae
  # os release : 5.7.17-1xxx
  # perf version : 5.10.rc6.gdb0ea13cc741
  # arch : x86_64
  # nrcpus online : 8
  # nrcpus avail : 8
  # cpudesc : Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
  # cpuid : GenuineIntel,6,142,12
  # total memory : 16158916 kB
  # cmdline : perf record -o- true
  # event : name = cycles, , id = { 81, 82, 83, 84, 85, 86, 87, 88 }, size = 120, ...
  # CPU_TOPOLOGY info available, use -I to display
  # NUMA_TOPOLOGY info available, use -I to display
  # pmu mappings: intel_pt = 9, intel_bts = 8, software = 1, power = 20, uprobe = 7, ...
  # time of first sample : 0.000000
  # time of last sample : 0.000000
  # sample duration :      0.000 ms
  # MEM_TOPOLOGY info available, use -I to display
  # cpu pmu capabilities: branches=32, max_precise=3, pmu_name=skylake

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-report.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 5efbd0602f17..2a845d6cac09 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -226,6 +226,8 @@ static int process_feature_event(struct perf_session *session,
 		pr_err("failed: wrong feature ID: %" PRI_lu64 "\n",
 		       event->feat.feat_id);
 		return -1;
+	} else if (rep->header_only) {
+		session_done = 1;
 	}
 
 	/*
@@ -1512,6 +1514,13 @@ int cmd_report(int argc, const char **argv)
 		perf_session__fprintf_info(session, stdout,
 					   report.show_full_info);
 		if (report.header_only) {
+			if (data.is_pipe) {
+				/*
+				 * we need to process first few records
+				 * which contains PERF_RECORD_HEADER_FEATURE.
+				 */
+				perf_session__process_events(session);
+			}
 			ret = 0;
 			goto error;
 		}
-- 
2.29.2.576.ga3fc446d84-goog


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

* [PATCH 2/2] perf evlist: Support pipe mode display
  2020-12-10  6:13 [PATCH 1/2] perf report: Support --header-only for pipe mode Namhyung Kim
@ 2020-12-10  6:13 ` Namhyung Kim
  2020-12-13 23:00   ` Jiri Olsa
  2020-12-13 23:00 ` [PATCH 1/2] perf report: Support --header-only for pipe mode Jiri Olsa
  1 sibling, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2020-12-10  6:13 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa
  Cc: Ingo Molnar, Peter Zijlstra, Mark Rutland, Alexander Shishkin,
	LKML, Stephane Eranian, Ian Rogers

Likewise, perf evlist command should print event attributes by reading
PERF_RECORD_HEADER_ATTR records.

Before:
  $ perf record -o- true | ./perf evlist -i-
  (prints nothing)

After:
  $ perf record -o- true | ./perf evlist -i-
  cycles:pppH

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/builtin-evlist.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index 98e992801251..4617b32c9c97 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -17,6 +17,14 @@
 #include "util/data.h"
 #include "util/debug.h"
 #include <linux/err.h>
+#include "util/tool.h"
+
+static int process_header_feature(struct perf_session *session __maybe_unused,
+				  union perf_event *event __maybe_unused)
+{
+	session_done = 1;
+	return 0;
+}
 
 static int __cmd_evlist(const char *file_name, struct perf_attr_details *details)
 {
@@ -27,12 +35,20 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
 		.mode      = PERF_DATA_MODE_READ,
 		.force     = details->force,
 	};
+	struct perf_tool tool = {
+		/* only needed for pipe mode */
+		.attr = perf_event__process_attr,
+		.feature = process_header_feature,
+	};
 	bool has_tracepoint = false;
 
-	session = perf_session__new(&data, 0, NULL);
+	session = perf_session__new(&data, 0, &tool);
 	if (IS_ERR(session))
 		return PTR_ERR(session);
 
+	if (data.is_pipe)
+		perf_session__process_events(session);
+
 	evlist__for_each_entry(session->evlist, pos) {
 		evsel__fprintf(pos, details, stdout);
 
-- 
2.29.2.576.ga3fc446d84-goog


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

* Re: [PATCH 1/2] perf report: Support --header-only for pipe mode
  2020-12-10  6:13 [PATCH 1/2] perf report: Support --header-only for pipe mode Namhyung Kim
  2020-12-10  6:13 ` [PATCH 2/2] perf evlist: Support pipe mode display Namhyung Kim
@ 2020-12-13 23:00 ` Jiri Olsa
  2020-12-14 13:22   ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2020-12-13 23:00 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra,
	Mark Rutland, Alexander Shishkin, LKML, Stephane Eranian,
	Ian Rogers

On Thu, Dec 10, 2020 at 03:13:01PM +0900, Namhyung Kim wrote:
> The --header-only checks file header and prints the feature data.  But
> as pipe mode doesn't have it in the header it prints almost nothing.
> Change it to process first few records until it founds HEADER_FEATURE.
> 
> Before:
>   $ perf record -o- true | perf report -i- --header-only
>   # ========
>   # captured on    : Thu Dec 10 14:34:59 2020
>   # header version : 1
>   # data offset    : 0
>   # data size      : 0
>   # feat offset    : 0
>   # ========
>   #
> 
> After:
>   $ perf record -o- true | perf report -i- --header-only
>   # ========
>   # captured on    : Thu Dec 10 14:49:11 2020
>   # header version : 1
>   # data offset    : 0
>   # data size      : 0
>   # feat offset    : 0
>   # ========
>   #
>   # hostname : balhae
>   # os release : 5.7.17-1xxx
>   # perf version : 5.10.rc6.gdb0ea13cc741
>   # arch : x86_64
>   # nrcpus online : 8
>   # nrcpus avail : 8
>   # cpudesc : Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
>   # cpuid : GenuineIntel,6,142,12
>   # total memory : 16158916 kB
>   # cmdline : perf record -o- true
>   # event : name = cycles, , id = { 81, 82, 83, 84, 85, 86, 87, 88 }, size = 120, ...
>   # CPU_TOPOLOGY info available, use -I to display
>   # NUMA_TOPOLOGY info available, use -I to display
>   # pmu mappings: intel_pt = 9, intel_bts = 8, software = 1, power = 20, uprobe = 7, ...
>   # time of first sample : 0.000000
>   # time of last sample : 0.000000
>   # sample duration :      0.000 ms
>   # MEM_TOPOLOGY info available, use -I to display
>   # cpu pmu capabilities: branches=32, max_precise=3, pmu_name=skylake
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> ---
>  tools/perf/builtin-report.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 5efbd0602f17..2a845d6cac09 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -226,6 +226,8 @@ static int process_feature_event(struct perf_session *session,
>  		pr_err("failed: wrong feature ID: %" PRI_lu64 "\n",
>  		       event->feat.feat_id);
>  		return -1;
> +	} else if (rep->header_only) {
> +		session_done = 1;
>  	}
>  
>  	/*
> @@ -1512,6 +1514,13 @@ int cmd_report(int argc, const char **argv)
>  		perf_session__fprintf_info(session, stdout,
>  					   report.show_full_info);
>  		if (report.header_only) {
> +			if (data.is_pipe) {
> +				/*
> +				 * we need to process first few records
> +				 * which contains PERF_RECORD_HEADER_FEATURE.
> +				 */
> +				perf_session__process_events(session);
> +			}
>  			ret = 0;
>  			goto error;
>  		}
> -- 
> 2.29.2.576.ga3fc446d84-goog
> 


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

* Re: [PATCH 2/2] perf evlist: Support pipe mode display
  2020-12-10  6:13 ` [PATCH 2/2] perf evlist: Support pipe mode display Namhyung Kim
@ 2020-12-13 23:00   ` Jiri Olsa
  2020-12-14 13:22     ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2020-12-13 23:00 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra,
	Mark Rutland, Alexander Shishkin, LKML, Stephane Eranian,
	Ian Rogers

On Thu, Dec 10, 2020 at 03:13:02PM +0900, Namhyung Kim wrote:
> Likewise, perf evlist command should print event attributes by reading
> PERF_RECORD_HEADER_ATTR records.
> 
> Before:
>   $ perf record -o- true | ./perf evlist -i-
>   (prints nothing)
> 
> After:
>   $ perf record -o- true | ./perf evlist -i-
>   cycles:pppH
> 
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> ---
>  tools/perf/builtin-evlist.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
> index 98e992801251..4617b32c9c97 100644
> --- a/tools/perf/builtin-evlist.c
> +++ b/tools/perf/builtin-evlist.c
> @@ -17,6 +17,14 @@
>  #include "util/data.h"
>  #include "util/debug.h"
>  #include <linux/err.h>
> +#include "util/tool.h"
> +
> +static int process_header_feature(struct perf_session *session __maybe_unused,
> +				  union perf_event *event __maybe_unused)
> +{
> +	session_done = 1;
> +	return 0;
> +}
>  
>  static int __cmd_evlist(const char *file_name, struct perf_attr_details *details)
>  {
> @@ -27,12 +35,20 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
>  		.mode      = PERF_DATA_MODE_READ,
>  		.force     = details->force,
>  	};
> +	struct perf_tool tool = {
> +		/* only needed for pipe mode */
> +		.attr = perf_event__process_attr,
> +		.feature = process_header_feature,
> +	};
>  	bool has_tracepoint = false;
>  
> -	session = perf_session__new(&data, 0, NULL);
> +	session = perf_session__new(&data, 0, &tool);
>  	if (IS_ERR(session))
>  		return PTR_ERR(session);
>  
> +	if (data.is_pipe)
> +		perf_session__process_events(session);
> +
>  	evlist__for_each_entry(session->evlist, pos) {
>  		evsel__fprintf(pos, details, stdout);
>  
> -- 
> 2.29.2.576.ga3fc446d84-goog
> 


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

* Re: [PATCH 2/2] perf evlist: Support pipe mode display
  2020-12-13 23:00   ` Jiri Olsa
@ 2020-12-14 13:22     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-12-14 13:22 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Namhyung Kim, Ingo Molnar, Peter Zijlstra, Mark Rutland,
	Alexander Shishkin, LKML, Stephane Eranian, Ian Rogers

Em Mon, Dec 14, 2020 at 12:00:35AM +0100, Jiri Olsa escreveu:
> On Thu, Dec 10, 2020 at 03:13:02PM +0900, Namhyung Kim wrote:
> > Likewise, perf evlist command should print event attributes by reading
> > PERF_RECORD_HEADER_ATTR records.
> > 
> > Before:
> >   $ perf record -o- true | ./perf evlist -i-
> >   (prints nothing)
> > 
> > After:
> >   $ perf record -o- true | ./perf evlist -i-
> >   cycles:pppH
> > 
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> 
> Acked-by: Jiri Olsa <jolsa@redhat.com>


Thanks, applied.

- Arnaldo


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

* Re: [PATCH 1/2] perf report: Support --header-only for pipe mode
  2020-12-13 23:00 ` [PATCH 1/2] perf report: Support --header-only for pipe mode Jiri Olsa
@ 2020-12-14 13:22   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2020-12-14 13:22 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Namhyung Kim, Ingo Molnar, Peter Zijlstra, Mark Rutland,
	Alexander Shishkin, LKML, Stephane Eranian, Ian Rogers

Em Mon, Dec 14, 2020 at 12:00:19AM +0100, Jiri Olsa escreveu:
> On Thu, Dec 10, 2020 at 03:13:01PM +0900, Namhyung Kim wrote:
> > The --header-only checks file header and prints the feature data.  But
> > as pipe mode doesn't have it in the header it prints almost nothing.
> > Change it to process first few records until it founds HEADER_FEATURE.
> > 
> > Before:
> >   $ perf record -o- true | perf report -i- --header-only
> >   # ========
> >   # captured on    : Thu Dec 10 14:34:59 2020
> >   # header version : 1
> >   # data offset    : 0
> >   # data size      : 0
> >   # feat offset    : 0
> >   # ========
> >   #
> > 
> > After:
> >   $ perf record -o- true | perf report -i- --header-only
> >   # ========
> >   # captured on    : Thu Dec 10 14:49:11 2020
> >   # header version : 1
> >   # data offset    : 0
> >   # data size      : 0
> >   # feat offset    : 0
> >   # ========
> >   #
> >   # hostname : balhae
> >   # os release : 5.7.17-1xxx
> >   # perf version : 5.10.rc6.gdb0ea13cc741
> >   # arch : x86_64
> >   # nrcpus online : 8
> >   # nrcpus avail : 8
> >   # cpudesc : Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
> >   # cpuid : GenuineIntel,6,142,12
> >   # total memory : 16158916 kB
> >   # cmdline : perf record -o- true
> >   # event : name = cycles, , id = { 81, 82, 83, 84, 85, 86, 87, 88 }, size = 120, ...
> >   # CPU_TOPOLOGY info available, use -I to display
> >   # NUMA_TOPOLOGY info available, use -I to display
> >   # pmu mappings: intel_pt = 9, intel_bts = 8, software = 1, power = 20, uprobe = 7, ...
> >   # time of first sample : 0.000000
> >   # time of last sample : 0.000000
> >   # sample duration :      0.000 ms
> >   # MEM_TOPOLOGY info available, use -I to display
> >   # cpu pmu capabilities: branches=32, max_precise=3, pmu_name=skylake
> > 
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> 
> Acked-by: Jiri Olsa <jolsa@redhat.com>

Thanks, applied.

- Arnaldo


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

end of thread, other threads:[~2020-12-14 13:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-10  6:13 [PATCH 1/2] perf report: Support --header-only for pipe mode Namhyung Kim
2020-12-10  6:13 ` [PATCH 2/2] perf evlist: Support pipe mode display Namhyung Kim
2020-12-13 23:00   ` Jiri Olsa
2020-12-14 13:22     ` Arnaldo Carvalho de Melo
2020-12-13 23:00 ` [PATCH 1/2] perf report: Support --header-only for pipe mode Jiri Olsa
2020-12-14 13:22   ` Arnaldo Carvalho de Melo

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).