Skip to contentSkip to conversation

mm/thp: dead code cleanup in Kconfig

PATCH Applied Julian Braha 5 participants 9 messages Mar 31 – Apr 7

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

PATCH 1/1 mm/thp: dead code cleanup in Kconfig

There is already an 'if TRANSPARENT_HUGEPAGE' condition wrapping several config options e.g. 'READ_ONLY_THP_FOR_FS', making
the 'depends on' statement for each of these a duplicate dependency (dead code).

I propose leaving the outer 'if TRANSPARENT_HUGEPAGE...endif' and removing the individual 'depends on TRANSPARENT_HUGEPAGE' statement from each option.

This dead code was found by kconfirm, a static analysis tool for Kconfig.

---
 mm/Kconfig | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
mm/Kconfig +1 -5
index e8bf1e9e6ad9..29d2de0d5c06 100644
@@ -810,7 +810,6 @@ if TRANSPARENT_HUGEPAGE
 
 choice
 	prompt "Transparent Hugepage Support sysfs defaults"
-	depends on TRANSPARENT_HUGEPAGE
 	default TRANSPARENT_HUGEPAGE_ALWAYS
 	help
 	  Selects the sysfs defaults for Transparent Hugepage Support.
@@ -840,7 +839,6 @@ endchoice
 
 choice
 	prompt "Shmem hugepage allocation defaults"
-	depends on TRANSPARENT_HUGEPAGE
 	default TRANSPARENT_HUGEPAGE_SHMEM_HUGE_NEVER
 	help
 	  Selects the hugepage allocation policy defaults for
@@ -886,7 +884,6 @@ endchoice
 
 choice
 	prompt "Tmpfs hugepage allocation defaults"
-	depends on TRANSPARENT_HUGEPAGE
 	default TRANSPARENT_HUGEPAGE_TMPFS_HUGE_NEVER
 	help
 	  Selects the hugepage allocation policy defaults for
@@ -931,7 +928,7 @@ endchoice
 
 config THP_SWAP
 	def_bool y
-	depends on TRANSPARENT_HUGEPAGE && ARCH_WANTS_THP_SWAP && SWAP && 64BIT
+	depends on ARCH_WANTS_THP_SWAP && SWAP && 64BIT
 	help
 	  Swap transparent huge pages in one piece, without splitting.
 	  XXX: For now, swap cluster backing transparent huge page
@@ -941,7 +938,6 @@ config THP_SWAP
 
 config READ_ONLY_THP_FOR_FS
 	bool "Read-only THP for filesystems (EXPERIMENTAL)"
-	depends on TRANSPARENT_HUGEPAGE
 
 	help
 	  Allow khugepaged to put read-only file-backed pages in THP.
Signature · 1 line
2.51.2
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Julian Braha

There is already an 'if TRANSPARENT_HUGEPAGE' condition wrapping several config options e.g. 'READ_ONLY_THP_FOR_FS', making
the 'depends on' statement for each of these a duplicate dependency (dead code).

I propose leaving the outer 'if TRANSPARENT_HUGEPAGE...endif' and removing the individual 'depends on TRANSPARENT_HUGEPAGE' statement from each option.

This dead code was found by kconfirm, a static analysis tool for Kconfig.

Thanks for acking tooling used :) much appreciated.

Quoted 2 lines

Unless there's some weird semantics I'm not aware of, this LGTM, so:

Quoted 52 lines
---
 mm/Kconfig | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
mm/Kconfig +1 -6
index e8bf1e9e6ad9..29d2de0d5c06 100644
@@ -810,7 +810,6 @@ if TRANSPARENT_HUGEPAGE
 
 choice
 	prompt "Transparent Hugepage Support sysfs defaults"
-	depends on TRANSPARENT_HUGEPAGE
 	default TRANSPARENT_HUGEPAGE_ALWAYS
 	help
 	  Selects the sysfs defaults for Transparent Hugepage Support.
@@ -840,7 +839,6 @@ endchoice
 
 choice
 	prompt "Shmem hugepage allocation defaults"
-	depends on TRANSPARENT_HUGEPAGE
 	default TRANSPARENT_HUGEPAGE_SHMEM_HUGE_NEVER
 	help
 	  Selects the hugepage allocation policy defaults for
@@ -886,7 +884,6 @@ endchoice
 
 choice
 	prompt "Tmpfs hugepage allocation defaults"
-	depends on TRANSPARENT_HUGEPAGE
 	default TRANSPARENT_HUGEPAGE_TMPFS_HUGE_NEVER
 	help
 	  Selects the hugepage allocation policy defaults for
@@ -931,7 +928,7 @@ endchoice
 
 config THP_SWAP
 	def_bool y
-	depends on TRANSPARENT_HUGEPAGE && ARCH_WANTS_THP_SWAP && SWAP && 64BIT
+	depends on ARCH_WANTS_THP_SWAP && SWAP && 64BIT
 	help
 	  Swap transparent huge pages in one piece, without splitting.
 	  XXX: For now, swap cluster backing transparent huge page
@@ -941,7 +938,6 @@ config THP_SWAP
 
 config READ_ONLY_THP_FOR_FS
 	bool "Read-only THP for filesystems (EXPERIMENTAL)"
-	depends on TRANSPARENT_HUGEPAGE
 
 	help
 	  Allow khugepaged to put read-only file-backed pages in THP.
--

2.51.2

maintainer
#2 lore raw
Quoted 6 lines · On Tue, 31 Mar 2026 08:22:32 +0100 "Lorenzo Stoakes (Oracle)" <[email protected]>…
Quoted 5 lines · Julian Braha

