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

From: Lorenzo Stoakes (Oracle)

Date: Tue Mar 31 2026 - 03:25:14 EST


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@xxxxxxxxx>

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

Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@xxxxxxxxxx>

> ---
> 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
>