* [PATCH] perf arm_spe: Fix bitfield dependency failure
@ 2026-01-23 10:02 Leo Yan
2026-01-23 10:27 ` James Clark
0 siblings, 1 reply; 5+ messages in thread
From: Leo Yan @ 2026-01-23 10:02 UTC (permalink / raw)
To: Sasha Levin, Greg KH, Arnaldo Carvalho de Melo, Namhyung Kim,
Ian Rogers, James Clark, linux-perf-users
Cc: Leo Yan, Thomas Voegtle, stable
A perf build failure was reported by Thomas Voegtle on stable kernel
v6.6.120:
make perf NO_JEVENTS=1 NO_LIBTRACEEVENT=1
BUILD: Doing 'make -j12' parallel build
HOSTCC fixdep.o
HOSTLD fixdep-in.o
...
...
CC tests/sample-parsing.o
CC util/intel-pt-decoder/intel-pt-pkt-decoder.o
CC util/perf-regs-arch/perf_regs_csky.o
CC util/arm-spe-decoder/arm-spe-pkt-decoder.o
CC util/perf-regs-arch/perf_regs_loongarch.o
In file included from util/arm-spe-decoder/arm-spe-pkt-decoder.h:10,
from util/arm-spe-decoder/arm-spe-pkt-decoder.c:14:
/local/git/linux-stable-rc/tools/include/linux/bitfield.h: In function ‘le16_encode_bits’:
/local/git/linux-stable-rc/tools/include/linux/bitfield.h:166:31: error: implicit declaration of
function ‘cpu_to_le16’; did you mean ‘htole16’? [-Werror=implicit-function-declaration]
____MAKE_OP(le##size,u##size,cpu_to_le##size,le##size##_to_cpu) \
^~~~~~~~~
/local/git/linux-stable-rc/tools/include/linux/bitfield.h:149:9: note: in definition of macro
‘____MAKE_OP’
return to((v & field_mask(field)) * field_multiplier(field)); \
^~
/local/git/linux-stable-rc/tools/include/linux/bitfield.h:170:1: note: in expansion of macro
‘__MAKE_OP’
__MAKE_OP(16)
Fix this by including linux/kernel.h, which provides the required
definitions.
The relevant C file in mainline already includes kernel.h, so the issue is
not exposed. It'd be good to merge this change on mainline as well for
robustness.
Fixes: 64d86c03e144 ("perf arm-spe: Extend branch operations")
Reported-by: Thomas Voegtle <tv@lio96.de>
Closes: https://lore.kernel.org/stable/3a44500b-d7c8-179f-61f6-e51cb50d3512@lio96.de/
Cc: stable@vger.kernel.org
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
index adf4cde320aa..8d16619cd098 100644
--- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
+++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
@@ -7,6 +7,7 @@
#ifndef INCLUDE__ARM_SPE_PKT_DECODER_H__
#define INCLUDE__ARM_SPE_PKT_DECODER_H__
+#include <linux/kernel.h>
#include <linux/bitfield.h>
#include <stddef.h>
#include <stdint.h>
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] perf arm_spe: Fix bitfield dependency failure
2026-01-23 10:02 [PATCH] perf arm_spe: Fix bitfield dependency failure Leo Yan
@ 2026-01-23 10:27 ` James Clark
2026-01-23 12:08 ` Leo Yan
0 siblings, 1 reply; 5+ messages in thread
From: James Clark @ 2026-01-23 10:27 UTC (permalink / raw)
To: Leo Yan
Cc: Thomas Voegtle, stable, Sasha Levin, Greg KH,
Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers,
linux-perf-users
On 23/01/2026 10:02 am, Leo Yan wrote:
> A perf build failure was reported by Thomas Voegtle on stable kernel
> v6.6.120:
>
> make perf NO_JEVENTS=1 NO_LIBTRACEEVENT=1
> BUILD: Doing 'make -j12' parallel build
> HOSTCC fixdep.o
> HOSTLD fixdep-in.o
> ...
> ...
> CC tests/sample-parsing.o
> CC util/intel-pt-decoder/intel-pt-pkt-decoder.o
> CC util/perf-regs-arch/perf_regs_csky.o
> CC util/arm-spe-decoder/arm-spe-pkt-decoder.o
> CC util/perf-regs-arch/perf_regs_loongarch.o
> In file included from util/arm-spe-decoder/arm-spe-pkt-decoder.h:10,
> from util/arm-spe-decoder/arm-spe-pkt-decoder.c:14:
> /local/git/linux-stable-rc/tools/include/linux/bitfield.h: In function ‘le16_encode_bits’:
> /local/git/linux-stable-rc/tools/include/linux/bitfield.h:166:31: error: implicit declaration of
> function ‘cpu_to_le16’; did you mean ‘htole16’? [-Werror=implicit-function-declaration]
> ____MAKE_OP(le##size,u##size,cpu_to_le##size,le##size##_to_cpu) \
> ^~~~~~~~~
> /local/git/linux-stable-rc/tools/include/linux/bitfield.h:149:9: note: in definition of macro
> ‘____MAKE_OP’
> return to((v & field_mask(field)) * field_multiplier(field)); \
> ^~
> /local/git/linux-stable-rc/tools/include/linux/bitfield.h:170:1: note: in expansion of macro
> ‘__MAKE_OP’
> __MAKE_OP(16)
>
> Fix this by including linux/kernel.h, which provides the required
> definitions.
>
> The relevant C file in mainline already includes kernel.h, so the issue is
> not exposed. It'd be good to merge this change on mainline as well for
> robustness.
>
> Fixes: 64d86c03e144 ("perf arm-spe: Extend branch operations")
> Reported-by: Thomas Voegtle <tv@lio96.de>
> Closes: https://lore.kernel.org/stable/3a44500b-d7c8-179f-61f6-e51cb50d3512@lio96.de/
> Cc: stable@vger.kernel.org
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
> tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> index adf4cde320aa..8d16619cd098 100644
> --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> @@ -7,6 +7,7 @@
> #ifndef INCLUDE__ARM_SPE_PKT_DECODER_H__
> #define INCLUDE__ARM_SPE_PKT_DECODER_H__
>
> +#include <linux/kernel.h>
> #include <linux/bitfield.h>
This isn't the first time I've seen this issue. Isn't the real fix to
include kernel.h in bitfield.h if it depends on it? Usually you
shouldn't have to know what all the dependencies of a header are when
you include it. Or is there a reason it wasn't done that way in the
first place? Maybe this has been discussed before?
> #include <stddef.h>
> #include <stdint.h>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] perf arm_spe: Fix bitfield dependency failure
2026-01-23 10:27 ` James Clark
@ 2026-01-23 12:08 ` Leo Yan
2026-01-23 14:03 ` David Laight
0 siblings, 1 reply; 5+ messages in thread
From: Leo Yan @ 2026-01-23 12:08 UTC (permalink / raw)
To: James Clark
Cc: Thomas Voegtle, stable, Sasha Levin, Greg KH,
Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers,
linux-perf-users
On Fri, Jan 23, 2026 at 10:27:42AM +0000, James Clark wrote:
[...]
> > diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> > index adf4cde320aa..8d16619cd098 100644
> > --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> > +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> > @@ -7,6 +7,7 @@
> > #ifndef INCLUDE__ARM_SPE_PKT_DECODER_H__
> > #define INCLUDE__ARM_SPE_PKT_DECODER_H__
> > +#include <linux/kernel.h>
> > #include <linux/bitfield.h>
>
> This isn't the first time I've seen this issue. Isn't the real fix to
> include kernel.h in bitfield.h if it depends on it?
Good point!
bitfield.h is a common header so I did not change it. I digged a bit
and found diverage between kernel's bitfield.h and tool's bitfield.h.
1) The kernel's bitfield.h includes asm/byteorder.h, and finally it
includes linux/byteorder/generic.h, cpu_to_le{16|32|64} are defined
in this file.
2) The tool's bitfield.h will includes asm/byteorder.h, but this hooks
to the headers provided by the toolchain. cpu_to_le{16|32|64} are
not C lib API, they are defined in tool's kernel.h.
As a result, we need to include kernel.h for perf build.
As you said, we can include kernel.h in bitfield.h, I will respin and
send a new series.
> Usually you shouldn't
> have to know what all the dependencies of a header are when you include it.
> Or is there a reason it wasn't done that way in the first place? Maybe this
> has been discussed before?
This issue is for tools only, and only Arm modules in perf folder use
this header, I don't expect this is widely spread issue.
Thanks,
Leo
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] perf arm_spe: Fix bitfield dependency failure
2026-01-23 12:08 ` Leo Yan
@ 2026-01-23 14:03 ` David Laight
2026-01-23 14:41 ` Leo Yan
0 siblings, 1 reply; 5+ messages in thread
From: David Laight @ 2026-01-23 14:03 UTC (permalink / raw)
To: Leo Yan
Cc: James Clark, Thomas Voegtle, stable, Sasha Levin, Greg KH,
Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers,
linux-perf-users
On Fri, 23 Jan 2026 12:08:47 +0000
Leo Yan <leo.yan@arm.com> wrote:
> On Fri, Jan 23, 2026 at 10:27:42AM +0000, James Clark wrote:
>
> [...]
>
> > > diff --git a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> > > index adf4cde320aa..8d16619cd098 100644
> > > --- a/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> > > +++ b/tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.h
> > > @@ -7,6 +7,7 @@
> > > #ifndef INCLUDE__ARM_SPE_PKT_DECODER_H__
> > > #define INCLUDE__ARM_SPE_PKT_DECODER_H__
> > > +#include <linux/kernel.h>
> > > #include <linux/bitfield.h>
> >
> > This isn't the first time I've seen this issue. Isn't the real fix to
> > include kernel.h in bitfield.h if it depends on it?
>
> Good point!
>
> bitfield.h is a common header so I did not change it. I digged a bit
> and found diverage between kernel's bitfield.h and tool's bitfield.h.
>
> 1) The kernel's bitfield.h includes asm/byteorder.h, and finally it
> includes linux/byteorder/generic.h, cpu_to_le{16|32|64} are defined
> in this file.
>
> 2) The tool's bitfield.h will includes asm/byteorder.h, but this hooks
> to the headers provided by the toolchain. cpu_to_le{16|32|64} are
> not C lib API, they are defined in tool's kernel.h.
Perhaps cpu_to_le16() and friends should be defined in the tools
asm/byteorder.h rather than its kernel.h.
David
>
> As a result, we need to include kernel.h for perf build.
>
> As you said, we can include kernel.h in bitfield.h, I will respin and
> send a new series.
>
> > Usually you shouldn't
> > have to know what all the dependencies of a header are when you include it.
> > Or is there a reason it wasn't done that way in the first place? Maybe this
> > has been discussed before?
>
> This issue is for tools only, and only Arm modules in perf folder use
> this header, I don't expect this is widely spread issue.
>
> Thanks,
> Leo
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] perf arm_spe: Fix bitfield dependency failure
2026-01-23 14:03 ` David Laight
@ 2026-01-23 14:41 ` Leo Yan
0 siblings, 0 replies; 5+ messages in thread
From: Leo Yan @ 2026-01-23 14:41 UTC (permalink / raw)
To: David Laight
Cc: James Clark, Thomas Voegtle, stable, Sasha Levin, Greg KH,
Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers,
linux-perf-users
On Fri, Jan 23, 2026 at 02:03:17PM +0000, David Laight wrote:
[...]
> > bitfield.h is a common header so I did not change it. I digged a bit
> > and found diverage between kernel's bitfield.h and tool's bitfield.h.
> >
> > 1) The kernel's bitfield.h includes asm/byteorder.h, and finally it
> > includes linux/byteorder/generic.h, cpu_to_le{16|32|64} are defined
> > in this file.
> >
> > 2) The tool's bitfield.h will includes asm/byteorder.h, but this hooks
> > to the headers provided by the toolchain. cpu_to_le{16|32|64} are
> > not C lib API, they are defined in tool's kernel.h.
>
> Perhaps cpu_to_le16() and friends should be defined in the tools
> asm/byteorder.h rather than its kernel.h.
This will override the toolchain's asm/byteorder.h.
Another issue is:
$ git grep -l cpu_to_le tools/
tools/arch/x86/include/asm/insn.h
tools/include/asm-generic/io.h
tools/include/linux/bitfield.h
tools/include/linux/kernel.h
tools/include/linux/unaligned.h
tools/perf/util/intel-pt.c
tools/testing/cxl/test/mem.c
tools/testing/nvdimm/test/ndtest.c
tools/testing/selftests/arm64/fp/fp-ptrace.c
tools/testing/selftests/kvm/include/arm64/processor.h
tools/testing/selftests/kvm/lib/arm64/gic_v3_its.c
tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
tools/usb/ffs-test.c
I assume these programs include kernel.h for calling cpu_to_le(), if
move cpu_to_le() out from kernel.h, it will break build for these
programs.
Thanks,
Leo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-01-23 14:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23 10:02 [PATCH] perf arm_spe: Fix bitfield dependency failure Leo Yan
2026-01-23 10:27 ` James Clark
2026-01-23 12:08 ` Leo Yan
2026-01-23 14:03 ` David Laight
2026-01-23 14:41 ` Leo Yan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox