Re: [PATCH] locking/lockdep: Fix lock used or unused stats error

From: Peter Zijlstra
Date: Tue Jul 09 2019 - 09:45:50 EST


On Tue, Jul 09, 2019 at 06:15:22PM +0800, Yuyang Du wrote:
> The stats variable nr_unused_locks is incremented every time a new lock
> class is register and decremented when the lock is first used in
> __lock_acquire(). And after all, it is shown and checked in lockdep_stats.
>
> However, under configurations that either CONFIG_TRACE_IRQFLAGS or
> CONFIG_PROVE_LOCKING is not defined:
>
> The commit:
>
> 091806515124b20 ("locking/lockdep: Consolidate lock usage bit initialization")
>
> missed marking the LOCK_USED flag at IRQ usage initialization because
> as mark_usage() is not called. And the commit:
>
> 886532aee3cd42d ("locking/lockdep: Move mark_lock() inside
> CONFIG_TRACE_IRQFLAGS && CONFIG_PROVE_LOCKING")
>
> further made mark_lock() not defined such that the LOCK_USED cannot be
> marked at all when the lock is first acquired.
>
> As a result, we fix this by not showing and checking the stats under such
> configurations for lockdep_stats.
>
> Reported-by: Qian Cai <cai@xxxxxx>
> Signed-off-by: Yuyang Du <duyuyang@xxxxxxxxx>

Thanks!