From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: akpm@linux-foundation.org, hughd@google.com, david@redhat.com,
ziy@nvidia.com, Liam.Howlett@oracle.com, npache@redhat.com,
ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Pedro Falcato <pfalcato@suse.de>
Subject: Re: [PATCH v4 0/2] fix MADV_COLLAPSE issue if THP settings are disabled
Date: Thu, 10 Jul 2025 09:58:00 +0800 [thread overview]
Message-ID: <ccce870e-3117-4044-96e6-4d0e15bef913@linux.alibaba.com> (raw)
In-Reply-To: <573eb43a-8536-4206-a7c6-d0daa1fd7e70@lucifer.local>
On 2025/7/9 20:36, Lorenzo Stoakes wrote:
> +cc Pedro as he'd raised concerns here also.
>
> Hi Baolin,
>
> Just for some clarification on this - thank you very much for this series,
> but based on discussion with David and concerns raised by Hugh + others,
> overall it feels as if, while the documentation is no doubt vague in ways
> it ought not to be, this behaviour is something we have put out into the
> world and we should continue to support it.
>
> So overall I feel that this series should not be applied.
Fair enough.
>
> Your work here is great, and really massive apologies for this after all
> the work you've put in (and of course the review work here also), but on
> reflection I think it's a risk we shouldn't take.
Consensus is the key. Thank you and David for the discussion and
suggestions.
> I understand this means that MADV_COLLAPSE can't be used to collapse at a
> mTHP granularity - we definitely need to have a think about how we might
> provide this sensibly.
>
> As for how to move forward - I will go ahead and update documentation to
> make the situation absolutely crystal clear, both in the man page and the
> rst.
OK. Great. Thanks.
> Thanks, Lorenzo
>
> On Wed, Jun 25, 2025 at 09:40:08AM +0800, Baolin Wang wrote:
>> When invoking thp_vma_allowable_orders(), if 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. And the MADV_COLLAPSE is an example of
>> such a case, that means it will not set TVA_ENFORCE_SYSFS when calling
>> thp_vma_allowable_orders().
>>
>> As we discussed in the previous thread [1], the MADV_COLLAPSE will ignore
>> the system-wide anon/shmem THP sysfs settings, which means that even though
>> we have disabled the anon/shmem THP configuration, MADV_COLLAPSE will still
>> attempt to collapse into a anon/shmem THP. This violates the rule we have
>> agreed upon: never means never.
>>
>> For example, system administrators who disabled THP everywhere must indeed very
>> much not want THP to be used for whatever reason - having individual programs
>> being able to quietly override this is very surprising and likely to cause headaches
>> for those who desire this not to happen on their systems.
>>
>> This patch set will address the MADV_COLLAPSE issue.
>>
>> Test
>> ====
>> 1. Tested the mm selftests and found no regressions.
>> 2. With toggling different Anon mTHP settings, the allocation and madvise collapse for
>> anonymous pages work well.
>> 3. With toggling different shmem mTHP settings, the allocation and madvise collapse for
>> shmem work well.
>> 4. Tested the large order allocation for tmpfs, and works as expected.
>>
>> [1] https://lore.kernel.org/all/1f00fdc3-a3a3-464b-8565-4c1b23d34f8d@linux.alibaba.com/
>>
>> Changes from v3:
>> - Collect reviewed tags. Thanks.
>> - Update the commit message, per David.
>>
>> Changes from v2:
>> - Update the commit message and cover letter, per Lorenzo. Thanks.
>> - Simplify the logic in thp_vma_allowable_orders(), per Lorenzo and David. Thanks.
>>
>> Changes from v1:
>> - Update the commit message, per Zi.
>> - Add Zi's reviewed tag. Thanks.
>> - Update the shmem logic.
>>
>> Baolin Wang (2):
>> mm: huge_memory: disallow hugepages if the system-wide THP sysfs
>> settings are disabled
>> mm: shmem: disallow hugepages if the system-wide shmem THP sysfs
>> settings are disabled
>>
>> include/linux/huge_mm.h | 51 ++++++++++++++++++-------
>> mm/shmem.c | 6 +--
>> tools/testing/selftests/mm/khugepaged.c | 8 +---
>> 3 files changed, 43 insertions(+), 22 deletions(-)
>>
>> --
>> 2.43.5
>>
prev parent reply other threads:[~2025-07-10 1:58 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 1:40 [PATCH v4 0/2] fix MADV_COLLAPSE issue if THP settings are disabled Baolin Wang
2025-06-25 1:40 ` [PATCH v4 1/2] mm: huge_memory: disallow hugepages if the system-wide THP sysfs " Baolin Wang
2025-06-25 4:34 ` Dev Jain
2025-06-25 1:40 ` [PATCH v4 2/2] mm: shmem: disallow hugepages if the system-wide shmem " Baolin Wang
2025-06-25 5:53 ` [PATCH v4 0/2] fix MADV_COLLAPSE issue if THP " Hugh Dickins
2025-06-25 6:05 ` Dev Jain
2025-06-25 6:26 ` Baolin Wang
2025-06-25 6:49 ` Dev Jain
2025-06-25 6:55 ` Baolin Wang
2025-06-25 7:20 ` Lorenzo Stoakes
2025-06-25 7:34 ` David Hildenbrand
2025-06-25 7:55 ` Lorenzo Stoakes
2025-06-25 8:12 ` Lorenzo Stoakes
2025-06-25 8:24 ` David Hildenbrand
2025-06-25 8:37 ` Lorenzo Stoakes
2025-06-25 8:52 ` Baolin Wang
2025-06-25 9:31 ` Lorenzo Stoakes
2025-06-25 10:02 ` Baolin Wang
2025-06-25 10:07 ` David Hildenbrand
2025-06-25 10:15 ` Lorenzo Stoakes
2025-06-25 10:29 ` David Hildenbrand
2025-06-25 8:53 ` David Hildenbrand
2025-06-25 11:03 ` Usama Arif
2025-06-25 11:09 ` David Hildenbrand
2025-06-26 3:49 ` Hugh Dickins
2025-06-25 7:23 ` David Hildenbrand
2025-06-25 7:30 ` Lorenzo Stoakes
2025-06-25 7:36 ` David Hildenbrand
2025-06-25 7:42 ` Lorenzo Stoakes
2025-06-25 7:49 ` David Hildenbrand
2025-06-25 8:16 ` David Hildenbrand
2025-06-25 8:22 ` Lorenzo Stoakes
2025-06-25 8:40 ` David Hildenbrand
2025-06-25 8:45 ` Lorenzo Stoakes
2025-06-25 21:51 ` Hugh Dickins
2025-07-09 12:36 ` Lorenzo Stoakes
2025-07-10 1:58 ` Baolin Wang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ccce870e-3117-4044-96e6-4d0e15bef913@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=npache@redhat.com \
--cc=pfalcato@suse.de \
--cc=ryan.roberts@arm.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).