[PATCH 7/7] sched/wait: remove the __add_wait_queue_*exclusive() helpers
From: Linus Torvalds
Date: Tue Nov 24 2026 - 12:48:03 EST
From: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 23 Nov 2026 17:04:33 -0800
Subject: [PATCH 7/7] sched/wait: remove the __add_wait_queue_*exclusive()
helpers
Each has one or two special-case users. Open-code them there: set
WQ_FLAG_EXCLUSIVE and queue the entry directly, with a note on why the
caller doesn't use add_wait_queue_exclusive().
I think all cases (eventpoll, orangefs and ubifs) are unnecessary and
could just use the regular ordering, but I'll leave that to those
maintainers to sort out.
Cc: Oleg Nesterov <oleg@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Juri Lelli <juri.lelli@xxxxxxxxxx>
Cc: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx> # eventpoll
Cc: Christian Brauner <brauner@xxxxxxxxxx> # eventpoll
Cc: Jan Kara <jack@xxxxxxx> # eventpoll
Cc: Mike Marshall <hubcap@xxxxxxxxxxxx> # orangefs
Cc: Richard Weinberger <richard@xxxxxx> # ubifs
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
---
fs/eventpoll.c | 7 +++++--
fs/orangefs/orangefs-bufmap.c | 7 +++++--
fs/ubifs/journal.c | 4 +++-
include/linux/wait.h | 17 -----------------
4 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 58c0cb845dc7..14095cd5f7cf 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -2351,8 +2351,11 @@ static int ep_poll(struct eventpoll *ep, struct
epoll_event __user *events,
* important.
*/
eavail = ep_events_available(ep);
- if (!eavail)
- __add_wait_queue_exclusive(&ep->wq, &wait);
+ if (!eavail) {
+ /* Head, for LIFO wakeups; ep->lock serializes ep->wq */
+ wait.flags |= WQ_FLAG_EXCLUSIVE;
+ list_add(&wait.entry, &ep->wq.head);
+ }
spin_unlock_irq(&ep->lock);
diff --git a/fs/orangefs/orangefs-bufmap.c b/fs/orangefs/orangefs-bufmap.c
index 34195f2cd845..bc0abc050934 100644
--- a/fs/orangefs/orangefs-bufmap.c
+++ b/fs/orangefs/orangefs-bufmap.c
@@ -85,8 +85,11 @@ static int wait_for_free(struct slot_map *m)
do {
long n = left, t;
- if (likely(list_empty(&wait.entry)))
- __add_wait_queue_entry_tail_exclusive(&m->q, &wait);
+ if (likely(list_empty(&wait.entry))) {
+ /* m->q.lock is held */
+ wait.flags |= WQ_FLAG_EXCLUSIVE;
+ __add_wait_queue(&m->q, &wait);
+ }
set_current_state(TASK_INTERRUPTIBLE);
if (m->c > 0)
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index 40a95a2fad50..a8a6c9b01b9b 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -303,7 +303,9 @@ static void __queue_and_wait(struct ubifs_info *c)
{
DEFINE_WAIT(wait);
- __add_wait_queue_entry_tail_exclusive(&c->reserve_space_wq, &wait);
+ /* c->reserve_space_wq.lock is held */
+ wait.flags |= WQ_FLAG_EXCLUSIVE;
+ __add_wait_queue(&c->reserve_space_wq, &wait);
set_current_state(TASK_UNINTERRUPTIBLE);
spin_unlock(&c->reserve_space_wq.lock);
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 4f87ad870f51..bc2ad10a00b2 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -174,23 +174,6 @@ static inline void __add_wait_queue(struct
wait_queue_head *wq_head, struct wait
list_add_tail(&wq_entry->entry, &wq_head->head);
}
-/*
- * Adds at the head, for epoll's LIFO wakeup of its epoll_wait()ers.
- */
-static inline void
-__add_wait_queue_exclusive(struct wait_queue_head *wq_head, struct
wait_queue_entry *wq_entry)
-{
- wq_entry->flags |= WQ_FLAG_EXCLUSIVE;
- list_add(&wq_entry->entry, &wq_head->head);
-}
-
-static inline void
-__add_wait_queue_entry_tail_exclusive(struct wait_queue_head
*wq_head, struct wait_queue_entry *wq_entry)
-{
- wq_entry->flags |= WQ_FLAG_EXCLUSIVE;
- __add_wait_queue(wq_head, wq_entry);
-}
-
static inline void
__remove_wait_queue(struct wait_queue_head *wq_head, struct
wait_queue_entry *wq_entry)
{
--
2.56.0.313.g975a75ca90