lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <73ada74e-68b6-483c-b992-a6845ffc41b1@arm.com>
Date: Tue, 24 Jun 2025 20:12:22 +0530
From: Dev Jain <dev.jain@....com>
To: Baolin Wang <baolin.wang@...ux.alibaba.com>, akpm@...ux-foundation.org,
 hughd@...gle.com, david@...hat.com
Cc: ziy@...dia.com, lorenzo.stoakes@...cle.com, Liam.Howlett@...cle.com,
 npache@...hat.com, ryan.roberts@....com, baohua@...nel.org,
 linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/2] mm: huge_memory: disallow hugepages if the
 system-wide THP sysfs settings are disabled


On 24/06/25 7:38 pm, Baolin Wang wrote:
>
>
> On 2025/6/24 17:57, Baolin Wang wrote:
>>
>>
>> On 2025/6/24 16:41, Dev Jain wrote:
>>>
>>> On 23/06/25 1:58 pm, Baolin Wang wrote:
>>>> When invoking thp_vma_allowable_orders(), the TVA_ENFORCE_SYSFS 
>>>> flag is not
>>>> specified, we will ignore the THP sysfs settings. Whilst it makes 
>>>> sense for the
>>>> callers who do not specify this flag, it creates a odd and 
>>>> surprising situation
>>>> where a sysadmin specifying 'never' for all THP sizes still 
>>>> observing THP pages
>>>> being allocated and used on the system.
>>>>
>>>> The motivating case for this is MADV_COLLAPSE. The MADV_COLLAPSE 
>>>> will ignore
>>>> the system-wide Anon THP sysfs settings, which means that even 
>>>> though we have
>>>> disabled the Anon THP configuration, MADV_COLLAPSE will still 
>>>> attempt to collapse
>>>> into a Anon THP. This violates the rule we have agreed upon: never 
>>>> means never.
>>>>
>>>> Currently, besides MADV_COLLAPSE not setting TVA_ENFORCE_SYSFS, 
>>>> there is only
>>>> one other instance where TVA_ENFORCE_SYSFS is not set, which is in the
>>>> collapse_pte_mapped_thp() function, but I believe this is 
>>>> reasonable from its
>>>> comments:
>>>>
>>>> "
>>>> /*
>>>>   * If we are here, we've succeeded in replacing all the native pages
>>>>   * in the page cache with a single hugepage. If a mm were to fault-in
>>>>   * this memory (mapped by a suitably aligned VMA), we'd get the 
>>>> hugepage
>>>>   * and map it by a PMD, regardless of sysfs THP settings. As such, 
>>>> let's
>>>>   * analogously elide sysfs THP settings here.
>>>>   */
>>>> if (!thp_vma_allowable_order(vma, vma->vm_flags, 0, PMD_ORDER))
>>>
>>> So the behaviour now is: First check whether THP settings converge 
>>> to never.
>>> Then, if enforce_sysfs is not set, return immediately. So in this 
>>> khugepaged
>>> code will it be better to call __thp_vma_allowable_orders()? If the 
>>> sysfs
>>> settings are changed to never before hitting collapse_pte_mapped_thp(),
>>> then right now we will return SCAN_VMA_CHECK from here, whereas, the 
>>> comment
>>> says "regardless of sysfs THP settings", which should include 
>>> "regardless
>>> of whether the sysfs settings say never".
>>
>> Sounds reasonable to me. Thanks.
>>
>> I will change thp_vma_allowable_order() to 
>> __thp_vma_allowable_orders() in the collapse_pte_mapped_thp() 
>> function to maintain consistency with the original logic.
>>
>> Lorenzo and David, how do you think? Thanks.
>
> After thinking more, since collapse_pte_mapped_thp() is only used for 
> file/shmem collapse, changing to __thp_vma_allowable_orders() has no 
> effect. So I prefer to leave it as is.


Oops my bad, thanks.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