All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zi Yan" <ziy@nvidia.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
	<ilya.gladyshev@linux.dev>,
	"Andrew Morton" <akpm@linux-foundation.org>
Cc: <ivgorbunov@me.com>, <Liam.Howlett@oracle.com>,
	<apopple@nvidia.com>, <artem.kuzin@huawei.com>,
	<baolin.wang@linux.alibaba.com>, <foxido@foxido.dev>,
	<harry.yoo@oracle.com>, <linux-kernel@vger.kernel.org>,
	<linux-mm@kvack.org>, <lorenzo.stoakes@oracle.com>,
	<mhocko@suse.com>, <muchun.song@linux.dev>, <rppt@kernel.org>,
	<surenb@google.com>, <torvalds@linuxfoundation.org>,
	<vbabka@suse.cz>, <willy@infradead.org>, <yuzhao@google.com>,
	<pfalcato@suse.de>, <kirill@shutemov.name>
Subject: Re: [PATCH v4 0/2] mm: improve folio refcount scalability
Date: Tue, 08 Sep 2026 16:18:13 -0400	[thread overview]
Message-ID: <DLA7NUL95SKS.GFI7EC61O3WL@nvidia.com> (raw)
In-Reply-To: <6d576c2a-af34-493c-bccb-cf2e035e6506@kernel.org>

On Mon Jun 22, 2026 at 3:55 AM EDT, David Hildenbrand (Arm) wrote:
> On 6/21/26 03:40, Zi Yan wrote:
>> On Sat Jun 20, 2026 at 2:19 PM EDT,  wrote:
>>>>
>>>> Thanks. Nice numbers.
>>>>
>>>> AI review had some things to say:
>>>>  https://sashiko.dev/#/patchset/df26082871b4c65b2bd38d409026237c08572836@linux.dev
>>>

<snip>

>
>> 
>> For your patch, is it because of the separation of refcount-0 and
>> frozen? The page goes refcount-0 before it is frozen? 
>
> Exactly that. Refcount 0 is only transitional.
>
>> Will it work if
>> the page is frozen first then gets its refcount to 0? Basically, the
>> frozen state prevents anyone else messing up with your refcount.
>> 
>
> Let me comment the original sequence:
>
<snip>

>
> T1: BUG: calls dtor of type X on page of type Y
>

Since Ilya restarted working on this[1], I would like to get this issue
sorted out first.

[1] https://lore.kernel.org/all/85b0e3c5f328e2c3779fda986fa19530ae9c77d5@linux.dev/

>
> I am confused about the "dtor of type X vs. type Y". We have the page in our
> hand, once we won (2) we can lookup the type and do the right thing.
>
>
> I guess the interesting part is where the destructor is called from the outside:
>
> static inline void folio_put(struct folio *folio)
> {
> 	if (folio_put_testzero(folio))
> 		__folio_put(folio);
> }
>
> Where we keep operating on it as if it were a folio, although it might now be a
> non-folio thing.
>
> So if T1 is doing a folio_put(), we'd call into page_cache_release() etc with
> a non-folio thing.

Right.

>
> But IIUC, that can happen today already when we do
> folio_try_get(folio)+folio_put(folio) and it wasn't a folio in the first place?

Yes, it can happen today. But it is safe, because 1) __folio_put() can
handle non-folios, 2) page_frag_free() will not see a folio as it
holds a reference to the page. It is an important asymmetry.

After the patchset, both can see a changing page type. This means we
will need a generic page/folio free function to avoid calling the wrong
page dtor. In addition, when a to-be-put page is freed and reallocated
by another thread, its order can change. I am not sure how a generic
free function can handle it. For folios and compound pages, the order is
stored in struct folio/struct page. But some users allocate high-order
non-compound pages (not passing __GFP_COMP), so only the owner knows the
exact page order. Unless we convert all of them to use __GFP_COMP (we
will do that on the way to memdesc).

This issue needs to be sorted out first.

>
> I'd assume that will all change once the refcount moves into
> separately-allocated "struct folios".




-- 
Best Regards,
Yan, Zi



  reply	other threads:[~2026-09-08 20:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 21:53 [PATCH v4 0/2] mm: improve folio refcount scalability Gladyshev Ilya
2026-06-08 21:54 ` [PATCH v4 1/2] mm: drop page refcount zero state semantics ilya.gladyshev
2026-06-08 21:54 ` [PATCH v4 2/2] mm: implement page refcount locking via dedicated bit Gladyshev Ilya
2026-06-08 22:47 ` [PATCH v4 0/2] mm: improve folio refcount scalability Andrew Morton
2026-06-09 10:28   ` David Hildenbrand (Arm)
2026-06-09 19:02   ` Gladyshev Ilya
2026-06-09 21:02     ` Pedro Falcato
2026-06-20 18:19   ` ilya.gladyshev
2026-06-21  1:40     ` Zi Yan
2026-06-22  7:55       ` David Hildenbrand (Arm)
2026-09-08 20:18         ` Zi Yan [this message]
2026-06-21  4:46     ` Linus Torvalds
2026-06-21 21:34       ` Gladyshev Ilya
2026-06-21 21:50         ` Matthew Wilcox
2026-06-23 21:23           ` Ilya Gladyshev
2026-06-24 10:24             ` David Hildenbrand (Arm)
2026-06-21 22:53         ` Linus Torvalds
2026-06-22  8:15       ` David Hildenbrand (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=DLA7NUL95SKS.GFI7EC61O3WL@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=artem.kuzin@huawei.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@kernel.org \
    --cc=foxido@foxido.dev \
    --cc=harry.yoo@oracle.com \
    --cc=ilya.gladyshev@linux.dev \
    --cc=ivgorbunov@me.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=pfalcato@suse.de \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=torvalds@linuxfoundation.org \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.org \
    --cc=yuzhao@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.