From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Waiman Long <longman@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Boqun Feng <boqun@kernel.org>, Nick Terrell <terrelln@fb.com>,
David Sterba <dsterba@suse.com>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
linux-kernel@vger.kernel.org,
"David Hildenbrand (Arm)" <david@kernel.org>,
llvm@lists.linux.dev
Subject: Re: [PATCH v2] locking/rwsem: don't let readers retain the lock past a queued writer
Date: Thu, 3 Dec 2026 19:22:50 +0000 [thread overview]
Message-ID: <axG_WVPrnvd-Elfv@gremlin> (raw)
In-Reply-To: <bfc87291-52d0-47ae-8cf8-9a28b636a2ad@redhat.com>
On Tue, Dec 01, 2026 at 11:27:59AM -0500, Waiman Long wrote:
> On 11/26/26 5:14 PM, Lorenzo Stoakes (ARM) wrote:
> > This still permits reader stealing if a writer last held the lock, as
> > failing to do so can starve readers in favour of writers. This maintains
> > fairness.
> Yes, I like this idea of maintaining some fairness.
Thanks :)
Yeah the numbers showed that this was a good idea.
> > Writer latency (microbenchmark, bare metal, p99)
> > ------------------------------------------------
> > readers base patched
> > 2 3813 us 17 us
> > 4 3868 us 29 us
> > 16 5369 us 4008 us (within expected stddev)
> > 62 4612 us 3835 us (ditto)
> > 2, one CCD 3865 us 17 us
> > 7, one CCD 3951 us 35 us
> >
> > Writer throughput +35-54% at 2 and 4 readers and in both one-CCD cases.
> > Reader steals in this test: 4.8M -> 8.
> Just to confirm if the reader steals had dropped from 4.8M to just 8. That
> is really low. What is the test duration?
Yeah this is accurate :)
Each test run is 7 runs of 5 seconds each, with:
* one writer calling mprotect() on a single page ever 1ms
* vs. [1,2,4,16,62,2^,7^] readers looping madvise(MADV_POPULATE_READ) over 64 pages.
^ = pinned to one CCD
So basically contrived to be the case this change is addressing.
So either the writer holds the lock or is at the head of the queue of a
reader-owned rwsem, thus won't steal.
Stats were:
base patched
rlock_steal 4809477 8
sleep_writer 4408523 22979
wake_writer 4823875 46499
wlock 17385 22926
rlock 229735 249025
So this is basically 'does this change do what we need' and yes :)
And as per the bench results there's no impact elsewhere.
> Other than a question about the drop in reader stealing count, the patch
> looks reasonable to me and the benchmark results look good too.
>
> Reviewed-by: Waiman Long <longman@redhat.com>
Great thanks! :)
--
Cheers, Lorenzo
prev parent reply other threads:[~2026-12-03 19:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 22:14 [PATCH v2] locking/rwsem: don't let readers retain the lock past a queued writer Lorenzo Stoakes (ARM)
2026-12-01 16:27 ` Waiman Long
2026-12-03 19:22 ` Lorenzo Stoakes (ARM) [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=axG_WVPrnvd-Elfv@gremlin \
--to=ljs@kernel.org \
--cc=boqun@kernel.org \
--cc=david@kernel.org \
--cc=dsterba@suse.com \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=terrelln@fb.com \
--cc=will@kernel.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