s390: fix dead defaults for S390_MODULES_SANITY_TEST and S390_UNWIND_SELFTEST
PATCH RESEND 1/1 s390: fix dead defaults for S390_MODULES_SANITY_TEST and S390_UNWIND_SELFTEST
These config options currently have unconditional defaults of 'n' from the def_tristate statement, which shadow the later default of 'KUNIT_ALL_TESTS', causing it to be dead code.
It looks to me like the commit 25d36a85c61b ("s390/test_unwind: convert to KUnit") added the KUNIT_ALL_TESTS default to S390_UNWIND_SELFTEST, but mistakenly didn't remove the previous 'n' default.
Then, the later commit 90c5318795ee ("s390/module: test loading modules with a lot of relocations") copied the Kconfig layout from S390_UNWIND_SELFTEST when adding the S390_MODULES_SANITY_TEST config option, without noticing the existing mistake.
This dead code was found by kconfirm, a static analysis tool for Kconfig.
--- arch/s390/Kconfig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/s390/Kconfig +2 -4
@@ -999,9 +999,8 @@ config S390_MODULES_SANITY_TEST_HELPERS menu "Selftests" config S390_UNWIND_SELFTEST - def_tristate n + def_tristate KUNIT_ALL_TESTS depends on KUNIT - default KUNIT_ALL_TESTS prompt "Test unwind functions" help This option enables s390 specific stack unwinder testing kernel
@@ -1023,9 +1022,8 @@ config S390_KPROBES_SANITY_TEST Say N if you are unsure. config S390_MODULES_SANITY_TEST - def_tristate n + def_tristate KUNIT_ALL_TESTS depends on KUNIT - default KUNIT_ALL_TESTS prompt "Enable s390 specific modules tests" select S390_MODULES_SANITY_TEST_HELPERS help
Signature · 1 line
2.53.0
Alexander Gordeev
maintainerQuoted 8 lines · Julian Braha
These config options currently have unconditional defaults of 'n' from the
def_tristatestatement, which shadow the later default of 'KUNIT_ALL_TESTS', causing it to be dead code.It looks to me like the commit
25d36a85c61b("s390/test_unwind: convert to KUnit") added theKUNIT_ALL_TESTSdefault toS390_UNWIND_SELFTEST, but mistakenly didn't remove the previous 'n' default.
Quoted 5 lines
Then, the later commit
90c5318795ee("s390/module: test loading modules with a lot of relocations") copied theKconfiglayout fromS390_UNWIND_SELFTESTwhen adding theS390_MODULES_SANITY_TESTconfig option, without noticing the existing mistake.This dead code was found by kconfirm, a static analysis tool for
Kconfig.
This tool is still in development, right?
Anyway, I do not quite get what do you mean with the dead code. Could you please elaborate?
Quoted 6 lines
Fixes 25d36a85c61b ("s390/test_unwind: convert to KUnit")Fixes 90c5318795ee ("s390/module: test loading modules with a lot of relocations")Signed-off-by Julian Braha <[email protected]>--- arch/s390/Kconfig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Thanks!
Quoted 1 line · Alexander Gordeev
This tool is still in development, right?
You can find the latest release (v0.7) outside the tree here:
https://github.com/julianbraha/kconfirm
And there's also a recent RFC to move it into the tree here:
https://lore.kernel.org/all/[email protected]/
Quoted 2 lines
Anyway, I do not quite get what do you mean with the dead code. Could you please elaborate?
Sure! In kconfig, default statements are evaluated in the order they appear (top --> bottom). This means that if you have an unconditional default statement at the top, e.g. 'default n', then all of the default statements that follow it will never be evaluated - in other words, they are dead code.
In the case of this code in particular, the 'def_tristate n' at the top does two things:
1. declares the type of the config option as a tristate,
2. sets the default value to 'n' unconditionally.
So, the 'default KUNIT_ALL_TESTS' statement that follows is dead code.
See also this sentence from the "Menu attributes" section of the kconfig docs:
"If multiple default values are visible, only the first defined one is active."
Source:
https://docs.kernel.org/kbuild/kconfig-language.html
- Julian Braha
Alexander Gordeev
maintainerOn Wed, Apr 29, 2026 at 10:39:14PM +0100, Julian Braha wrote:
Hi Julian,
Quoted 23 lines · Alexander Gordeev
Quoted 1 line
This tool is still in development, right?
You can find the latest release (v0.7) outside the tree here:
https://github.com/julianbraha/kconfirmAnd there's also a recent RFC to move it into the tree here:
https://lore.kernel.org/all/[email protected]/Quoted 2 lines
Anyway, I do not quite get what do you mean with the dead code. Could you please elaborate?
Sure! In kconfig, default statements are evaluated in the order they appear (top --> bottom). This means that if you have an unconditional default statement at the top, e.g. 'default n', then all of the default statements that follow it will never be evaluated - in other words, they are dead code.
In the case of this code in particular, the '
def_tristaten' at the top does two things:
1. declares the type of the config option as a tristate,
2. sets the default value to 'n' unconditionally.
Quoted 8 lines
So, the 'default
KUNIT_ALL_TESTS' statement that follows is dead code.See also this sentence from the "Menu attributes" section of the kconfig docs:
"If multiple default values are visible, only the first defined one is active."
Source:
https://docs.kernel.org/kbuild/kconfig-language.html
Thanks a lot for the clarificaiton!
In the end of the day I see no impact on the end result (aka the generated config) - please correct me if I am wrong.
I think once the tool is officially included you could refer to it in the commit message, but please do not add the described commits as Fixes - these are no real issues.
Quoted 1 line
- Julian Braha
Thanks!
Quoted 2 lines · Alexander Gordeev
In the end of the day I see no impact on the end result (aka the generated config) - please correct me if I am wrong.
Yes, there is actually an impact on the end result / the generated config:
When a user of the kernel build system (e.g. 'make menuconfig') enables the config option KUNIT_ALL_TESTS, the user expects *all of the tests* to be enabled. Which is what commit25d36a85c61b ("s390/test_unwind: convert to KUnit")
was attempting to do with these tests, but it appears they made a copy-paste mistake. This is the commit referenced in the Fixes tag.
The point is, these tests were intended to be included with KUNIT_ALL_TESTS, but aren't. This is unintended behavior, and the definition of a bug in the kernel configuration spec.
That being said, I do agree with you that this is pretty low in severity, as far as bugs go. It is kunit tests we're talking about, after all. I'll check with Greg to see if he thinks this is worthy of a Fixes tag. Another, similar patch I sent out includes the Fixes tag, and has not received any objections from its 3 reviewers and testers so far:
https://lore.kernel.org/all/[email protected]/
Quoted 2 lines
I think once the tool is officially included you could refer to it in the commit message,
I will also check on the best practices for tool-assisted development. In the past, I have received encouragement for acknowledging the tool:
https://lore.kernel.org/all/[email protected]/
and the official kernel docs require an acknowledgement for AI tool assistance (although this tool is not AI and doesn't generate code...)
- Julian Braha
Alexander Gordeev
maintainerQuoted 6 lines · Julian Braha
Quoted 2 lines · Alexander Gordeev
In the end of the day I see no impact on the end result (aka the generated config) - please correct me if I am wrong.
Yes, there is actually an impact on the end result / the generated config:
That is what is currently generated (likely because of "depends on KUNIT"):
CONFIG_S390_UNWIND_SELFTEST=mCONFIG_S390_MODULES_SANITY_TEST=m
# CONFIG_KUNIT_ALL_TESTS is not set
Quoted 10 lines
When a user of the kernel build system (e.g. 'make menuconfig') enables the config option
KUNIT_ALL_TESTS, the user expects *all of the tests* to be enabled. Which is what commit25d36a85c61b("s390/test_unwind: convert to KUnit")
was attempting to do with these tests, but it appears they made a copy-paste mistake. This is the commit referenced in the Fixes tag.The point is, these tests were intended to be included with
KUNIT_ALL_TESTS, but aren't. This is unintended behavior, and the definition of a bug in the kernel configuration spec.
I could not recreate it. Could you please provide the exact steps?
Quoted 7 lines
That being said, I do agree with you that this is pretty low in severity, as far as bugs go. It is kunit tests we're talking about, after all. I'll check with Greg to see if he thinks this is worthy of a Fixes tag. Another, similar patch I sent out includes the Fixes tag, and has not received any objections from its 3 reviewers and testers so far:
https://lore.kernel.org/all/[email protected]/
Well, this is not about severity, it is about whether an actual problem did exist and was fixed. The patch itself is fine
Quoted 8 lines
Quoted 2 lines
I think once the tool is officially included you could refer to it in the commit message,
I will also check on the best practices for tool-assisted development. In the past, I have received encouragement for acknowledging the tool:
https://lore.kernel.org/all/[email protected]/
and the official kernel docs require an acknowledgement for AI tool assistance (although this tool is not AI and doesn't generate code...)
I do appreciate your effort to bring a new tool! But unless it is part of the toolchain it shold not be referred to in a commit message as far as I am concerned. IOW, once it is in the tree, it is fine to mention it:
https://lore.kernel.org/all/[email protected]/
officially
Quoted 1 line
- Julian Braha
Thanks!
Quoted 1 line · Alexander Gordeev
I could not recreate it. Could you please provide the exact steps?
Sure, here are the exact commands I ran to reproduce for S390_UNWIND_SELFTEST. Note that I'm on x86-64 and cross-compiling for s390:
1. Start from a minimal configuration:
'make ARCH=s390 CROSS_COMPILE=s390x-unknown-linux-gnu- allnoconfig'
2. Enter menuconfig:
'make ARCH=s390 CROSS_COMPILE=s390x-unknown-linux-gnu- menuconfig'
3. Set CONFIG_KUNIT=y
4. Set CONFIG_KUNIT_ALL_TESTS=y
5. Check '.config', and see that S390_UNWIND_SELFTEST is still disabled
The steps to reproduce for S390_MODULES_SANITY_TEST are the same, but you also need to enable MODULES because of the additional dependency.
Quoted 4 lines
I do appreciate your effort to bring a new tool! But unless it is part of
the toolchain it shold not be referred to in a commit message as far as I am concerned. IOW, once it is in the tree, it is fine to mention it:
Thanks :)
Separately, I checked with Greg, and he says that:
1. it is a requirement to acknowledge tool usage, but
2. this patch (and others like it) shouldn't have the Fixes tag.
So I will resubmit this patch without "Fixes", but still acknowledging the tool, see also:
https://lore.kernel.org/all/2026050728-construct-tingle-0852@gregkh/
- Julian Braha