From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Kiryl Shutsemau <kas@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>, Jan Kara <jack@suse.cz>,
Hugh Dickins <hughd@google.com>,
Christian Brauner <brauner@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Harry Yoo <harry@kernel.org>, Miklos Szeredi <miklos@szeredi.hu>,
Miaohe Lin <linmiaohe@huawei.com>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
Oscar Salvador <osalvador@suse.de>,
"Liam R. Howlett" <liam@infradead.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <brendan.jackman@linux.dev>,
Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Nico Pache <nico.pache@linux.dev>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Usama Arif <usama.arif@linux.dev>,
Kairui Song <kasong@tencent.com>, Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
Baoquan He <baoquan.he@linux.dev>,
"Paul E. McKenney" <paulmck@kernel.org>,
Pedro Falcato <pfalcato@suse.de>,
Luis Chamberlain <mcgrof@kernel.org>,
Ilya Gladyshev <ilya.gladyshev@linux.dev>,
Jaegeuk Kim <jaegeuk@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, fuse-devel@lists.linux.dev,
kernel-team@meta.com
Subject: Re: [RFC PATCH v2 01/18] mm: free PG_rcu_free folios only after an RCU grace period
Date: Wed, 11 Nov 2026 11:03:38 +0100 [thread overview]
Message-ID: <f39a0ec3-be81-43f0-91e8-145ec139b1bc@kernel.org> (raw)
In-Reply-To: <CAHk-=wihE=ioLKrwzz=WQSJg6HhB-syu4hqZ2QFwgnwYmmLEgg@mail.gmail.com>
On 11/9/26 19:01, Linus Torvalds wrote:
> On Mon, 9 Nov 2026 at 09:24, David Hildenbrand (Arm) <david@kernel.org> wrote:
>>>
>>> I think trying to corral it into some special case is the last thing
>>> we want to do. It only makes things less potentially useful and more
>>> fragile.
>> Let me wrap my head around how this would look when we decouple pages from
>> folios, where pages might not have a ->lru anymore, or not even a refcount.
>
> So for an example of a place that already does RCU freeing of pages -
> *not* folios - look at the TLB shootdown.
Yes, I am well aware of that handling. Unfortunately. :)
>
> It's very round-about and hard to tell, but it's using
>
> tlb_remove_table_free
> call_rcu(&batch->rcu, tlb_remove_table_rcu);
>
> and that then does
>
> tlb_remove_table_rcu ->
> __tlb_remove_table_free ->
> __tlb_remove_table ->
> pagetable_dtor_free ->
> pagetable_free ->
> __pagetable_free ->
> __free_pages(page, compound_order(page))
>
> (and I might have messed this up - this really is a rats nest of
> nested inline functions).
>
> And in order to do this all, it sets up *another* page just to contain
> the batching (which is also RCU-free'd)
Yeah, I recall some details about ->lru not being usable (as reused for other
purposes by some architectures) and some things about multiple page tables
residing in a single physical page on some architectures (at least powerpc),
which makes using ptdesc / ->lru impossible as well, as we might only be freeing
parts of a page instead of full pages.
And some page tables today might already be allocated from slab (I think at
least sparc64 and m68k do that).
So that's one of the reason why tlb_remove_table() consumes a void * pointer
instead of a page/ptdesc pointer. It's all linked to
CONFIG_HAVE_ARCH_TLB_REMOVE_TABLE IIRC.
>
> Now, the batching is probably a very good thing in that context, so
> I'm not actually suggesting this should be converted to some common
> RCU-freeing thing.
>
> Rather, I'm pointing out that we have existing hacks in this area that
> have grown up over time and would have been a *lot* less hacky if we
> had had a proper RCU-freeing page allocator back when that whole TLB
> freeing code was written.
See, I am not sure about that given the challenge with
CONFIG_HAVE_ARCH_TLB_REMOVE_TABLE. And apparently powerpc is using that, which
is not quite the museum piece (compared to m68k and sparc64 :) )
In a perfect world without these corner cases that make our life hard, possibly.
>
> So I'm not saying "we should unify this". But I *am* saying "look, RCU
> freeing of pages is _already_ a thing, and we have complicated hacky
> things in place for it".
>
> And they are complicated not because they necessarily should be
> complicated, but because we solved the TLB shootdown after we already
> had tons of complex architecture-specific code in place, and we
> basically ended up adding that RCU phase on top of that existing
> per-architecture complexity and abstraction.
Jup.
>
> *NOW* it would be actually fairly painful to try to convert the TLB
> shootdown to a new order. But originally, it would have been very nice
> if we had just had a "Oh, mark this page for RCU freeing".
>
> (In all fairness, we also did it that way because some architectures
> don't need the RCU delay simply because they have some other hardware
> page walking infrastructure than the actual page tables the kernel
> builds up. Not that those architectures *matter* today, but some of
> that per-architecture inline function stuff is required to basically
> isolate these kinds of decisions from the MM code - that deep inline
> function indirection has a reason that is entirely independent of the
> freeing side).
There are some dirty details when it comes to the upcoming page vs. folio split
that I am still unclear about.
The page table example you mention above is another prime example of the
challenges we'll face: page tables will have a separately allocated memdesc
("ptdesc"), just like folios will have their memdesc ("folio") separately allocated.
When RCU freeing, we'll really have to keep the allocated memdesc alive as well.
RCU-freeing the page only is not sufficient.
There was even talk about allocating page tables from slab later, as long as we
can adjust a "struct ptdesc" to it. Which would solve the problem of powerpc
etc. that don't operate on full pages for page tables.
So I might be completely off, but what I imagine is that the memdescs will get
RCU-freed (these are not pages), and once they are then getting freed, they will
probably take the physical page with them.
And freeing memdescs through RCU will likely be memdesc specific.
I really don't know, Willy might know more about these plans.
But I am overloaded with all the Fixes, so my brain doesn't work quite right.
--
Cheers,
David
next prev parent reply other threads:[~2026-11-11 10:03 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 13:00 [RFC PATCH v2 00/18] mm: read the page cache without folio references Kiryl Shutsemau (Meta)
2026-11-04 13:00 ` [RFC PATCH v2 01/18] mm: free PG_rcu_free folios only after an RCU grace period Kiryl Shutsemau (Meta)
2026-11-05 20:37 ` David Hildenbrand (Arm)
2026-11-06 10:23 ` Kiryl Shutsemau
2026-11-09 14:42 ` David Hildenbrand (Arm)
2026-11-09 15:56 ` Linus Torvalds
2026-11-09 17:23 ` David Hildenbrand (Arm)
2026-11-09 18:01 ` Linus Torvalds
2026-11-11 10:03 ` David Hildenbrand (Arm) [this message]
2026-11-04 13:00 ` [RFC PATCH v2 02/18] splice: don't steal page cache folios Kiryl Shutsemau (Meta)
2026-11-04 16:05 ` David Hildenbrand (Arm)
2026-11-05 14:55 ` Kiryl Shutsemau
2026-11-04 13:00 ` [RFC PATCH v2 03/18] fuse: don't move a folio with PG_rcu_free into a fuse file Kiryl Shutsemau (Meta)
2026-11-09 14:46 ` David Hildenbrand (Arm)
2026-11-09 16:28 ` Linus Torvalds
2026-11-09 16:35 ` Linus Torvalds
2026-11-09 17:48 ` David Hildenbrand (Arm)
2026-11-10 13:58 ` Kiryl Shutsemau
2026-11-04 13:01 ` [RFC PATCH v2 04/18] mm: count the pages waiting for a grace period Kiryl Shutsemau (Meta)
2026-11-09 14:48 ` David Hildenbrand (Arm)
2026-11-04 13:01 ` [RFC PATCH v2 05/18] mm: expedite the grace period when a CPU has many deferred frees Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 06/18] mm: free the pages waiting for a grace period before OOM Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 07/18] mm: free the pages waiting for a grace period before isolation fails Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 08/18] mm/compaction: free the migrated folios that wait for a grace period Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 09/18] mm/memory-failure: handle folios with PG_rcu_free Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 10/18] mm: have folio_mark_accessed() return whether the folio is hot Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 11/18] mm/filemap: mark a folio accessed in one place in filemap_read() Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 12/18] mm/filemap: set PG_rcu_free on the folios that reads keep coming back to Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 13/18] mm/filemap: read from the page cache without folio references Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 14/18] mm/filemap: read large folios " Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 15/18] mm/filemap: don't store f_ra.prev_pos for FMODE_RANDOM files Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 16/18] mm/shmem: count accesses to a folio the way filemap_read() does Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 17/18] mm/shmem: read without folio references Kiryl Shutsemau (Meta)
2026-11-04 13:01 ` [RFC PATCH v2 18/18] mm/filemap: add a debugfs switch for lockless page cache reads Kiryl Shutsemau (Meta)
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=f39a0ec3-be81-43f0-91e8-145ec139b1bc@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=brauner@kernel.org \
--cc=brendan.jackman@linux.dev \
--cc=dev.jain@arm.com \
--cc=fuse-devel@lists.linux.dev \
--cc=hannes@cmpxchg.org \
--cc=harry@kernel.org \
--cc=hughd@google.com \
--cc=ilya.gladyshev@linux.dev \
--cc=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--cc=kas@kernel.org \
--cc=kasong@tencent.com \
--cc=kernel-team@meta.com \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mcgrof@kernel.org \
--cc=mhocko@suse.com \
--cc=miklos@szeredi.hu \
--cc=nao.horiguchi@gmail.com \
--cc=nico.pache@linux.dev \
--cc=osalvador@suse.de \
--cc=paulmck@kernel.org \
--cc=pfalcato@suse.de \
--cc=qi.zheng@linux.dev \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=torvalds@linux-foundation.org \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=weixugc@google.com \
--cc=willy@infradead.org \
--cc=yuanchu@google.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
all inboxes | Powered by JetHome®