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>
---
tools/perf/util/parse-events.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index dfb951bb184b..c7fe8b4167d7 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -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>
@@ -672,7 +673,22 @@ static int add_tracepoint_multi_sys(struct parse_events_state *parse_state,
int 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
--
2.46.0.469.g59c65b2a67-goog
On Sat, Aug 31, 2024 at 12:04:14AM -0700, Ian Rogers wrote:
> 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.
⬢[acme@toolbox perf-tools-next]$ gcc --version
gcc (GCC) 14.2.1 20240801 (Red Hat 14.2.1-1)
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
⬢[acme@toolbox perf-tools-next]$ gcc --version
gcc (GCC) 14.2.1 20240801 (Red Hat 14.2.1-1)
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
⬢[acme@toolbox perf-tools-next]$ uname -a
Linux toolbox 6.10.4-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Aug 11 15:32:50 UTC 2024 x86_64 GNU/Linux
⬢[acme@toolbox perf-tools-next]$ head /etc/os-release
NAME="Fedora Linux"
VERSION="40 (Toolbx Container Image)"
ID=fedora
VERSION_ID=40
VERSION_CODENAME=""
PLATFORM_ID="platform:f40"
PRETTY_NAME="Fedora Linux 40 (Toolbx Container Image)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:40"
⬢[acme@toolbox perf-tools-next]$
CC /tmp/build/perf-tools-next/tests/bp_signal_overflow.o
tests/bp_signal.c: In function ‘__event’:
tests/bp_signal.c:115:28: error: operand of ‘?:’ changes signedness from ‘int’ to ‘long unsigned int’ due to unsignedness of other operand [-Werror=sign-compare]
115 | pe.bp_len = is_x ? default_breakpoint_len() : sizeof(long);
| ^~~~~~~~~~~~~~~~~~~~~~~~
LD /tmp/build/perf-tools-next/pmu-events/pmu-events-in.o
cc1: all warnings being treated as errors
make[4]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:105: /tmp/build/perf-tools-next/tests/bp_signal.o] Error 1
CC /tmp/build/perf-tools-next/builtin-mem.o
make[4]: *** Waiting for unfinished jobs....
CC /tmp/build/perf-tools-next/util/symbol.o
CC /tmp/build/perf-tools-next/builtin-version.o
AR /tmp/build/perf-tools-next/libpmu-events.a
CC /tmp/build/perf-tools-next/util/metricgroup.o
CC /tmp/build/perf-tools-next/builtin-c2c.o
CC /tmp/build/perf-tools-next/util/header.o
make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:158: tests] Error 2
make[2]: *** [Makefile.perf:777: /tmp/build/perf-tools-next/perf-test-in.o] Error 2
make[2]: *** Waiting for unfinished jobs....
On Tue, Sep 3, 2024 at 7:24 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > On Sat, Aug 31, 2024 at 12:04:14AM -0700, Ian Rogers wrote: > > 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. > > ⬢[acme@toolbox perf-tools-next]$ gcc --version > gcc (GCC) 14.2.1 20240801 (Red Hat 14.2.1-1) > Copyright (C) 2024 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > ⬢[acme@toolbox perf-tools-next]$ gcc --version > gcc (GCC) 14.2.1 20240801 (Red Hat 14.2.1-1) > Copyright (C) 2024 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > ⬢[acme@toolbox perf-tools-next]$ uname -a > Linux toolbox 6.10.4-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Aug 11 15:32:50 UTC 2024 x86_64 GNU/Linux > ⬢[acme@toolbox perf-tools-next]$ head /etc/os-release > NAME="Fedora Linux" > VERSION="40 (Toolbx Container Image)" > ID=fedora > VERSION_ID=40 > VERSION_CODENAME="" > PLATFORM_ID="platform:f40" > PRETTY_NAME="Fedora Linux 40 (Toolbx Container Image)" > ANSI_COLOR="0;38;2;60;110;180" > LOGO=fedora-logo-icon > CPE_NAME="cpe:/o:fedoraproject:fedora:40" > ⬢[acme@toolbox perf-tools-next]$ > > CC /tmp/build/perf-tools-next/tests/bp_signal_overflow.o > tests/bp_signal.c: In function ‘__event’: > tests/bp_signal.c:115:28: error: operand of ‘?:’ changes signedness from ‘int’ to ‘long unsigned int’ due to unsignedness of other operand [-Werror=sign-compare] > 115 | pe.bp_len = is_x ? default_breakpoint_len() : sizeof(long); > | ^~~~~~~~~~~~~~~~~~~~~~~~ > LD /tmp/build/perf-tools-next/pmu-events/pmu-events-in.o Teach me to build only with clang. Fixed in v2. Thanks, Ian > cc1: all warnings being treated as errors > make[4]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:105: /tmp/build/perf-tools-next/tests/bp_signal.o] Error 1 > CC /tmp/build/perf-tools-next/builtin-mem.o > make[4]: *** Waiting for unfinished jobs.... > CC /tmp/build/perf-tools-next/util/symbol.o > CC /tmp/build/perf-tools-next/builtin-version.o > AR /tmp/build/perf-tools-next/libpmu-events.a > CC /tmp/build/perf-tools-next/util/metricgroup.o > CC /tmp/build/perf-tools-next/builtin-c2c.o > CC /tmp/build/perf-tools-next/util/header.o > make[3]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:158: tests] Error 2 > make[2]: *** [Makefile.perf:777: /tmp/build/perf-tools-next/perf-test-in.o] Error 2 > make[2]: *** Waiting for unfinished jobs.... >
© 2016 - 2026 Red Hat, Inc.