[PATCH] mm/thp: dead code cleanup in Kconfig

Julian Braha posted 1 patch 1 day, 4 hours ago
mm/Kconfig | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
[PATCH] mm/thp: dead code cleanup in Kconfig
Posted by Julian Braha 1 day, 4 hours ago
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.

Signed-off-by: Julian Braha <julianbraha@gmail.com>
---
 mm/Kconfig | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index e8bf1e9e6ad9..29d2de0d5c06 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -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
Re: [PATCH] mm/thp: dead code cleanup in Kconfig
Posted by Lorenzo Stoakes (Oracle) 1 day, 3 hours ago
On Tue, Mar 31, 2026 at 08:07:30AM +0100, Julian Braha wrote:
> 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.

>
> Signed-off-by: Julian Braha <julianbraha@gmail.com>

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

Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>

> ---
>  mm/Kconfig | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/mm/Kconfig b/mm/Kconfig
> index e8bf1e9e6ad9..29d2de0d5c06 100644
> --- a/mm/Kconfig
> +++ b/mm/Kconfig
> @@ -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
>
Re: [PATCH] mm/thp: dead code cleanup in Kconfig
Posted by Andrew Morton 10 hours ago
On Tue, 31 Mar 2026 08:22:32 +0100 "Lorenzo Stoakes (Oracle)" <ljs@kernel.org> wrote:

> On Tue, Mar 31, 2026 at 08:07:30AM +0100, Julian Braha wrote:
> > 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.

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


> >
> > Signed-off-by: Julian Braha <julianbraha@gmail.com>
> 
> Unless there's some weird semantics I'm not aware of, this LGTM, so:
> 
> Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>

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