* [PATCH] locking/lockdep: Fix lock used or unused stats error
@ 2019-07-09 10:15 Yuyang Du
2019-07-09 13:45 ` Peter Zijlstra
2019-07-13 11:14 ` [tip:locking/urgent] " tip-bot for Yuyang Du
0 siblings, 2 replies; 3+ messages in thread
From: Yuyang Du @ 2019-07-09 10:15 UTC (permalink / raw)
To: peterz, will.deacon, mingo; +Cc: linux-kernel, frederic, arnd, cai, Yuyang Du
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@lca.pw>
Signed-off-by: Yuyang Du <duyuyang@gmail.com>
---
kernel/locking/lockdep_proc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index 9c49ec6..65b6a16 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -210,6 +210,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
nr_hardirq_read_safe = 0, nr_hardirq_read_unsafe = 0,
sum_forward_deps = 0;
+#ifdef CONFIG_PROVE_LOCKING
list_for_each_entry(class, &all_lock_classes, lock_entry) {
if (class->usage_mask == 0)
@@ -241,13 +242,13 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
if (class->usage_mask & LOCKF_ENABLED_HARDIRQ_READ)
nr_hardirq_read_unsafe++;
-#ifdef CONFIG_PROVE_LOCKING
sum_forward_deps += lockdep_count_forward_deps(class);
-#endif
}
#ifdef CONFIG_DEBUG_LOCKDEP
DEBUG_LOCKS_WARN_ON(debug_atomic_read(nr_unused_locks) != nr_unused);
#endif
+
+#endif
seq_printf(m, " lock-classes: %11lu [max: %lu]\n",
nr_lock_classes, MAX_LOCKDEP_KEYS);
seq_printf(m, " direct dependencies: %11lu [max: %lu]\n",
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] locking/lockdep: Fix lock used or unused stats error
2019-07-09 10:15 [PATCH] locking/lockdep: Fix lock used or unused stats error Yuyang Du
@ 2019-07-09 13:45 ` Peter Zijlstra
2019-07-13 11:14 ` [tip:locking/urgent] " tip-bot for Yuyang Du
1 sibling, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2019-07-09 13:45 UTC (permalink / raw)
To: Yuyang Du; +Cc: will.deacon, mingo, linux-kernel, frederic, arnd, cai
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@lca.pw>
> Signed-off-by: Yuyang Du <duyuyang@gmail.com>
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:locking/urgent] locking/lockdep: Fix lock used or unused stats error
2019-07-09 10:15 [PATCH] locking/lockdep: Fix lock used or unused stats error Yuyang Du
2019-07-09 13:45 ` Peter Zijlstra
@ 2019-07-13 11:14 ` tip-bot for Yuyang Du
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Yuyang Du @ 2019-07-13 11:14 UTC (permalink / raw)
To: linux-tip-commits
Cc: peterz, linux-kernel, mingo, torvalds, will.deacon, cai,
duyuyang, akpm, paulmck, tglx, hpa
Commit-ID: 68d41d8c94a31dfb8233ab90b9baf41a2ed2da68
Gitweb: https://git.kernel.org/tip/68d41d8c94a31dfb8233ab90b9baf41a2ed2da68
Author: Yuyang Du <duyuyang@gmail.com>
AuthorDate: Tue, 9 Jul 2019 18:15:22 +0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 13 Jul 2019 11:24:53 +0200
locking/lockdep: Fix lock used or unused stats error
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@lca.pw>
Signed-off-by: Yuyang Du <duyuyang@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: arnd@arndb.de
Cc: frederic@kernel.org
Link: https://lkml.kernel.org/r/20190709101522.9117-1-duyuyang@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/locking/lockdep_proc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index 9c49ec645d8b..65b6a1600c8f 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -210,6 +210,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
nr_hardirq_read_safe = 0, nr_hardirq_read_unsafe = 0,
sum_forward_deps = 0;
+#ifdef CONFIG_PROVE_LOCKING
list_for_each_entry(class, &all_lock_classes, lock_entry) {
if (class->usage_mask == 0)
@@ -241,12 +242,12 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
if (class->usage_mask & LOCKF_ENABLED_HARDIRQ_READ)
nr_hardirq_read_unsafe++;
-#ifdef CONFIG_PROVE_LOCKING
sum_forward_deps += lockdep_count_forward_deps(class);
-#endif
}
#ifdef CONFIG_DEBUG_LOCKDEP
DEBUG_LOCKS_WARN_ON(debug_atomic_read(nr_unused_locks) != nr_unused);
+#endif
+
#endif
seq_printf(m, " lock-classes: %11lu [max: %lu]\n",
nr_lock_classes, MAX_LOCKDEP_KEYS);
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-13 11:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-09 10:15 [PATCH] locking/lockdep: Fix lock used or unused stats error Yuyang Du
2019-07-09 13:45 ` Peter Zijlstra
2019-07-13 11:14 ` [tip:locking/urgent] " tip-bot for Yuyang Du
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).