Re: [PATCH v5 3/4] mm: huge_memory: refactor enabled_store() with change_enabled()

Wei Yang
2026-03-11T03:13:28Z

On Tue, Mar 10, 2026 at 10:57:09AM -0700, Breno Leitao wrote:
>Refactor enabled_store() to use a new change_enabled() helper.
>Introduce a separate enum global_enabled_mode and
>global_enabled_mode_strings[], mirroring the anon_enabled_mode
>pattern from the previous commit.
>
>A separate enum is necessary because the global THP setting does
>not support "inherit", only "always", "madvise", and "never".
>Reusing anon_enabled_mode would leave a NULL gap in the string
>array, causing sysfs_match_string() to stop early and fail to
>match entries after the gap.
>
>The helper uses the same loop pattern as set_anon_enabled_mode(),
>iterating over an array of flag bit positions and using
>__test_and_set_bit()/__test_and_clear_bit() to track whether the state
>actually changed.
>
>Signed-off-by: Breno Leitao <leitao@debian.org>
>Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>

Reviewed-by: Wei Yang <richard.weiyang@gmail.com>

--
Wei Yang
Help you, Help me