From: Kiryl Shutsemau <kirill@shutemov.name>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>,
Ilya Gladyshev <ilya.gladyshev@linux.dev>,
Matthew Wilcox <willy@infradead.org>,
Lorenzo Stoakes <ljs@kernel.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>,
"Paul E. McKenney" <paulmck@kernel.org>
Subject: Re: Improve page refcount scalability
Date: Fri, 16 Oct 2026 15:40:12 +0100 [thread overview]
Message-ID: <atI0edrmeiRuRtNQ@thinkstation> (raw)
In-Reply-To: <CAHk-=wjLjgfwgSZ1RDk4YdNFcV0ntosMO5AmBoHD76Zb3HFY7Q@mail.gmail.com>
On Tue, Oct 13, 2026 at 11:43:14AM -0700, Linus Torvalds wrote:
> Comments?
There's a regression: the lockless read loses on large reads from large
folios.
In a 64-vCPU guest on a Threadripper 7975WX, 1 MiB reads of a cached
ext4 file are 9% slower from one thread with rcu-free-v3 than without
it, 64K reads 4% slower.
The reference path looks a large folio up once and copies it in one go.
The lockless one walks i_pages from the root and calls
copy_page_to_iter() for every 4K page.
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.
if (folio != prev) {
if (!filemap_read_rcu_can_copy(folio, index, *last_index))
break;
/* Many pages of a large folio: one reference is cheaper */
if (folio_test_large(folio) &&
min_t(unsigned long, folio_next_index(folio) - index,
DIV_ROUND_UP(offset + iov_iter_count(iter),
PAGE_SIZE)) > 4)
break;
prev = folio;
}
With it, ext4 1 MiB reads match base and 64K reads are within 2%. Small
reads do not change. The cut is on the folio, not on the read size, so
files in 4K folios keep the gain on large reads: 1 MiB tmpfs reads from
one thread are ~30% faster than base.
Sounds reasonable?
I've pushed my tree here:
https://git.kernel.org/pub/scm/linux/kernel/git/kas/linux.git rcu-free/rfc-v1
I'm thinking of posting it as an RFC to make it easier to review.
Objections?
--
Kiryl Shutsemau / Kirill A. Shutemov
next prev parent reply other threads:[~2026-10-16 14:40 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 18:43 Improve page refcount scalability Linus Torvalds
2026-10-13 21:03 ` Matthew Wilcox
2026-10-13 21:26 ` Linus Torvalds
2026-10-13 23:20 ` Paul E. McKenney
2026-10-14 10:36 ` Kiryl Shutsemau
2026-10-14 10:46 ` David Hildenbrand (Arm)
2026-10-13 22:43 ` Kiryl Shutsemau
2026-10-13 23:39 ` Linus Torvalds
2026-10-14 11:53 ` Kiryl Shutsemau
2026-10-14 15:28 ` Matthew Wilcox
2026-10-14 0:10 ` Harry Yoo
2026-10-14 1:01 ` Linus Torvalds
2026-10-14 13:59 ` Pedro Falcato
2026-10-14 16:25 ` Linus Torvalds
2026-10-14 16:59 ` Linus Torvalds
2026-10-14 17:15 ` Linus Torvalds
2026-10-14 17:43 ` Kirill A. Shutemov
2026-10-14 18:24 ` Linus Torvalds
2026-10-15 2:12 ` Jaegeuk Kim
2026-10-16 14:43 ` Kiryl Shutsemau
2026-10-16 15:41 ` Jaegeuk Kim
2026-10-16 14:40 ` Kiryl Shutsemau [this message]
2026-10-16 14:47 ` Linus Torvalds
2026-10-16 15:14 ` 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=atI0edrmeiRuRtNQ@thinkstation \
--to=kirill@shutemov.name \
--cc=david@kernel.org \
--cc=ilya.gladyshev@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mcgrof@kernel.org \
--cc=paulmck@kernel.org \
--cc=torvalds@linux-foundation.org \
--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