There is already an 'if TRANSPARENT_HUGEPAGE' condition wrapping several config options e.g. 'READ_ONLY_THP_FOR_FS', making
the 'depends on' statement for each of these a duplicate dependency (dead code).

Quoted 7 lines
Quoted 5 lines

I propose leaving the outer 'if TRANSPARENT_HUGEPAGE...endif' and removing the individual 'depends on TRANSPARENT_HUGEPAGE' statement from each option.

This dead code was found by kconfirm, a static analysis tool for Kconfig.

Thanks for acking tooling used :) much appreciated.

OK, I give up. Where do I learn about kconfirm?

Quoted 6 lines
Quoted 2 lines

Unless there's some weird semantics I'm not aware of, this LGTM, so:

Thanks. I'll add this to my (small!) post-rc1 pile.

maintainer
#4 lore raw
Quoted 4 lines · On Sun, 5 Apr 2026 18:18:14 +0100 Julian Braha <[email protected]> wrote:

Hi Andrew,

I've just made a proper announcement of kconfirm on the mailing list:
https://lore.kernel.org/all/[email protected]/T/#u

Looks neat, thanks. I don't know how much uptake you'll get from others and I expect that addressing all those flaws yourself would be a long project! However...

Quoted 2 lines

Additionally, the code is available here:
https://github.com/julianbraha/kconfirm

Have you considered adding kconfirm to the tree? A top-level `make kconfirm' should help move things along?

#5 lore raw
Quoted 1 line

Have you considered adding kconfirm to the tree? A top-level `make

kconfirm' should help move things along?

Actually I would love to move the tool into the tree. I will clean up the code a bit and create an RFC soon.

Best regards,
Julian Braha

#6 lore raw
Quoted 2 lines · Julian Braha
Quoted 1 line

Have you considered adding kconfirm to the tree? A top-level `make

kconfirm' should help move things along?

+1 to this!

Quoted 3 lines

Actually I would love to move the tool into the tree. I will clean up the code a bit and create an RFC soon.

Thanks :)

Quoted 3 lines

Best regards,
Julian Braha

Cheers, Lorenzo

maintainer Acked-by on v1 1/1
#7 lore raw
In reply to Julian Braha
Quoted 5 lines · Julian Braha

There is already an 'if TRANSPARENT_HUGEPAGE' condition wrapping several config options e.g. 'READ_ONLY_THP_FOR_FS', making
the 'depends on' statement for each of these a duplicate dependency (dead code).

Quoted 7 lines

I propose leaving the outer 'if TRANSPARENT_HUGEPAGE...endif' and removing the individual 'depends on TRANSPARENT_HUGEPAGE' statement from each option.

This dead code was found by kconfirm, a static analysis tool for Kconfig.

Signature · 3 lines
Cheers,

David
Reviewed-by on v1 1/1
#8 lore raw
In reply to Julian Braha
Quoted 5 lines · Julian Braha

There is already an 'if TRANSPARENT_HUGEPAGE' condition wrapping several config options e.g. 'READ_ONLY_THP_FOR_FS', making
the 'depends on' statement for each of these a duplicate dependency (dead code).

Quoted 7 lines

I propose leaving the outer 'if TRANSPARENT_HUGEPAGE...endif' and removing the individual 'depends on TRANSPARENT_HUGEPAGE' statement from each option.

This dead code was found by kconfirm, a static analysis tool for Kconfig.

Quoted 49 lines
---
 mm/Kconfig | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
mm/Kconfig +1 -5
index e8bf1e9e6ad9..29d2de0d5c06 100644
@@ -810,7 +810,6 @@ if TRANSPARENT_HUGEPAGE
 
 choice
 	prompt "Transparent Hugepage Support sysfs defaults"
-	depends on TRANSPARENT_HUGEPAGE
 	default TRANSPARENT_HUGEPAGE_ALWAYS
 	help
 	  Selects the sysfs defaults for Transparent Hugepage Support.
@@ -840,7 +839,6 @@ endchoice
 
 choice
 	prompt "Shmem hugepage allocation defaults"
-	depends on TRANSPARENT_HUGEPAGE
 	default TRANSPARENT_HUGEPAGE_SHMEM_HUGE_NEVER
 	help
 	  Selects the hugepage allocation policy defaults for
@@ -886,7 +884,6 @@ endchoice
 
 choice
 	prompt "Tmpfs hugepage allocation defaults"
-	depends on TRANSPARENT_HUGEPAGE
 	default TRANSPARENT_HUGEPAGE_TMPFS_HUGE_NEVER
 	help
 	  Selects the hugepage allocation policy defaults for
@@ -931,7 +928,7 @@ endchoice
 
 config THP_SWAP
 	def_bool y
-	depends on TRANSPARENT_HUGEPAGE && ARCH_WANTS_THP_SWAP && SWAP && 64BIT
+	depends on ARCH_WANTS_THP_SWAP && SWAP && 64BIT
 	help
 	  Swap transparent huge pages in one piece, without splitting.
 	  XXX: For now, swap cluster backing transparent huge page
@@ -941,7 +938,6 @@ config THP_SWAP
 
 config READ_ONLY_THP_FOR_FS
 	bool "Read-only THP for filesystems (EXPERIMENTAL)"
-	depends on TRANSPARENT_HUGEPAGE
 
 	help
 	  Allow khugepaged to put read-only file-backed pages in THP.