diff mbox series

[v3,4/9] perf mem: Only initialize memory event for recording

Message ID 20201028063813.8562-5-leo.yan@linaro.org (mailing list archive)
State New, archived
Headers show
Series perf mem/c2c: Support AUX trace | expand

Commit Message

Leo Yan Oct. 28, 2020, 6:38 a.m. UTC
It's needless to initialize memory events for reporting, this patch
moves memory event initialization for only recording.  Furthermore,
the change allows to parse perf data on cross platforms, e.g. perf
tool can report result properly even the machine doesn't support
the memory events.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/builtin-mem.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Ian Rogers Oct. 30, 2020, 1:04 a.m. UTC | #1
On Tue, Oct 27, 2020 at 11:38 PM Leo Yan <leo.yan@linaro.org> wrote:
>
> It's needless to initialize memory events for reporting, this patch
> moves memory event initialization for only recording.  Furthermore,
> the change allows to parse perf data on cross platforms, e.g. perf
> tool can report result properly even the machine doesn't support
> the memory events.
>
> Signed-off-by: Leo Yan <leo.yan@linaro.org>

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/builtin-mem.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
> index 31144f586e77..f3dc2d2b879c 100644
> --- a/tools/perf/builtin-mem.c
> +++ b/tools/perf/builtin-mem.c
> @@ -78,6 +78,11 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
>         OPT_END()
>         };
>
> +       if (perf_mem_events__init()) {
> +               pr_err("failed: memory events not supported\n");
> +               return -1;
> +       }
> +
>         argc = parse_options(argc, argv, options, record_mem_usage,
>                              PARSE_OPT_KEEP_UNKNOWN);
>
> @@ -436,11 +441,6 @@ int cmd_mem(int argc, const char **argv)
>                 NULL
>         };
>
> -       if (perf_mem_events__init()) {
> -               pr_err("failed: memory events not supported\n");
> -               return -1;
> -       }
> -
>         argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
>                                         mem_usage, PARSE_OPT_KEEP_UNKNOWN);
>
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 31144f586e77..f3dc2d2b879c 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -78,6 +78,11 @@  static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
 	OPT_END()
 	};
 
+	if (perf_mem_events__init()) {
+		pr_err("failed: memory events not supported\n");
+		return -1;
+	}
+
 	argc = parse_options(argc, argv, options, record_mem_usage,
 			     PARSE_OPT_KEEP_UNKNOWN);
 
@@ -436,11 +441,6 @@  int cmd_mem(int argc, const char **argv)
 		NULL
 	};
 
-	if (perf_mem_events__init()) {
-		pr_err("failed: memory events not supported\n");
-		return -1;
-	}
-
 	argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands,
 					mem_usage, PARSE_OPT_KEEP_UNKNOWN);