Re: [PATCH v2 1/2] sched/wait: Queue non-exclusive waiters at the head in do_wait_intr*()

From: Oleg Nesterov

Date: Mon Nov 23 2026 - 09:28:51 EST


On 11/22, Mani Tofigh via B4 Relay wrote:
>
> --- a/kernel/sched/wait.c
> +++ b/kernel/sched/wait.c
> @@ -319,8 +319,12 @@ EXPORT_SYMBOL(prepare_to_wait_event);
> */
> int do_wait_intr(wait_queue_head_t *wq, wait_queue_entry_t *wait)
> {
> - if (likely(list_empty(&wait->entry)))
> - __add_wait_queue_entry_tail(wq, wait);
> + if (likely(list_empty(&wait->entry))) {
> + if (wait->flags & WQ_FLAG_EXCLUSIVE)
> + __add_wait_queue_entry_tail(wq, wait);
> + else
> + __add_wait_queue(wq, wait);
> + }
>
> set_current_state(TASK_INTERRUPTIBLE);
> if (signal_pending(current))
> @@ -336,8 +340,12 @@ EXPORT_SYMBOL(do_wait_intr);
>
> int do_wait_intr_irq(wait_queue_head_t *wq, wait_queue_entry_t *wait)
> {
> - if (likely(list_empty(&wait->entry)))
> - __add_wait_queue_entry_tail(wq, wait);
> + if (likely(list_empty(&wait->entry))) {
> + if (wait->flags & WQ_FLAG_EXCLUSIVE)
> + __add_wait_queue_entry_tail(wq, wait);
> + else
> + __add_wait_queue(wq, wait);
> + }
>
> set_current_state(TASK_INTERRUPTIBLE);
> if (signal_pending(current))

perhaps it makes sense to add the new trivial helper later,
prepare_to_wait_event() can use it too.

Reviewed-by: Oleg Nesterov <oleg@xxxxxxxxxx>