Re: Improve page refcount scalability

From: Kiryl Shutsemau

Date: Mon Oct 19 2026 - 12:56:22 EST


On Fri, Oct 16, 2026 at 07:47:48AM -0700, Linus Torvalds wrote:
> On Fri, 16 Oct 2026 at 07:40, Kiryl Shutsemau <kirill@xxxxxxxxxxxxx> wrote:
> >
> > I've added a cutoff to the lockless path: if the folio is large and the
> > read covers more than four of its pages, leave it to the slow path,
> > where one reference covers all of them.
> >
> > Sounds reasonable?
>
> Sounds eminently reasonable to me.

I realized that we don't need to re-lookup the large folio in the xarray
for each index it covers: a large folio is all-or-nothing. If we found it
at one index, it is at all the indexes the folio covers. But we need
*one* more xas_load() per large folio, for the last page we copy: the
folio's size cannot be trusted without a reference, and finding the
folio in that slot proves the range is still its own.

So I dropped the cutoff. 64K reads of one hot folio from 64 threads go
from ~93k to ~1.37M MiB/s on huge tmpfs and from ~572k to ~1.36M MiB/s
on ext4: the cutoff sent them to the slow path. Single-thread large
reads stay at base.

--
Kiryl Shutsemau / Kirill A. Shutemov