linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Hugh Dickins <hughd@google.com>
Cc: "David Hildenbrand" <david@redhat.com>,
	"Patryk Kowalczyk" <patryk@kowalczyk.ws>,
	da.gomez@samsung.com, baohua@kernel.org,
	wangkefeng.wang@huawei.com, ioworker0@gmail.com,
	willy@infradead.org, ryan.roberts@arm.com,
	akpm@linux-foundation.org, eero.t.tamminen@intel.com,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: regression - mm: shmem: add large folio support for tmpfs affect GPU performance.
Date: Fri, 25 Jul 2025 14:05:13 +0800	[thread overview]
Message-ID: <0c9dc2fa-34c9-4db5-bea3-af4caf05ee6b@linux.alibaba.com> (raw)
In-Reply-To: <dab283bf-a9cf-30be-02ed-da0d7c8ffcf0@google.com>



On 2025/7/25 12:47, Hugh Dickins wrote:
> On Fri, 25 Jul 2025, Baolin Wang wrote:
>>>
>>> I hope to correct the logic of i915 driver's shmem allocation, by extending
>>> the shmem write length in the i915 driver to allocate PMD- sized THPs. IIUC,
>>> some sample fix code is as follows (untested). Patryk, could you help test
>>> it to see if this resolves your issue? Thanks.
> 
> This patch cannot be the right fix.  It may be a very sensible workaround
> for some in-kernel drivers (I've not looked or tried); but unless I
> misunderstand, it does nothing to restore userspace behaviour on a
> huge=always tmpfs.

Yes. Initially, we wanted to maintain compatibility with the 'huge=' 
option, meaning that 'huge=always' tmpfs mount would still allocate 
PMD-sized THPs. However, the current implementation is the consensus we 
reached after much debate:

1. “When using tmpfs as a filesystem, it should behave like other 
filesystems. No more special mount options.” Per Matthew.
2. “Do not let the 'huge=' mount option mean 'PMD-sized' when other 
sizes exist.” Per David.

At the time, we should have sought your advice, but we failed. The long 
historical discussion is in this thread[1]. So now the strategy for 
tmpfs supporting large folios is:

"
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 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 large 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.
"

Currently, we have observed regression in the i915 driver but have not 
yet seen userspace regression on a huge=always tmpfs.

If you have better suggestions, please feel free to point them out. Thanks.

[1] https://lore.kernel.org/lkml/Zw_IT136rxW_KuhU@casper.infradead.org/

> Please reread my comment earlier in the thread, in particular,
> Passing a new SIGBUS xfstest does not excuse a regression: strict PAGE_SIZE
> SIGBUS behaviour is fine for the newly-featured mTHPs or large folios,
> but not for the long-established huge=always.



  reply	other threads:[~2025-07-25  6:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAJCW39JCDX6_S2Ojt1HMmX-h_qAKm2eBRzxX5kOHNJz60Zu=vw@mail.gmail.com>
     [not found] ` <d5c6ac93-1af0-4093-afea-94a29a387903@redhat.com>
     [not found]   ` <63b69425-2fd1-2c77-06d6-e7ea25c92f34@google.com>
     [not found]     ` <3f204974-26c8-4d5f-b7ae-4052cbfdf4ac@redhat.com>
     [not found]       ` <a8ac7ec3-4cb3-4dd8-8d02-ede6905f322e@linux.alibaba.com>
2025-07-25  2:38         ` Baolin Wang
2025-07-25  4:47           ` Hugh Dickins
2025-07-25  6:05             ` Baolin Wang [this message]
2025-07-25  8:36               ` Patryk Kowalczyk
2025-07-25  9:17                 ` Baolin Wang
2025-07-28  5:35               ` Hugh Dickins
2025-07-28  6:29                 ` 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=0c9dc2fa-34c9-4db5-bea3-af4caf05ee6b@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=da.gomez@samsung.com \
    --cc=david@redhat.com \
    --cc=eero.t.tamminen@intel.com \
    --cc=hughd@google.com \
    --cc=ioworker0@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=patryk@kowalczyk.ws \
    --cc=ryan.roberts@arm.com \
    --cc=ville.syrjala@linux.intel.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    /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