linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linuxfoundation.org>
To: Pedro Falcato <pfalcato@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Gladyshev Ilya <gladyshev.ilya1@h-partners.com>,
	David Hildenbrand <david@kernel.org>,
	 Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	"Liam R . Howlett" <Liam.Howlett@oracle.com>,
	 Vlastimil Babka <vbabka@suse.cz>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	 Michal Hocko <mhocko@suse.com>, Zi Yan <ziy@nvidia.com>,
	Harry Yoo <harry.yoo@oracle.com>,
	 Matthew Wilcox <willy@infradead.org>,
	Yu Zhao <yuzhao@google.com>,
	 Baolin Wang <baolin.wang@linux.alibaba.com>,
	Alistair Popple <apopple@nvidia.com>,
	 Gorbunov Ivan <gorbunov.ivan@h-partners.com>,
	Muchun Song <muchun.song@linux.dev>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	Kiryl Shutsemau <kirill@shutemov.name>,
	 Dave Chinner <david@fromorbit.com>
Subject: Re: [PATCH 0/1] mm: improve folio refcount scalability
Date: Wed, 4 Mar 2026 09:34:52 -0800	[thread overview]
Message-ID: <CAHk-=whc7ne30jPpe=FFECg4OBUAqEqzQUXJ+vdb8NyYDW1anA@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=whWnAqw+2YZ=LHs5C6ecGSLqgi+DxtJJ_p06rZsnosVKA@mail.gmail.com>

On Sun, 1 Mar 2026 at 13:16, Linus Torvalds
<torvalds@linuxfoundation.org> wrote:
>
> Ho humm. Maybe that "locked" flag is the best we can do.

Coming back to this after having spent a few days mulling it all.

End result: I do think that the locked bit is the right solution, and
you can add my "Acked-by" to the series.

I do have a couple of requests (the ack is not conditional on these,
but having looked at the patch it's what my reactions were):

 (a) please rename "page_ref_add_unless_zero()" and friends, since
that's not what they do any more. Now it is
"page_ref_add_unless_locked()"

 (b) verify and add a comment somewhere that the PAGEREF_LOCKED_BIT on
a free'd folio is never removed until the page ref is set to 1 by the
next allocation by set_pages_refcounted()

I'm asking for that (b) because if it is ever set back to zero, this
all fails, because the fixup for the atomic_add_return() might do a
atomic_dec() - if it never saw the PAGEREF_LOCKED_BIT - and free a
page twice after all.

(And if I missed some reason why (b) isn't true, please holler).

Anyway, I like it. My initial reaction was that it was complicated,
but in the end I think that was just because it was done a bit
differently from what I was used to in how we did the DEAD flag for
dentries, but I think this is actually the better model (*).

                   Linus

(*) For dentries we use that lockref thing which has its own
complications with the spinlock acting as the lock bit for the
refcount, and it uses the cmpxchg loop to synchronize things because
it wants that lock to be absolute. But I think the page count approach
is actually better in being more flexible.


      reply	other threads:[~2026-03-04 17:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26 16:27 Gladyshev Ilya
2026-02-26 16:27 ` [PATCH 1/1] mm: implement page refcount locking via dedicated bit Gladyshev Ilya
2026-03-04 19:16   ` David Hildenbrand (Arm)
2026-02-28 22:19 ` [PATCH 0/1] mm: improve folio refcount scalability Andrew Morton
2026-03-01  3:27   ` Linus Torvalds
2026-03-01 18:52     ` Linus Torvalds
2026-03-01 20:26       ` Pedro Falcato
2026-03-01 21:16         ` Linus Torvalds
2026-03-04 17:34           ` Linus Torvalds [this message]

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='CAHk-=whc7ne30jPpe=FFECg4OBUAqEqzQUXJ+vdb8NyYDW1anA@mail.gmail.com' \
    --to=torvalds@linuxfoundation.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=david@fromorbit.com \
    --cc=david@kernel.org \
    --cc=gladyshev.ilya1@h-partners.com \
    --cc=gorbunov.ivan@h-partners.com \
    --cc=harry.yoo@oracle.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=vbabka@suse.cz \
    --cc=willy@infradead.org \
    --cc=yuzhao@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