perf top: Initialize perf_env->cpuid, needed by the per arch annotation init routine
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 30 Sep 2019 14:53:00 +0000 (11:53 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 7 Oct 2019 15:22:17 +0000 (12:22 -0300)
Just read it so that later on the per arch init routine can use it,
e.g. x86__annotate_init().

When using a perf.data file this is obtained from a header that was put
there by 'perf record', and then it may be for another machine, another
arch.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-4t4n3o8l8s0tc2b1pq53hyr4@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-top.c

index 1f60124eb19bb4e722f22323bcb46d0c27491800..611d03030abcdad6cb4ad6ca21c7bc1f83dadc61 100644 (file)
@@ -1560,6 +1560,17 @@ int cmd_top(int argc, const char **argv)
        status = perf_config(perf_top_config, &top);
        if (status)
                return status;
+       /*
+        * Since the per arch annotation init routine may need the cpuid, read
+        * it here, since we are not getting this from the perf.data header.
+        */
+       status = perf_env__read_cpuid(&perf_env);
+       if (status) {
+               pr_err("Couldn't read the cpuid for this machine: %s\n",
+                      str_error_r(errno, errbuf, sizeof(errbuf)));
+               goto out_delete_evlist;
+       }
+       top.evlist->env = &perf_env;
 
        argc = parse_options(argc, argv, options, top_usage, 0);
        if (argc)