Re: [PATCH-tip v3 06/11] locking/rwsem: Enhance DEBUG_RWSEMS_WARN_ON() macro

From: Waiman Long
Date: Wed Apr 03 2019 - 11:33:36 EST


On 04/03/2019 09:09 AM, Peter Zijlstra wrote:
> On Thu, Feb 28, 2019 at 02:09:36PM -0500, Waiman Long wrote:
>> diff --git a/kernel/locking/rwsem.h b/kernel/locking/rwsem.h
>> index 1d8f722..c8fd3f1 100644
>> --- a/kernel/locking/rwsem.h
>> +++ b/kernel/locking/rwsem.h
>> @@ -27,9 +27,13 @@
>> #define RWSEM_ANONYMOUSLY_OWNED (1UL << 1)
>>
>> #ifdef CONFIG_DEBUG_RWSEMS
>> -# define DEBUG_RWSEMS_WARN_ON(c) DEBUG_LOCKS_WARN_ON(c)
>> +# define DEBUG_RWSEMS_WARN_ON(c, sem) \
>> + WARN_ONCE(c, "DEBUG_RWSEMS_WARN_ON(%s): count = 0x%lx, owner = 0x%lx, curr 0x%lx, list %sempty\n",\
>> + #c, atomic_long_read(&(sem)->count), \
>> + (long)((sem)->owner), (long)current, \
>> + list_empty(&(sem)->wait_list) ? "" : "not ")
> This changes DEBUG_LOCKS_WARN_ON() to WARN_ONCE(), the difference being
> that you now fail to kill lockdep on a rwsem error, which seems
> unfortunate.
>
>> #else
>> -# define DEBUG_RWSEMS_WARN_ON(c)
>> +# define DEBUG_RWSEMS_WARN_ON(c, sem)
>> #endif

Yes, you are right. I will update my patch to fix that.

Cheers,
Longman