linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] locking/lockdep: Fix meaningless usages output of lock classes
@ 2021-06-27 14:23 Xiongwei Song
  2021-06-28  3:19 ` Xiongwei Song
  0 siblings, 1 reply; 2+ messages in thread
From: Xiongwei Song @ 2021-06-27 14:23 UTC (permalink / raw)
  To: peterz, mingo, will, longman, boqun.feng, linux-kernel; +Cc: Xiongwei Song

From: Xiongwei Song <sxwjean@gmail.com>

When enabling CONFIG_LOCK_STAT, then CONFIG_LOCKDEP is forcedly enabled.
We can get output from /proc/lockdep, which currently includes usages of
classes. But the usages of classes are meaningless, see the output
below:

/ # cat /proc/lockdep
all lock classes:
ffffffff9af63350 ....: cgroup_mutex

ffffffff9af54eb8 ....: (console_sem).lock

ffffffff9af54e60 ....: console_lock

ffffffff9ae74c38 ....: console_owner_lock

ffffffff9ae74c80 ....: console_owner

ffffffff9ae66e60 ....: cpu_hotplug_lock

Only one usage context for each lock, this is because each usage is only
changed in mark_lock() that is in CONFIG_PROVE_LOCKING defined section,
however in the test situation, it's not.

The fix is to move the usages reading and seq_print from
CONFIG_PROVE_LOCKING undefined setcion to it defined section.

Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
---
 kernel/locking/lockdep_proc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index 806978314496..1b1103ee7dc6 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -73,10 +73,11 @@ static int l_show(struct seq_file *m, void *v)
 #ifdef CONFIG_PROVE_LOCKING
 	seq_printf(m, " FD:%5ld", lockdep_count_forward_deps(class));
 	seq_printf(m, " BD:%5ld", lockdep_count_backward_deps(class));
-#endif
 
 	get_usage_chars(class, usage);
 	seq_printf(m, " %s", usage);
+#endif
+
 
 	seq_printf(m, ": ");
 	print_name(m, class);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] locking/lockdep: Fix meaningless usages output of lock classes
  2021-06-27 14:23 [PATCH] locking/lockdep: Fix meaningless usages output of lock classes Xiongwei Song
@ 2021-06-28  3:19 ` Xiongwei Song
  0 siblings, 0 replies; 2+ messages in thread
From: Xiongwei Song @ 2021-06-28  3:19 UTC (permalink / raw)
  To: Xiongwei Song
  Cc: peterz, mingo, will, longman, Boqun Feng, Linux Kernel Mailing List

Please ignore this patch, it's not good. I will improve it.

Regards,
Xiongwei

On Sun, Jun 27, 2021 at 10:23 PM Xiongwei Song <sxwjean@me.com> wrote:
>
> From: Xiongwei Song <sxwjean@gmail.com>
>
> When enabling CONFIG_LOCK_STAT, then CONFIG_LOCKDEP is forcedly enabled.
> We can get output from /proc/lockdep, which currently includes usages of
> classes. But the usages of classes are meaningless, see the output
> below:
>
> / # cat /proc/lockdep
> all lock classes:
> ffffffff9af63350 ....: cgroup_mutex
>
> ffffffff9af54eb8 ....: (console_sem).lock
>
> ffffffff9af54e60 ....: console_lock
>
> ffffffff9ae74c38 ....: console_owner_lock
>
> ffffffff9ae74c80 ....: console_owner
>
> ffffffff9ae66e60 ....: cpu_hotplug_lock
>
> Only one usage context for each lock, this is because each usage is only
> changed in mark_lock() that is in CONFIG_PROVE_LOCKING defined section,
> however in the test situation, it's not.
>
> The fix is to move the usages reading and seq_print from
> CONFIG_PROVE_LOCKING undefined setcion to it defined section.
>
> Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
> ---
>  kernel/locking/lockdep_proc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
> index 806978314496..1b1103ee7dc6 100644
> --- a/kernel/locking/lockdep_proc.c
> +++ b/kernel/locking/lockdep_proc.c
> @@ -73,10 +73,11 @@ static int l_show(struct seq_file *m, void *v)
>  #ifdef CONFIG_PROVE_LOCKING
>         seq_printf(m, " FD:%5ld", lockdep_count_forward_deps(class));
>         seq_printf(m, " BD:%5ld", lockdep_count_backward_deps(class));
> -#endif
>
>         get_usage_chars(class, usage);
>         seq_printf(m, " %s", usage);
> +#endif
> +
>
>         seq_printf(m, ": ");
>         print_name(m, class);
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-28  3:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-27 14:23 [PATCH] locking/lockdep: Fix meaningless usages output of lock classes Xiongwei Song
2021-06-28  3:19 ` Xiongwei Song

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).