From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mani Tofigh via B4 Relay <devnull+mt4022.columbia.edu@kernel.org>,
Breno Leitao <leitao@debian.org>,
Christian Brauner <brauner@kernel.org>,
Mateusz Guzik <mjguzik@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
tz2294@columbia.edu, stable@vger.kernel.org,
Mani Tofigh <mt4022@columbia.edu>
Subject: Re: [PATCH] pipe: keep per-write wakeups for EPOLLEXCLUSIVE consumers
Date: Wed, 18 Nov 2026 14:10:17 +0100 [thread overview]
Message-ID: <av2juQijIISJAgyf@redhat.com> (raw)
In-Reply-To: <CAHk-=wjqParwoB8wb9KfGVpbwUwvKvObpLOo=XPM0GGfkn3ibw@mail.gmail.com>
On 11/17, Linus Torvalds wrote:
>
> That header isn't _horrible_, but some of it was uglier than needed,
> and adding WQ_FLAG_PRIORITY would have been a huge pain because the
> code unnecessarily special-cases WQ_FLAG_EXCLUSIVE.
Yes. See also below.
> NOTE! Entirely untested. Comments?
I tried to check it line-by-line, see nothing wrong. FWIW,
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
---------------------------------------------------------------------------
And this reminds me. Please look at __wait_event_interruptible_locked(),
it is buggy.
do_wait_intr() and do_wait_intr_irq() use __add_wait_queue_entry_tail()
regardless of WQ_FLAG_EXCLUSIVE (reported by Mani in another thread).
Plus another problem: exclusive waiter must not fail if it was selected
by wakeup, see the comment in prepare_to_wait_event().
What if we add, say, WQ_FLAG_LOCKED and change prepare_to_wait_event()
--- x/kernel/sched/wait.c
+++ x/kernel/sched/wait.c
@@ -274,7 +274,8 @@ long prepare_to_wait_event(struct wait_q
unsigned long flags;
long ret = 0;
- spin_lock_irqsave(&wq_head->lock, flags);
+ if (!(wq_entry->flags & WQ_FLAG_LOCKED))
+ spin_lock_irqsave(&wq_head->lock, flags);
if (signal_pending_state(state, current)) {
/*
* Exclusive waiter must not fail if it was selected by wakeup,
@@ -299,7 +300,8 @@ long prepare_to_wait_event(struct wait_q
}
set_current_state(state);
}
- spin_unlock_irqrestore(&wq_head->lock, flags);
+ if (!(wq_entry->flags & WQ_FLAG_LOCKED))
+ spin_unlock_irqrestore(&wq_head->lock, flags);
return ret;
}
?
Yes, finish_wait() needs to check WQ_FLAG_LOCKED too... perhaps just
if (WQ_FLAG_LOCKED) list_del_init(...);
at the start.
Then we can trivially redefine all users of __wait_event_interruptible_locked()
on top of ___wait_event/etc.
Say, wait_event_interruptible_exclusive_locked(wq, condition) can use
___wait_event(wq, condition, TASK_INTERRUPTIBLE,
WQ_FLAG_EXCLUSIVE | WQ_FLAG_LOCKED,
spin_unlock(&wq->lock); schedule(); spin_lock(&wq->lock))
Will you agree with this hack? If yes, I'll try to make the patch on top of
your cleanup.
Oleg.
prev parent reply other threads:[~2026-11-18 13:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 21:02 Mani Tofigh via B4 Relay
2026-11-11 23:34 ` Oleg Nesterov
2026-11-12 10:26 ` Oleg Nesterov
2026-11-12 12:56 ` Oleg Nesterov
2026-11-17 13:27 ` Oleg Nesterov
2026-11-17 16:22 ` Linus Torvalds
2026-11-17 17:25 ` Oleg Nesterov
2026-11-17 17:35 ` Linus Torvalds
2026-11-17 17:58 ` Oleg Nesterov
2026-11-17 19:12 ` Linus Torvalds
2026-11-17 19:48 ` Linus Torvalds
2026-11-17 20:41 ` Oleg Nesterov
2026-11-18 13:10 ` Oleg Nesterov [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=av2juQijIISJAgyf@redhat.com \
--to=oleg@redhat.com \
--cc=brauner@kernel.org \
--cc=devnull+mt4022.columbia.edu@kernel.org \
--cc=jack@suse.cz \
--cc=leitao@debian.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=mt4022@columbia.edu \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tz2294@columbia.edu \
--cc=viro@zeniv.linux.org.uk \
/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®