]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf parse-events: Vary default_breakpoint_len on i386 and arm64
authorIan Rogers <irogers@google.com>
Wed, 4 Sep 2024 05:06:05 +0000 (22:06 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 4 Sep 2024 12:50:46 +0000 (09:50 -0300)
On arm64 the breakpoint length should be 4-bytes but 8-bytes is
tolerated as perf passes that as sizeof(long). Just pass the correct
value.

On i386 the sizeof(long) check in the kernel needs to match the
kernel's long size. Check using an environment (uname checks) whether
4 or 8 bytes needs to be passed. Cache the value in a static.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Chaitanya S Prakash <chaitanyas.prakash@arm.com>
Cc: Colin Ian King <colin.i.king@gmail.com>
Cc: Dominique Martinet <asmadeus@codewreck.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Junhao He <hejunhao3@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Yang Jihong <yangjihong@bytedance.com>
Link: https://lore.kernel.org/r/20240904050606.752788-6-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/parse-events.c

index 8c837c8a6c8c616d3a5990eeb1371ad16d32c4ca..f5eb1af8302c7bacca4b10033e6f9fda8849783f 100644 (file)
@@ -8,6 +8,7 @@
 #include <sys/ioctl.h>
 #include <sys/param.h>
 #include "term.h"
+#include "env.h"
 #include "evlist.h"
 #include "evsel.h"
 #include <subcmd/parse-options.h>
@@ -673,7 +674,22 @@ static int add_tracepoint_multi_sys(struct parse_events_state *parse_state,
 
 size_t default_breakpoint_len(void)
 {
+#if defined(__i386__)
+       static int len;
+
+       if (len == 0) {
+               struct perf_env env = {};
+
+               perf_env__init(&env);
+               len = perf_env__kernel_is_64_bit(&env) ? sizeof(u64) : sizeof(long);
+               perf_env__exit(&env);
+       }
+       return len;
+#elif defined(__aarch64__)
+       return 4;
+#else
        return sizeof(long);
+#endif
 }
 
 static int