From: Sasha Levin <sashal@kernel.org>
To: "Thomas Gleixner" <tglx@linutronix.de>,
"Darren Hart" <dvhart@infradead.org>,
"Davidlohr Bueso" <dave@stgolabs.net>,
"André Almeida" <andrealmeid@igalia.com>,
"Will Deacon" <will@kernel.org>,
"Waiman Long" <longman@redhat.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Simon Liebold" <simonlie@amazon.de>,
"John Stultz" <jstultz@google.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 6.12.y 2/2] sched/wake_q: Add helper to call wake_up_q after unlock with preemption disabled
Date: Thu, 6 Aug 2026 13:49:42 -0400 [thread overview]
Message-ID: <20260806131004.stable-0005@kernel.org> (raw)
In-Reply-To: <20260806093259.2778358-3-simonlie@amazon.de>
On Thu, Aug 06, 2026 at 09:32:59AM +0000, Simon Liebold wrote:
> [ Upstream commit abfdccd6af2b071951633e57d6322c46a1ea791f ]
>
> A common pattern seen when wake_qs are used to defer a wakeup
> until after a lock is released is something like:
> preempt_disable();
> raw_spin_unlock(lock);
> wake_up_q(wake_q);
> preempt_enable();
>
> So create some raw_spin_unlock*_wake() helper functions to clean
> this up.
Both patches apply cleanly to 6.12.y and are byte-identical to their
upstream counterparts, so mechanically there is nothing wrong here. But
the rationale in the cover letter does not hold up:
> Even though it looks like a refactor, it adds an if (wake_q), gating the
> wake queue drain.
That "if (wake_q)" is a NULL pointer check, not an "is the queue empty"
check. On 6.12.y every call site of the new helpers passes the address of
an on-stack DEFINE_WAKE_Q - __mutex_unlock_slowpath() and
task_blocks_on_rt_mutex() both pass &wake_q unconditionally - so it is
never false, and the preempt_disable() plus wake_up_q() drain stays
exactly as unconditional as it is today. The only site that can pass NULL
is rt_mutex_slowlock_block() via rt_mutex_wait_proxy_lock(), and that
already carries the identical guard in 6.12.y from the 4a0779145781
("locking/rtmutex: Make sure we wake anything on the wake_q when we
release the lock->wait_lock") backport.
Patch 1/2 additionally converts mutex::wait_lock to irqsave/irqrestore,
which adds a small cost to the slow path rather than removing one. And
the unconditional drain in the plain mutex release path arrived with
894d1b3db41c ("locking/mutex: Remove wakeups from under
mutex::wait_lock") in v6.12.95, not with 4a0779145781 in v6.12.96.
Also note that "wake_q is only ever populated on the ww_mutex path" is
not right either: __mutex_unlock_slowpath() does wake_q_add() for the
ordinary contended waiter.
Neither commit has a Fixes: or Cc: stable tag and both are proxy-exec
prep/cleanup work, so before I queue them for 6.12.y I would like to see
before/after fio numbers with each patch applied separately, so we know
which change actually recovers the throughput you measured.
--
Thanks,
Sasha
prev parent reply other threads:[~2026-08-06 17:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 9:32 [PATCH 6.12.y 0/2] Please backport wake_q drain follow-ups Simon Liebold
2026-08-06 9:32 ` [PATCH 6.12.y 1/2] locking/mutex: Make mutex::wait_lock irq safe Simon Liebold
2026-08-06 9:32 ` [PATCH 6.12.y 2/2] sched/wake_q: Add helper to call wake_up_q after unlock with preemption disabled Simon Liebold
2026-08-06 17:49 ` Sasha Levin [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=20260806131004.stable-0005@kernel.org \
--to=sashal@kernel.org \
--cc=andrealmeid@igalia.com \
--cc=boqun.feng@gmail.com \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=simonlie@amazon.de \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.