Thread (28 messages) 28 messages, 4 authors, 2021-06-09
STALE1838d
Revisions (4)
  1. v2 current
  2. v3 [diff vs current]
  3. v4 [diff vs current]
  4. v5 [diff vs current]

[PATCH v2 8/8] perf record: Directly bail out for compat case

From: Leo Yan <hidden>
Date: 2021-06-02 10:31:06
Also in: linux-arm-kernel, lkml
Subsystem: performance events subsystem, the rest · Maintainers: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Linus Torvalds

Since the 64-bit atomicity is not promised in 32-bit perf, directly
report the error and bail out for this case.

Now only applies on x86_64 and Arm64 platforms.

Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Leo Yan <redacted>
---
 tools/perf/builtin-record.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 3337b5f93336..f47e298281f7 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -74,6 +74,7 @@
 #include <linux/zalloc.h>
 #include <linux/bitmap.h>
 #include <sys/time.h>
+#include <sys/utsname.h>
 
 struct switch_output {
 	bool		 enabled;
@@ -848,6 +849,22 @@ static int record__mmap_evlist(struct record *rec,
 				  opts->auxtrace_sample_mode;
 	char msg[512];
 
+#ifndef __LP64__
+	struct utsname uts;
+	int ret;
+
+	ret = uname(&uts);
+	if (ret < 0)
+		return ret;
+
+	if (!strncmp(uts.machine, "x86_64", 6) || !strncmp(uts.machine, "aarch64", 7) ||
+	    !strncmp(uts.machine, "arm64", 5)) {
+		pr_err("Error, 32-bit perf cannot record from a 64-bit kernel.\n"
+		       "Please use a 64-bit version of perf instead.\n");
+		return -ENOTSUP;
+	}
+#endif
+
 	if (opts->affinity != PERF_AFFINITY_SYS)
 		cpu__setup_cpunode_map();
 
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help