Xiongwei Song 4840ce2267 locking/lockdep: Fix meaningless /proc/lockdep output of lock classes on !CONFIG_PROVE_LOCKING
When enabling CONFIG_LOCK_STAT=y, then CONFIG_LOCKDEP=y is forcedly enabled,
but CONFIG_PROVE_LOCKING is disabled.

We can get output from /proc/lockdep, which currently includes usages of
lock classes. But the usages 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 the CONFIG_PROVE_LOCKING=y section,
however in the test situation, it's not.

The fix is to move the usages reading and seq_print from the
!CONFIG_PROVE_LOCKING section to its defined section.

Also, locks_after list of lock_class is empty when !CONFIG_PROVE_LOCKING,
so do the same thing as what have done for usages of lock classes.

With this patch with !CONFIG_PROVE_LOCKING we can get the results below:

	/ # cat /proc/lockdep
	all lock classes:
	ffffffff85163290: cgroup_mutex
	ffffffff85154dd8: (console_sem).lock
	ffffffff85154d80: console_lock
	ffffffff85074b58: console_owner_lock
	ffffffff85074ba0: console_owner
	ffffffff85066d60: cpu_hotplug_lock

... a class key and the relevant class name each line.

Signed-off-by: Xiongwei Song <sxwjean@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Waiman Long <longman@redhat.com>
Link: https://lore.kernel.org/r/20210629135916.308210-1-sxwjean@me.com
2021-07-05 10:44:52 +02:00
..
2021-06-18 11:43:09 +02:00
2021-06-18 11:43:09 +02:00
2021-06-28 12:14:19 -07:00
2021-05-05 12:39:29 -07:00
2021-06-18 11:43:07 +02:00
2021-04-27 18:14:38 -07:00
2021-04-08 19:37:21 +02:00
2021-06-18 11:43:09 +02:00
2021-03-24 12:11:48 -04:00
2021-04-27 13:50:58 -07:00
2021-04-08 16:04:20 -07:00
2021-05-06 19:24:11 -07:00
2021-06-28 12:14:19 -07:00
2021-06-18 11:43:08 +02:00
2021-06-28 11:45:29 -07:00
2021-06-18 11:43:09 +02:00
2021-05-07 00:26:33 -07:00
2021-06-28 12:14:19 -07:00
2020-12-14 16:40:27 -08:00
2020-11-14 11:26:04 -08:00
2020-12-17 13:01:31 -08:00
2020-12-14 16:40:27 -08:00
2021-06-18 11:43:09 +02:00
2020-07-27 14:31:12 -04:00
2020-12-01 10:30:28 +00:00
2021-06-28 12:14:19 -07:00
2021-06-18 11:43:07 +02:00
2021-05-12 11:43:31 +02:00
2021-02-09 12:27:29 -05:00
2021-05-07 00:26:34 -07:00
2020-08-19 14:14:12 +02:00
2020-08-19 14:13:20 +02:00