Re: [PATCH POC] prctl: extend PR_SET_THP_DISABLE to optionally exclude VM_HUGEPAGE
From: Usama Arif
Date: Wed Jul 23 2025 - 13:08:07 EST
>> Thanks for the patch David!
>>
>> As discussed in the other thread, with the below diff
>>
>> diff --git a/kernel/sys.c b/kernel/sys.c
>> index 2a34b2f70890..3912f5b6a02d 100644
>> --- a/kernel/sys.c
>> +++ b/kernel/sys.c
>> @@ -2447,7 +2447,7 @@ static int prctl_set_thp_disable(unsigned long thp_disable, unsigned long flags,
>> return -EINVAL;
>> /* Flags are only allowed when disabling. */
>> - if (!thp_disable || (flags & ~PR_THP_DISABLE_EXCEPT_ADVISED))
>> + if ((!thp_disable && flags) || (flags & ~PR_THP_DISABLE_EXCEPT_ADVISED))
>> return -EINVAL;
>> if (mmap_write_lock_killable(current->mm))
>> return -EINTR;
>>
>>
>> I tested with the below selftest, and it works. It hopefully covers
>> majority of the cases including fork and re-enabling THPs.
>> Let me know if it looks ok and please feel free to add this in the
>> next revision you send.
>>
>>
>> Once the above diff is included, please feel free to add
>>
>> Acked-by: Usama Arif <usamaarif642@xxxxxxxxx>
>> Tested-by: Usama Arif <usamaarif642@xxxxxxxxx>
>
> Thanks!
>
> The latest version lives at
>
> https://github.com/davidhildenbrand/linux/tree/PR_SET_THP_DISABLE
>
> With all current review feedback addressed (primarily around description+comments) + that one fix.
>
>
Hi David,
Just wanted to check if the above branch is up to date?
I didn't check the description/comments, but it still has [1]:
if (!thp_disable || (flags & ~PR_THP_DISABLE_EXCEPT_ADVISED))
and not
if ((!thp_disable && flags) || (flags & ~PR_THP_DISABLE_EXCEPT_ADVISED))
in prctl_set_thp_disable, which is causing the reset to system policy case in my selftest to fail.
[1] https://github.com/davidhildenbrand/linux/commit/5711cdf5dfe65ca28dac2a57d62e18f1475dac57#diff-dc9985831020a20a54baf023fec641593d0d4e75a78988c3b35a176aff1c0321R2450
Thanks,
Usama