Skip to contentSkip to conversation

perf top: Initialize perf_env->cpuid, needed by the per arch annotation init routine

tip: perf/core tip-bot2 for Arnaldo Carvalho de Melo 1 participant 1 message Oct 15, 2019 1 message not in the archive perf events

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

tip-bot2 for Arnaldo Carvalho de Melo

author merge bot Applied
#1 lore raw

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     608127f73779bfc199158b61efdbdb690720e542
Gitweb:        https://git.kernel.org/tip/608127f73779bfc199158b61efdbdb690720e542
Author:        Arnaldo Carvalho de Melo <[email protected]>
AuthorDate:    Mon, 30 Sep 2019 11:53:00 -03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Mon, 07 Oct 2019 12:22:17 -03:00

perf top: Initialize perf_env->cpuid, needed by the per arch annotation init routine

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.

---
 tools/perf/builtin-top.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/perf/builtin-top.c +11 -0
index 1f60124..611d030 100644
@@ -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)