linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: David Hildenbrand <david@redhat.com>,
	akpm@linux-foundation.org, hughd@google.com
Cc: willy@infradead.org, lorenzo.stoakes@oracle.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
Subject: Re: [RFC PATCH] mm: shmem: fix the strategy for the tmpfs 'huge=' options
Date: Thu, 31 Jul 2025 10:41:24 +0800	[thread overview]
Message-ID: <78c0f8ba-7e71-41da-9ac8-bcd26717dc71@linux.alibaba.com> (raw)
In-Reply-To: <0a689e9f-082b-497d-a32b-afc3feddcdb8@redhat.com>



On 2025/7/30 17:30, David Hildenbrand wrote:
> On 30.07.25 10:14, Baolin Wang wrote:
>> After commit acd7ccb284b8 ("mm: shmem: add large folio support for 
>> tmpfs"),
>> we have extended tmpfs to allow any sized large folios, rather than just
>> PMD-sized large folios.
>>
>> The strategy discussed previously was:
>>
>> "
>> Considering that tmpfs already has the 'huge=' option to control the
>> PMD-sized large folios allocation, we can extend the 'huge=' option to
>> allow any sized large folios.  The semantics of the 'huge=' mount option
>> are:
>>
>>      huge=never: no any sized large folios
>>      huge=always: any sized large folios
>>      huge=within_size: like 'always' but respect the i_size
>>      huge=advise: like 'always' if requested with madvise()
>>
>> Note: for tmpfs mmap() faults, due to the lack of a write size hint, 
>> still
>> allocate the PMD-sized huge folios if huge=always/within_size/advise is
>> set.
>>
>> Moreover, the 'deny' and 'force' testing options controlled by
>> '/sys/kernel/mm/transparent_hugepage/shmem_enabled', still retain the 
>> same
>> semantics.  The 'deny' can disable any sized large folios for tmpfs, 
>> while
>> the 'force' can enable PMD sized large folios for tmpfs.
>> "
>>
>> This means that when tmpfs is mounted with 'huge=always' or 
>> 'huge=within_size',
>> tmpfs will allow getting a highest order hint based on the size of 
>> write() and
>> fallocate() paths. It will then try each allowable large order, rather 
>> than
>> continually attempting to allocate PMD-sized large folios as before.
>>
>> However, this might break some user scenarios for those who want to use
>> PMD-sized large folios, such as the i915 driver which did not supply a 
>> write
>> size hint when allocating shmem [1].
>>
>> Moreover, Hugh also complained that this will cause a regression in 
>> userspace
>> with 'huge=always' or 'huge=within_size'.
>>
>> So, let's revisit the strategy for tmpfs large page allocation. A 
>> simple fix
>> would be to always try PMD-sized large folios first, and if that 
>> fails, fall
>> back to smaller large folios. However, this approach differs from the 
>> strategy
>> for large folio allocation used by other file systems. Is this 
>> acceptable?
> 
> My opinion so far has been that anon and shmem are different than 
> ordinary FS'es ... primarily because 
> allocation(readahead)+reclaim(writeback) behave differently.
> 
> There were opinions in the past that tmpfs should just behave like any 
> other fs, and I think that's what we tried to satisfy here: use the 
> write size as an indication.
> 
> I assume there will be workloads where either approach will be 
> beneficial. I also assume that workloads that use ordinary fs'es could 
> benefit from the same strategy (start with PMD), while others will 
> clearly not.

Yes, using the write size as an indication to allocate large folios is 
certainly reasonable in some scenarios, as it avoids memory bloat while 
leveraging the advantages of large folios.

Personally, I prefer to use this method by default for allocating tmpfs 
large folios, but we also need to consider how to avoid regression if 
the 'huge=always/within_size' mount option is set.

> So no real opinion, it all doesn't feel ideal ... at least with his 
> approach here we would stick more to the old tmpfs behavior.


  parent reply	other threads:[~2025-07-31  2:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-30  8:14 [RFC PATCH] mm: shmem: fix the strategy for the tmpfs 'huge=' options Baolin Wang
2025-07-30  9:30 ` David Hildenbrand
2025-07-30 15:23   ` Lorenzo Stoakes
2025-07-31  2:41   ` Baolin Wang [this message]
2025-07-30 15:17 ` Lorenzo Stoakes
2025-07-31  2:57   ` Baolin Wang
2025-08-12  8:35 ` Baolin Wang
2025-08-13  6:59   ` Hugh Dickins
2025-08-14 10:03     ` Baolin Wang

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=78c0f8ba-7e71-41da-9ac8-bcd26717dc71@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=ryan.roberts@arm.com \
    --cc=willy@infradead.org \
    --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).