Re: [PATCH v3 -mm -next] ipc,sem: fix lockdep false positive

From: Michel Lespinasse
Date: Fri Mar 29 2013 - 09:59:45 EST


On Fri, Mar 29, 2013 at 6:55 AM, Rik van Riel <riel@xxxxxxxxxxx> wrote:
> On Thu, 28 Mar 2013 19:50:47 -0700
> Michel Lespinasse <walken@xxxxxxxxxx> wrote:
>
>> This is IMO where the spin_unlock_wait(&sma->sem_perm.lock) would
>> belong - right before the goto again.
>
> Here is the slightly more optimistic (and probably more readable)
> version of the patch:
>
> ---8<---
> Unfortunately the locking scheme originally proposed has false positives
> with lockdep. This can be fixed by changing the code to only ever take
> one lock, and making sure that other relevant locks are not locked, before
> entering a critical section.
>
> For the "global lock" case, this is done by taking the sem_array lock,
> and then (potentially) waiting for all the semaphore's spinlocks to be
> unlocked.
>
> For the "local lock" case, we wait on the sem_array's lock to be free,
> before taking the semaphore local lock. To prevent races, we need to
> check again after we have taken the local lock.
>
> Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Reported-by: Sasha Levin <sasha.levin@xxxxxxxxxx>
> Signed-off-by: Rik van Riel <riel@xxxxxxxxxx>

Looks good.

Reviewed-by: Michel Lespinasse <walken@xxxxxxxxxx>

--
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
--
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/