Skip to content

Commit fa6cc3f

Browse files
captain5050acmel
authored andcommitted
perf parse-events: Vary default_breakpoint_len on i386 and arm64
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 <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Chaitanya S Prakash <[email protected]> Cc: Colin Ian King <[email protected]> Cc: Dominique Martinet <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Junhao He <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Yang Jihong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 70b27c7 commit fa6cc3f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tools/perf/util/parse-events.c

+16
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <sys/ioctl.h>
99
#include <sys/param.h>
1010
#include "term.h"
11+
#include "env.h"
1112
#include "evlist.h"
1213
#include "evsel.h"
1314
#include <subcmd/parse-options.h>
@@ -673,7 +674,22 @@ static int add_tracepoint_multi_sys(struct parse_events_state *parse_state,
673674

674675
size_t default_breakpoint_len(void)
675676
{
677+
#if defined(__i386__)
678+
static int len;
679+
680+
if (len == 0) {
681+
struct perf_env env = {};
682+
683+
perf_env__init(&env);
684+
len = perf_env__kernel_is_64_bit(&env) ? sizeof(u64) : sizeof(long);
685+
perf_env__exit(&env);
686+
}
687+
return len;
688+
#elif defined(__aarch64__)
689+
return 4;
690+
#else
676691
return sizeof(long);
692+
#endif
677693
}
678694

679695
static int

0 commit comments

Comments
 (0)