Re: [PATCH] mutex: set owner only once on acquisition

Johannes Weiner
2009-01-15T08:56:25Z

On Thu, Jan 15, 2009 at 09:41:01AM +0100, Johannes Weiner wrote:
> mutex_lock() sets the lock owner, no need to set it upfront in
> __mutex_lock_common().
>
> Inside __mutex_lock_common() we can cope with the case where the
> successful acquirer got preempted by us before setting the owner
> field: there is an explicit check in the spinning code and the
> sleeping part doesn't rely on it.
>
> The debug code does owner checks only on unlock where the field is
> garuanteed to be set.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
> kernel/mutex.c | 2 --
> 1 file changed, 2 deletions(-)
>
> Just a small observation. Peter said it wouldn't matter much as the
> write is to a hot cache line. But otoh, why keep it if it's not
> necessary. :)

Damn, I'm really async here, sorry Peter. Just noticed you already
picked it up.

Hannes