lkml.org 
[lkml]   [2016]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH -v4 1/8] locking/drm: Kill mutex trickery
On Sat, Oct 08, 2016 at 01:58:07PM +0200, Thomas Gleixner wrote:
> Hmm. I'm not a great fan of this, because that requires an conditional
> unlock mechanism.
>
> res = trylock_recursive(lock);
> if (res == FAILED)
> goto out;
> .....
>
> if (res == SUCCESS)
> unlock(lock);
>
> While if you actually keep track of recursion you can do:
>
> if (!trylock_recursive(lock))
> goto out;
>
> ....
>
> unlock_recursive(lock);
>
> or even:
>
> lock_recursive(lock);
>
> unlock_recursive(lock);
>
> That's making lock/trylock and unlock symetric, so its obvious in the
> source what's going on and the recursion tracking allows for better
> debugability.

Hurm,. so I thought that in general we disliked recursive locking
because it quickly turns in to a horrible mess.

Adding such primitives makes it 'easy' to use recursive locking and then
where does it stop?


\
 
 \ /
  Last update: 2016-10-08 16:19    [W:0.176 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site