Re: [RFC v5] wait: prevent exclusive waiter starvation

From: Oleg Nesterov
Date: Mon Jan 26 2009 - 22:30:20 EST


On 01/26, Johannes Weiner wrote:
>
> Another iteration. I didn't use a general finish_wait_exclusive() but
> a version of this function that just returns whether we were woken
> through the queue or not.

But if your helper (finish_wait_woken) returns true, we always need
to wakeup the next waiter, or we don't need to use it. So why not
place the wakeup in the helper itself?

> --- a/include/linux/wait.h
> +++ b/include/linux/wait.h
> @@ -333,16 +333,20 @@ do { \
> for (;;) { \
> prepare_to_wait_exclusive(&wq, &__wait, \
> TASK_INTERRUPTIBLE); \
> - if (condition) \
> + if (condition) { \
> + finish_wait(&wq, &__wait); \
> break; \
> + } \
> if (!signal_pending(current)) { \
> schedule(); \
> continue; \
> } \
> ret = -ERESTARTSYS; \
> + if (finish_wait_woken(&wq, &__wait)) \
> + __wake_up_common(&wq, TASK_INTERRUPTIBLE, \

No, we can't use __wake_up_common() without wq->lock.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/