Skip to contentSkip to conversation

kunit: fix longest symbol length test

PATCH RESEND In review Sergio González Collado 3 participants 4 messages Jul 6, 2025 – Jul 10, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND v3 1/1 kunit: fix longest symbol length test

The kunit test that checks the longests symbol length [1], has triggered warnings in some pilelines when symbol prefixes are used [2][3]. The test will to depend on !PREFIX_SYMBOLS and !CFI_CLANG as sujested in [4] and on !GCOV_KERNEL.

[1] https://lore.kernel.org/rust-for-linux/CABVgOSm=5Q0fM6neBhxSbOUHBgNzmwf2V22vsYC10YRBT=kN1g@mail.gmail.com/T/#t
[2] https://lore.kernel.org/all/[email protected]/T/#u
[3] https://lore.kernel.org/rust-for-linux/[email protected]/T/#t
[4] https://lore.kernel.org/linux-kselftest/20250427200916.GA1661412@ax162/T/#t

---
 lib/Kconfig.debug                | 1 +
 lib/tests/longest_symbol_kunit.c | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/Kconfig.debug +1 -0
index ebe33181b6e6..4a75a52803b6 100644
@@ -2885,6 +2885,7 @@ config FORTIFY_KUNIT_TEST
 config LONGEST_SYM_KUNIT_TEST
 	tristate "Test the longest symbol possible" if !KUNIT_ALL_TESTS
 	depends on KUNIT && KPROBES
+	depends on !PREFIX_SYMBOLS && !CFI_CLANG && !GCOV_KERNEL
 	default KUNIT_ALL_TESTS
 	help
 	  Tests the longest symbol possible
lib/tests/longest_symbol_kunit.c +1 -2
index e3c28ff1807f..9b4de3050ba7 100644
@@ -3,8 +3,7 @@
  * Test the longest symbol length. Execute with:
  *  ./tools/testing/kunit/kunit.py run longest-symbol
  *  --arch=x86_64 --kconfig_add CONFIG_KPROBES=y --kconfig_add CONFIG_MODULES=y
- *  --kconfig_add CONFIG_RETPOLINE=n --kconfig_add CONFIG_CFI_CLANG=n
- *  --kconfig_add CONFIG_MITIGATION_RETPOLINE=n
+ *  --kconfig_add CONFIG_CPU_MITIGATIONS=n --kconfig_add CONFIG_GCOV_KERNEL=n
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

base-commit: 772b78c2abd85586bb90b23adff89f7303c704c7

Signature · 1 line
2.39.2
#1 lore raw
Quoted 46 lines · Sergio González Collado

The kunit test that checks the longests symbol length [1], has triggered warnings in some pilelines when symbol prefixes are used [2][3]. The test will to depend on !PREFIX_SYMBOLS and !CFI_CLANG as sujested in [4] and on !GCOV_KERNEL.

[1] https://lore.kernel.org/rust-for-linux/CABVgOSm=5Q0fM6neBhxSbOUHBgNzmwf2V22vsYC10YRBT=kN1g@mail.gmail.com/T/#t
[2] https://lore.kernel.org/all/[email protected]/T/#u
[3] https://lore.kernel.org/rust-for-linux/[email protected]/T/#t
[4] https://lore.kernel.org/linux-kselftest/20250427200916.GA1661412@ax162/T/#t

---
 lib/Kconfig.debug                | 1 +
 lib/tests/longest_symbol_kunit.c | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/Kconfig.debug +1 -0
index ebe33181b6e6..4a75a52803b6 100644
@@ -2885,6 +2885,7 @@ config FORTIFY_KUNIT_TEST
 config LONGEST_SYM_KUNIT_TEST
 	tristate "Test the longest symbol possible" if !KUNIT_ALL_TESTS
 	depends on KUNIT && KPROBES
+	depends on !PREFIX_SYMBOLS && !CFI_CLANG && !GCOV_KERNEL
 	default KUNIT_ALL_TESTS
 	help
 	  Tests the longest symbol possible
lib/tests/longest_symbol_kunit.c +1 -2
index e3c28ff1807f..9b4de3050ba7 100644
@@ -3,8 +3,7 @@
  * Test the longest symbol length. Execute with:
  *  ./tools/testing/kunit/kunit.py run longest-symbol
  *  --arch=x86_64 --kconfig_add CONFIG_KPROBES=y --kconfig_add CONFIG_MODULES=y
