They are used by the i915 DRM driver starting with Linux 6.7.
(struct wait_queue)->flags is no longer always zero. I wonder if some code relied on this...
This is part of the update of DRM drivers to Linux 6.7.
Sponsored by: The FreeBSD Foundation
Differential D48755
linuxkpi: Add `woken_wake_function()` and `wait_woken()` Authored by dumbbell on Jan 31 2025, 2:22 PM. Tags None Referenced Files
Details
They are used by the i915 DRM driver starting with Linux 6.7. (struct wait_queue)->flags is no longer always zero. I wonder if some code relied on this... This is part of the update of DRM drivers to Linux 6.7. Sponsored by: The FreeBSD Foundation
Diff Detail
Event TimelineComment Actions I made local changes to address @bz comments, but I will only upload it when other concerns are addressed.
Comment Actions I think the implementation should look more like linux_wait_on_bit_timeout() and linux_wake_up_bit(). In particular, we should use sleepqueue locks (keyed by wq->private) to synchronize the checks; this lockless approach is basically duplicating Linux internals. For instance, their implementation makes use of the fact that set_task_state() issues a full barrier in order to synchronize some scheduler function, but that is not true in the LinuxKPI. In particular, I think something like the following would be easier to understand and would look more like other routines in this file: linux_wait_woken(...)
{
void *wchan = wq->private;
for (;;) {
sleepq_lock(whcan);
if (wq->flags & WQ_FLAG_WOKEN) {
sleepq_unlock(wchan);
break;
}
set_task_state(current, state);
<sleep>
<break if timeout elapsed>
}
}
woken_wait_function(...)
{
void *wchan = wq->private;
sleepq_lock(wchan);
wq->flags &= ~WQ_FLAG_WOKEN;
sleepq_signal(...);
sleepq_release(wchan);
}Comment Actions Thank you @markj for the detailed feedback! I reimplemented the patch based on your suggestion and will test it shortly. I didn’t keep the infinite loop in wait_woken() because the Linux implementation doesn’t have one: the caller is supposed to do the loop.
Comment Actions @markj: Thank you, I will work on a refactor. Do you want me to submit the refactor in this review or separately? I’m leaning toward the latter.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||