Questions about wake_up[_interruptible][_all]
From: Stefan Metzmacher
Date: Wed Aug 13 2025 - 16:28:31 EST
Hi,
there are several cases where wait queues are used in:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/smb/client/smbdirect.c
and
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/smb/server/transport_rdma.c
I'm a bit confused because we the use mixed use of
wake_up(), wake_up_interruptible() and wake_up_interruptible_all()
On the wait side the following are used
wait_event(), wait_event_interruptible() and wait_event_interruptible_timeout()
The documentation of all wait_event_* macros say 'wake_up()' should be used.
And there's no documentation on the various wake_up_* macros.
I guess I understand the difference between
wait_event() and wait_event_interruptible(),
the first ignores any signal even kill and the
2nd returns -ERESTARTSYS on any signal.
I'm wondering if using wait_event_killable() should
be preferred instead of wait_event() in order to prevent
processes in state D hanging forever.
For some wait queues it would be desired that only
a single waiter is woken, so it can make good forward progress,
so maybe some wait_event_*_exclusive() would be useful for this.
As far as I understand the difference between
wake_up() and wake_up_all() is that the first
stops after the first waiter with WQ_FLAG_EXCLUSIVE.
and wake_up_all() wakes all waiters (useful for error conditions,
which all waiters should handle immediately.
But I don't understand the difference between
wake_up() and wake_up_interruptible().
My best guess would be that wake_up_interruptible()
would not wake waiters using wait_event(), but only
waiters using wait_event_interruptible() or any other
version that includes TASK_INTERRUPTIBLE.
So I guess we never want to use wake_up_interruptible(),
but always wake_up() or wake_up_all() instead...
It would be great if the documentation of
the wake_up macros and their interaction with
the wait_event macros could be improved.
Any hints are highly welcome :-)
Thanks!
metze