The first patch fixes an build failure issued caused by bitfield on the stable kernel, the second patch is a minor polish to avoid including redundant headers.
Verified for Arm64 perf building.
Signed-off-by: Leo Yan leo.yan@arm.com --- Leo Yan (2): tools: Fix bitfield dependency failure perf: Remove redundant kernel.h include
tools/include/linux/bitfield.h | 1 + tools/perf/arch/arm64/util/header.c | 1 - tools/perf/util/cs-etm.c | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) --- base-commit: 800af362d68945e589f73cda429d04bfe4287feb change-id: 20260123-perf_fix_bitfield-h-084902f55c35
Best regards,
A perf build failure was reported by Thomas Voegtle on stable kernel v6.6.120:
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 issue was not found on the mainline due to the relevant C files have included kernel.h. 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... To: Greg KH gregkh@linuxfoundation.org To: Sasha Levin sashal@kernel.org Cc: stable@vger.kernel.org Signed-off-by: Leo Yan leo.yan@arm.com --- tools/include/linux/bitfield.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/tools/include/linux/bitfield.h b/tools/include/linux/bitfield.h index 6093fa6db2600b3246007b2236d7c0076b02343b..ddf81f24956ba069b2c1a7b096a6c9bf92fc9182 100644 --- a/tools/include/linux/bitfield.h +++ b/tools/include/linux/bitfield.h @@ -8,6 +8,7 @@ #define _LINUX_BITFIELD_H
#include <linux/build_bug.h> +#include <linux/kernel.h> #include <asm/byteorder.h>
/*
Now that the bitfield dependency is resolved, the explicit inclusion of kernel.h is no longer needed. Remove the redundant include.
Signed-off-by: Leo Yan leo.yan@arm.com --- tools/perf/arch/arm64/util/header.c | 1 - tools/perf/util/cs-etm.c | 1 - 2 files changed, 2 deletions(-)
diff --git a/tools/perf/arch/arm64/util/header.c b/tools/perf/arch/arm64/util/header.c index f445a2dd6293442645404d7c42c3f7a2992bd9c9..cbc0ba101636bf275101385c662f5f3881c8f7c4 100644 --- a/tools/perf/arch/arm64/util/header.c +++ b/tools/perf/arch/arm64/util/header.c @@ -1,4 +1,3 @@ -#include <linux/kernel.h> #include <linux/bits.h> #include <linux/bitfield.h> #include <stdio.h> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 12b55c2bc2ca4f5d7df6b26ddbffc18b7904800e..95f439c96180d354f2bc08356a844c1a79d5a148 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -6,7 +6,6 @@ * Author: Mathieu Poirier mathieu.poirier@linaro.org */
-#include <linux/kernel.h> #include <linux/bitfield.h> #include <linux/bitops.h> #include <linux/coresight-pmu.h>