Re: [PATCH v2 1/2] mm: huge_memory: refactor thpsize_shmem_enabled_store() with sysfs_match_string()
From: Breno Leitao
Date: Thu May 14 2026 - 04:33:52 EST
On Wed, May 13, 2026 at 09:45:07AM +0000, ranxiaokai627@xxxxxxx wrote:
> From: Ran Xiaokai <ran.xiaokai@xxxxxxxxxx>
>
> Inspired by commit 82d9ff648c6c ("mm: huge_memory: refactor
> anon_enabled_store() with set_anon_enabled_mode()"), refactor
> thpsize_shmem_enabled_store() using sysfs_match_string().
> This eliminates the duplicated spin_lock/unlock(), set/clear_bit(),
> calls across all branches, reducing code duplication.
>
> Tested with selftests ./run_kselftest.sh -t mm:ksft_thp.sh,
> all test cases passed.
>
> Signed-off-by: Ran Xiaokai <ran.xiaokai@xxxxxxxxxx>
Reviewed-by: Breno Leitao <leitao@xxxxxxxxxx>
> + /* Do not override huge allocation policy with non-PMD sized mTHP */
> + if (mode == HUGE_SHMEM_ENABLED_INHERIT &&
> + shmem_huge == SHMEM_HUGE_FORCE && !is_pmd_order(order))
> + return -EINVAL;
This identation seems a bit broken. You probably want something like:
if (mode == HUGE_SHMEM_ENABLED_INHERIT &&
shmem_huge == SHMEM_HUGE_FORCE && !is_pmd_order(order))
return -EINVAL;