Re: [PATCH] ipc,sem: move restart loop to do_smart_update

From: Davidlohr Bueso
Date: Wed May 22 2013 - 18:21:01 EST


On Sun, 2013-05-19 at 18:32 -0400, Rik van Riel wrote:
> >
> > One fix would be a loop in do_smart_update():
> > - first check the global queue
> > - then the per-semaphore queues
> > - if one of the per-semaphore queues made progress: check the global
> > queue again
> > - if the global queue made progress: check the per semaphore queues again
> > ...
>
> Would that be as simple as making do_smart_update() loop back to
> the top if update_queue on a single semaphore's queue returns
> a non-zero value (something was changed), and there are complex
> operations pending?

I've been looking at the code for a while and this approach seems quite
reasonable. I'd still like Manfred's feedback though. I ran pgbench and
your semop-multi program, nothing suspicious.

> ---8<---
>
> Subject: ipc,sem: move restart loop to do_smart_update
>
> A complex operation may be sleeping on a semaphore to become
> a certain value. A sleeping simple operation may turn the
> semaphore into that value.
>
> Having the restart loop inside update_queue means we may be
> missing the complex operation (which lives on a different
> queue), and result in a semaphore lockup.
>
> The lockup can be avoided by moving the restart loop into
> do_smart_update, so the list of pending complex operations
> will also be checked if required.
>
> Signed-off-by: Rik van Riel <riel@xxxxxxxxxx>
> Reported-by: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx>

Acked-by: Davidlohr Bueso <davidlohr.bueso@xxxxxx>

--
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/