- *  --kconfig_add CONFIG_RETPOLINE=n --kconfig_add CONFIG_CFI_CLANG=n
- *  --kconfig_add CONFIG_MITIGATION_RETPOLINE=n
+ *  --kconfig_add CONFIG_CPU_MITIGATIONS=n --kconfig_add CONFIG_GCOV_KERNEL=n
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Quoted 1 line

base-commit: 772b78c2abd85586bb90b23adff89f7303c704c7

So this will obviously 'work'. But what I don't understand is the purpose of this test. Why can't we amend the test itself to use KSYM_NAME_LEN-8 (or whatever the actual magic value is) and recognise that we don't have full control over the symbol names; despite using C.

#2 lore raw

Hello,

The initial goal was to verify that a KSYM_NAME_LEN of 512 was
working as expected. It also fixed an issue in /x86/tools/insn_decoder_test.c.

This fix is indeed quite trivial, I just implemented the suggested
ideas. Amend the test using KSYM_NAME_LEN-8 doesn't really seem to me to fix the underlying problem (I also don't know if there is any magic value).

Take into account that he actual warnings that have been reported in
the CI ("Please increase KSYM_NAME_LEN both in kernel and kallsyms.c")
are not from this test, but from
https://elixir.bootlin.com/linux/v6.15/source/scripts/kallsyms.c#L146,
the test has just make that warning evident. Would removing that comment be a better solution?

Nevertheless, acknowledging that we don't have full control over the
symbols' names, is also an interesting insight.

I will be happy to address the issue in one way or another, no problem there.

Regards,
Sergio

#3 lore raw
In reply to Sergio González Collado
Quoted 11 lines · Sergio González Collado

The kunit test that checks the longests symbol length [1], has triggered warnings in some pilelines when symbol prefixes are used [2][3]. The test will to depend on !PREFIX_SYMBOLS and !CFI_CLANG as sujested in [4] and on !GCOV_KERNEL.

[1] https://lore.kernel.org/rust-for-linux/CABVgOSm=5Q0fM6neBhxSbOUHBgNzmwf2V22vsYC10YRBT=kN1g@mail.gmail.com/T/#t
[2] https://lore.kernel.org/all/[email protected]/T/#u
[3] https://lore.kernel.org/rust-for-linux/[email protected]/T/#t
[4] https://lore.kernel.org/linux-kselftest/20250427200916.GA1661412@ax162/T/#t

Quoted 4 lines

Hello!

Thanks for resending! I don't believe this has been accepted yet. So I've added it to the list of patches to get accepted for the kselftest/kunit branch.

Thanks!
-Rae

Quoted 36 lines
---
 lib/Kconfig.debug                | 1 +
 lib/tests/longest_symbol_kunit.c | 3 +--
 2 files changed, 2 insertions(+), 2 deletions(-)
lib/Kconfig.debug +1 -0
index ebe33181b6e6..4a75a52803b6 100644
@@ -2885,6 +2885,7 @@ config FORTIFY_KUNIT_TEST
 config LONGEST_SYM_KUNIT_TEST
        tristate "Test the longest symbol possible" if !KUNIT_ALL_TESTS
        depends on KUNIT && KPROBES
+       depends on !PREFIX_SYMBOLS && !CFI_CLANG && !GCOV_KERNEL
        default KUNIT_ALL_TESTS
        help
          Tests the longest symbol possible
lib/tests/longest_symbol_kunit.c +1 -2
index e3c28ff1807f..9b4de3050ba7 100644
@@ -3,8 +3,7 @@
  * Test the longest symbol length. Execute with:
  *  ./tools/testing/kunit/kunit.py run longest-symbol
  *  --arch=x86_64 --kconfig_add CONFIG_KPROBES=y --kconfig_add CONFIG_MODULES=y
- *  --kconfig_add CONFIG_RETPOLINE=n --kconfig_add CONFIG_CFI_CLANG=n
- *  --kconfig_add CONFIG_MITIGATION_RETPOLINE=n
+ *  --kconfig_add CONFIG_CPU_MITIGATIONS=n --kconfig_add CONFIG_GCOV_KERNEL=n
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

base-commit: 772b78c2abd85586bb90b23adff89f7303c704c7 --
2.39.2