From: Zi Yan <ziy@nvidia.com>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
"David Hildenbrand (Arm)" <david@kernel.org>,
Matthew Brost <matthew.brost@intel.com>
Cc: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Christian Koenig <christian.koenig@amd.com>,
Huang Rui <ray.huang@amd.com>,
Matthew Auld <matthew.auld@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <liam@infradead.org>,
Nico Pache <npache@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
Dave Airlie <airlied@redhat.com>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH 1/3] mm/huge_memory: add folio_split_driver_managed()
Date: Tue, 28 Jul 2026 11:52:19 -0400 [thread overview]
Message-ID: <00499B8B-F546-4A4E-84A6-126BAE5BC239@nvidia.com> (raw)
In-Reply-To: <ami_wF2QhQ1ZM6-f@lucifer>
On 28 Jul 2026, at 10:44, Lorenzo Stoakes (ARM) wrote:
> On Tue, Jul 28, 2026 at 02:58:39PM +0200, David Hildenbrand (Arm) wrote:
>> On 7/27/26 20:23, Zi Yan wrote:
>>> On 27 Jul 2026, at 13:33, David Hildenbrand (Arm) wrote:
>>>
>>>> On 7/22/26 17:28, Zi Yan wrote:
>>>>>
>>>>> Strickly speaking, these vm_insert*() compound pages are not folios,
>>>>> since folios are supposed to be rmappable and they are either anonymous
>>>>> memory or file-backed memory. I am working on separating them from
>>>>> rmappable folios by replacing PG_private with PG_folio and marking all
>>>>> pages in a folio with PG_folio in page_rmappable_folio().
>>>>>
>>>>> Hopefully, we can find a better name, like refcounted_folio, later for
>>>>> these non-rmappable compound pages.
>>>>
>>>> They wouldn't really be folios, I guess. They would likely be a simple
>>>> "refcounted" memtype that allows for compound pages.
>>>
>>> Yes, they are not folios. But “folio” was started to replace “compound page”
>>> and slowly becomes rmappable anon and file-backed. People outside MM still
>>> thinks “folio” == “compound page”.
>>
>> Yes, it's a bit of a mess now.
>>
>>> But once I manage to remove PG_private
>>> and get us PG_folio, page_folio() will return NULL for non-folio compound
>>> pages and we will need a new type for them, “refcounted_XXX”. We can decide
>>> XXX when I get there. :)
>>
>> So far willy did not document a type that just has a refcount.
>>
>> https://kernelnewbies.org/MatthewWilcox/Memdescs
>
> I was going to say.
>
> It seems a bit specific, because different things might have a different use for
> 'pages with refcounts that shouldn't be touched by core mm' and different
> semantics perhaps.
>
> Obviously if it was a different memdesc type then it'd not be a folio.
Yes, this part is easy. Slab uses GFP_COMP and no one regards large slab pages
as folios. The confusion comes from large pages without a page_type.
>
>>
>> Maybe "Managed memory" (struct mgdesc) could be the right thing for some memory
>> with a refcount.
For driver allocated memory, probably yes. I also see allocations listed below
with GFP_KERNEL_ACCOUNT | __GFP_COMP, so AcctMem would also be a candidate.
1. arch/s390/kvm/dat.c
2. io_uring/memmap.c
3. drivers/dma-buf/heaps/system_heap.c when mem_accounting is enabled.
>>
>> The question is, if the use case at hand would even require a refcount, of if
>> frozen pages would be good enough.
I hope so and that could simplify our work without handling refcount. But I assume
user outside MM would still want a refcount to do the page life time management
work, otherwise they might need to build their own one(s).
>>
>>>
>>>>
>>>> But what is the conclusion here? It sounds like "folio_split_" is the entirely
>>>> wrong interface for these compound pages.
>
> Yeah the thing is we need some clarification on what is a folio exactly.
>
> A folio is a physically, virtually and logically contiguous set of
> bytes. It is a power-of-two in size, and it is aligned to that same
> power-of-two. It is at least as large as %PAGE_SIZE. If it is in the
> page cache, it is at a file offset which is a multiple of that
> power-of-two. It may be mapped into userspace at an address which is at
> an arbitrary page offset, but its kernel virtual address is aligned to
> its size.
>
> By that definition a compound page _is_ a folio. And anything that _could_ be
> mapped into userland.
>
> But if we are going to say folio == rmappable then can we actually update the
> description of folio to say so?
>
> Or perhaps reference the fact that 'transitionally' it is as above, but in
> future will mean only rmappable.
I can come up with a patch clarifying the comment.
>
>>>
>>> We probably would allow folio_split() to be used on compound pages now
>>> until we can make a clean distinction, e.g., using PG_folio, between them.
>>>
>>> Yes, folio_split() and its helper functions are meant for rmappable anon and
>>> file-backed folios. But currently “folio” is de facto “compound page”, since
>>> for example prep_compound_head() initializes folio fields even if it is meant
>>> only for compound pages.
>>
>> If we can stop more abuse right from the start, that would be nice.
>
> Yes.
>
>>
>> We do have split_page() that splits a non-compound higher-order page. Maybe we
>> want a split_compound_page(), or allow for split_page() to accept compound pages.
>
> Ha! I read this after making this very same suggestion. High.. 5?
>
> But yeah obviously agree.
>
>>
>> Because splitting a folio is really something different than splitting just some
>> compound page (no mapping/pagecache/whatever involved).
>
> Yup.
It sounds like split_compound_page() gets some love (David, Lorenzo, and Matthew
all want it). I can add one to mm/page_alloc.c, so that Matthew can build
his patchset on top of it.
Best Regards,
Yan, Zi
next prev parent reply other threads:[~2026-07-28 15:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 4:42 Matthew Brost
2026-07-22 4:42 ` [PATCH 2/3] drm/xe: select TRANSPARENT_HUGEPAGE Matthew Brost
2026-07-22 4:42 ` [PATCH 3/3] drm/ttm: allocate pool pages as compound (__GFP_COMP) Matthew Brost
2026-08-03 13:54 ` Christian König
2026-08-03 18:47 ` Matthew Brost
2026-07-22 14:26 ` [PATCH 1/3] mm/huge_memory: add folio_split_driver_managed() Zi Yan
2026-07-22 15:28 ` Zi Yan
2026-07-27 17:33 ` David Hildenbrand (Arm)
2026-07-27 18:23 ` Zi Yan
2026-07-27 20:34 ` Matthew Brost
2026-07-28 12:58 ` David Hildenbrand (Arm)
2026-07-28 14:44 ` Lorenzo Stoakes (ARM)
2026-07-28 15:52 ` Zi Yan [this message]
2026-07-28 19:01 ` David Hildenbrand (Arm)
2026-07-28 14:40 ` Lorenzo Stoakes (ARM)
2026-07-28 14:46 ` Lorenzo Stoakes (ARM)
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=00499B8B-F546-4A4E-84A6-126BAE5BC239@nvidia.com \
--to=ziy@nvidia.com \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=christian.koenig@amd.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=npache@redhat.com \
--cc=ray.huang@amd.com \
--cc=ryan.roberts@arm.com \
--cc=simona@ffwll.ch \
--cc=tvrtko.ursulin@igalia.com \
--cc=tzimmermann@suse.de \
--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
all inboxes | Powered by JetHome®