From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: Peng Huang <penghuang@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Boqun Feng <boqun@kernel.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Waiman Long <longman@redhat.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
John Stultz <jstultz@google.com>,
Suren Baghdasaryan <surenb@google.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
linux-rt-devel@lists.linux.dev
Subject: Re: [RFC PATCH v2 0/6] rwsem: priority boost for holders blocking high-priority waiters
Date: Tue, 1 Dec 2026 23:43:10 +0300 [thread overview]
Message-ID: <aw8ixo21YMqkLQe9@scheduler.schedules> (raw)
In-Reply-To: <20261201062738.1047159-1-penghuang@google.com>
Hi Peng,
On Mon, Nov 30, 2026 at 10:27:27PM -0800, Peng Huang wrote:
> Hi,
>
> High-priority threads (e.g. UI/render) can stall for tens to hundreds
> of milliseconds on shared rw_semaphores like mmap_lock or i_rwsem when
> preempted low-priority or SCHED_IDLE readers block a writer. Outside
> PREEMPT_RT, rwsems have no PI, Proxy Execution covers only mutexes,
> and read-owners are anonymous. This hits both servers (/proc/pid/
> cmdline, background MADV_COLD) and phones (nice -10 UI vs. background
> MADV_PAGEOUT on small cores, where we found it).
>
> This RFC raises the fair load weight of contended rwsem holders:
> - Patches 1-2: per-task tracking of up to 4 held rwsems (no atomics);
> btrfs untracks i_rwsem before cross-task io_uring completion.
> - Patch 3: pack top waiter priority into sem->count bits 3..8 (no
> struct rw_semaphore growth).
> - Patches 4-5: apply boost in set_load_weight() (p->prio and PI
> untouched); re-check queued holders on enqueue, preemption, and
> tick; drop on unlock.
> - Patch 6: KUnit suite (16 cases, 20 tests).
>
> Opt-in via CONFIG_RWSEM_SCHED_BOOST; disable at boot with
> rwsem_sched_boost=0.
>
> Questions for this RFC
> ----------------------
> - Is per-task tracking + weight boost acceptable for readers, or
> should this wait for Proxy Execution to cover rwsems?
> - Track readers and writers, or readers only (leaving writers to PE)?
> - Raw pointer slots (+56 B/task, explicit untrack) or a hash table?
> - Reweight via set_load_weight() (stays in cgroup share, moves PELT)
> or a floor on flattened EEVDF weight (crosses cgroups, skips PELT)?
>
> Known limits
> ------------
> - Weight is not PI; only runnable holders benefit (not I/O-blocked).
> Queued holders wait up to one tick; at most 4 rwsems/task tracked.
> - Waiter priority is sampled on queue (so rwsem-to-rwsem propagates
> when a boosted holder queues, but not across mutexes or futexes);
> concurrent readers share the boost.
> - Under FAIR_GROUP_SCHED, boost stays within the holder's cgroup
> share; a boosted SCHED_IDLE holder still yields to non-idle wakeups.
> - Under Proxy Execution, a fair task running for a non-fair donor is
> linked only on its next enqueue or preemption.
>
> Results (mean high-priority waiter latency)
> -------------------------------------------
> - KUnit (UML, nice +19 reader + 4 nice 0 hogs, nice -10 writer):
> 1813 -> 50 ms (-97.2%, median of 3; control 1.77-1.81 s).
> - QEMU x86_64 -smp 4 (TCG), mmap_lock, same setup (10 runs):
> 445.8 -> 8.7 ms within one image (-98.1%, max 14.9 ms, 0/200 > 16 ms;
> BASE 394.4 ms, TCG shifts up to 20% across images).
> - ARM64 phone (older 6.18 backport), mmap_lock, nice -10 vs. 7 hogs:
> 46.95 -> 8.89 ms (-81.1%) unpinned, 229.5 -> 19.4 ms (-91.5%) mid.
>
> Costs and non-results
> ---------------------
> - UML uncontended fastpath (boost=0 -> 1, median of 3): read 16.9 ->
> 20.2, write 17.1 -> 19.8, nested read 16.9 -> 21.8 ns/op; boosted
> holder cycling an unrelated rwsem: 28.5 ns/op.
> - Tick scan: walks up to 16 queued holders per tick under rq->lock
> (round-robin, up to 4 sem->count reads each); not measured alone.
> - Waiter prio rescan: O(1) when waiters share priority; losing a sole
> top waiter rescans remaining waiters under wait_lock (O(waiters)).
> - QEMU (boost=0 -> 1, 10 runs): madvise +2.4%, mprotect +1.4% (+0.4%
> median); equal-priority contention -4.3% mean, -5.6% median
> (196-240 ms on vs. 195-268 ms off).
> - ARM64 (same backport): madvise -2.2%, mprotect +0.2%; boot-time
> hackbench +6.6% and pipe +0.2% (settled -8.7% and -0.7%);
> equal-priority contention -10.6% mid-pinned, -2.8% mean / +12.1%
> median unpinned.
...
> - Browser warm launch from zRAM (same backport, 22 vs. 23 runs):
> +2.4% (p=0.45); holders spent 91-96% of inversion in D state (I/O).
> - Reader count loses 1 bit (22 bits on 32-bit, > PID_MAX_LIMIT).
> Memory: +56 B/task_struct, +16 B/rq.
Well if that is the case I can't see increasing the weight would help
atleast on this browser thing.
Even Proxy Exec. wouldn't help that much. You can't make a sleeping
task run earlier while it is sleeping.
But aside from that if we really want this, I think it would be better
to try to make this compatible with Proxy Exec. rather than
trying to implement a new mechanism, no :-)?
Thanks!
Kayra
next prev parent reply other threads:[~2026-12-01 20:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 6:27 Peng Huang
2026-12-01 6:27 ` [RFC PATCH v2 1/6] locking/rwsem: Track held rwsems per task Peng Huang
2026-12-01 6:27 ` [RFC PATCH v2 2/6] btrfs: untrack i_rwsem before io_uring encoded read completion Peng Huang
2026-12-01 8:40 ` Christoph Hellwig
2026-12-01 14:43 ` Steven Rostedt
2026-12-01 17:41 ` Peng Huang
2026-12-01 6:27 ` [RFC PATCH v2 3/6] locking/rwsem: Publish the top waiter priority Peng Huang
2026-12-01 6:27 ` [RFC PATCH v2 4/6] sched: Apply rwsem holder boost to the fair load weight Peng Huang
2026-12-01 6:27 ` [RFC PATCH v2 5/6] sched/fair: Boost rwsem holders with contended high-priority waiters Peng Huang
2026-12-01 6:27 ` [RFC PATCH v2 6/6] locking/rwsem: Add KUnit tests for scheduler priority boost Peng Huang
2026-12-01 20:43 ` Kayra Cizmeci [this message]
2026-12-01 21:10 ` [RFC PATCH v2 0/6] rwsem: priority boost for holders blocking high-priority waiters Peng Huang
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=aw8ixo21YMqkLQe9@scheduler.schedules \
--to=kayracizmeci@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=boqun@kernel.org \
--cc=bsegall@google.com \
--cc=clrkwllms@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=longman@redhat.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=penghuang@google.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=surenb@google.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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
all inboxes | Powered by JetHome®