]> git.ipfire.org Git - thirdparty/linux.git/commit
sched/wait: Drop WQ_FLAG_EXCLUSIVE from add_wait_queue_priority()
authorSean Christopherson <seanjc@google.com>
Thu, 22 May 2025 23:52:16 +0000 (16:52 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 23 Jun 2025 16:50:57 +0000 (09:50 -0700)
commit867347bb21e18551b48eb147c0b2d8635909c8b5
tree18fc771af7e62f06a67c86ae941d6f9d4a56c4cc
parent86e00cd162a727c0b847def89bbd787c20eb8f5d
sched/wait: Drop WQ_FLAG_EXCLUSIVE from add_wait_queue_priority()

Drop the setting of WQ_FLAG_EXCLUSIVE from add_wait_queue_priority() and
instead have callers manually add the flag prior to adding their structure
to the queue.  Blindly setting WQ_FLAG_EXCLUSIVE is flawed, as the nature
of exclusive, priority waiters means that only the first waiter added will
ever receive notifications.

Pushing the flawed behavior to callers will allow fixing the problem one
hypervisor at a time (KVM added the flawed API, and then KVM's code was
copy+pasted nearly verbatim by Xen and Hyper-V), and will also allow for
adding an API that provides true exclusivity, i.e. that guarantees at most
one priority waiter is in the queue.

Opportunistically add a comment in Hyper-V to call out the mess.  Xen
privcmd's irqfd_wakefup() doesn't actually operate in exclusive mode, i.e.
can be "fixed" simply by dropping WQ_FLAG_EXCLUSIVE.  And KVM is primed to
switch to the aforementioned fully exclusive API, i.e. won't be carrying
the flawed code for long.

No functional change intended.

Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250522235223.3178519-7-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
drivers/hv/mshv_eventfd.c
drivers/xen/privcmd.c
kernel/sched/wait.c
virt/kvm/eventfd.c