Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf bpf_counter: Fix the 32-bit build
@ 2026-11-28  1:31 Arnaldo Carvalho de Melo
  2026-11-28  1:36 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-11-28  1:31 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, linux-perf-users,
	Arnaldo Carvalho de Melo, Hang Zhengyang,
	Arnaldo Carvalho de Melo

The bpffs hint added for the perf_event_attr map compares st.f_type with
BPF_FS_MAGIC.  On 32-bit glibc __fsword_t is int while BPF_FS_MAGIC is
unsigned int, so the comparison is a sign-compare warning:

  util/bpf_counter.c:394:43: error: comparison of integer expressions of
  different signedness: '__fsword_t' {aka 'int'} and 'unsigned int'
  [-Werror=sign-compare]

It is fatal where perf builds with WERROR=1, as the almalinux i386
images do; Debian builds with WERROR=0 and only warns, and Alpine's musl
defines f_type as unsigned long, so it does not warn at all.

Cast f_type to unsigned long, the form tools/bpf/bpftool/common.c uses,
which is warning-free on both 32 and 64-bit.

Fixes: 2ea09b93b4ca61c1 ("perf bpf_counter: Say why the perf_event_attr map can't be used")
Cc: Hang Zhengyang <hang.zhengyang1010@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/bpf_counter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c
index 9a463eb9d51d9b2f..6a1d9081f0db5b80 100644
--- a/tools/perf/util/bpf_counter.c
+++ b/tools/perf/util/bpf_counter.c
@@ -391,7 +391,7 @@ static void bperf_pin_hint(struct target *target, const char *path)
 
 	scnprintf(buf, sizeof(buf), "%s", path);
 	dir = dirname(buf);
-	if (statfs(dir, &st) || st.f_type == BPF_FS_MAGIC)
+	if (statfs(dir, &st) || (unsigned long)st.f_type == BPF_FS_MAGIC)
 		return;
 	if (target->attr_map)
 		pr_err("--bpf-attr-map: %s is not on bpffs\n", dir);
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf bpf_counter: Fix the 32-bit build
  2026-11-28  1:31 [PATCH] perf bpf_counter: Fix the 32-bit build Arnaldo Carvalho de Melo
@ 2026-11-28  1:36 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-28  1:36 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: linux-perf-users

> The bpffs hint added for the perf_event_attr map compares st.f_type with
> BPF_FS_MAGIC.  On 32-bit glibc __fsword_t is int while BPF_FS_MAGIC is
> unsigned int, so the comparison is a sign-compare warning:
> 
>   util/bpf_counter.c:394:43: error: comparison of integer expressions of
>   different signedness: '__fsword_t' {aka 'int'} and 'unsigned int'
>   [-Werror=sign-compare]
> 
> It is fatal where perf builds with WERROR=1, as the almalinux i386
> images do; Debian builds with WERROR=0 and only warns, and Alpine's musl
> defines f_type as unsigned long, so it does not warn at all.
> 
> Cast f_type to unsigned long, the form tools/bpf/bpftool/common.c uses,
> which is warning-free on both 32 and 64-bit.
> 
> Fixes: 2ea09b93b4ca61c1 ("perf bpf_counter: Say why the perf_event_attr map can't be used")
> Cc: Hang Zhengyang <hang.zhengyang1010@gmail.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128013144.16600-1-acme@kernel.org?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-28  1:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28  1:31 [PATCH] perf bpf_counter: Fix the 32-bit build Arnaldo Carvalho de Melo
2026-11-28  1:36 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox