WARNING: mutexes are preferred for single holder semaphores

Benjamin Herrenschmidt benh at kernel.crashing.org
Mon May 5 13:38:39 EST 2008


On Sun, 2008-05-04 at 20:41 -0400, Sean MacLennan wrote:
> This is a bit OT, but I got the warning in the subject from
> checkpatch.pl for a piece of code. The code *is* using a mutex. Does it
> actually mean I shouldn't use a mutex?
> 
> The code declares a global mutex:
> 
> 	static DECLARE_MUTEX(list_lock);
> 
> The odds of two accesses to the list_lock at the same time are zero.
> But it would be Very Bad(tm) if it did happen. Since the odds of
> contention are near zero, the cost of the mutex is near zero, so I put
> it in.
> 
> I think I can safely ignore the warning, but I want to make sure....

Show us the code... It could be a bug in checkpatch or you using 
the wrong functions somewhere ...

Ben.




More information about the Linuxppc-dev mailing list