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

From: Wei Yang

Date: Tue Mar 10 2026 - 23:13:36 EST


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@xxxxxxxxxx>
>Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@xxxxxxxxxx>

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

--
Wei Yang
Help you, Help me