]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
locking/lockdep: Track number of zapped classes
authorWaiman Long <longman@redhat.com>
Thu, 6 Feb 2020 15:24:05 +0000 (10:24 -0500)
committerIngo Molnar <mingo@kernel.org>
Tue, 11 Feb 2020 12:10:49 +0000 (13:10 +0100)
The whole point of the lockdep dynamic key patch is to allow unused
locks to be removed from the lockdep data buffers so that existing
buffer space can be reused. However, there is no way to find out how
many unused locks are zapped and so we don't know if the zapping process
is working properly.

Add a new nr_zapped_classes counter to track that and show it in
/proc/lockdep_stats.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lkml.kernel.org/r/20200206152408.24165-4-longman@redhat.com
kernel/locking/lockdep.c
kernel/locking/lockdep_internals.h
kernel/locking/lockdep_proc.c

index 35449f5b79fb1ed1837bb454042dca629eaf0dcb..28222d03345f37492656255e4949d924c2c9266a 100644 (file)
@@ -147,6 +147,7 @@ static DECLARE_BITMAP(list_entries_in_use, MAX_LOCKDEP_ENTRIES);
 #define KEYHASH_SIZE           (1UL << KEYHASH_BITS)
 static struct hlist_head lock_keys_hash[KEYHASH_SIZE];
 unsigned long nr_lock_classes;
+unsigned long nr_zapped_classes;
 #ifndef CONFIG_DEBUG_LOCKDEP
 static
 #endif
@@ -4880,6 +4881,7 @@ static void zap_class(struct pending_free *pf, struct lock_class *class)
        }
 
        remove_class_from_lock_chains(pf, class);
+       nr_zapped_classes++;
 }
 
 static void reinit_class(struct lock_class *class)
index a525368b8cf61d3da99377cba2b5e55457ff1a3f..76db80446a32c96a2eaa7dea7731dd91894d047d 100644 (file)
@@ -130,6 +130,7 @@ extern const char *__get_key_name(const struct lockdep_subclass_key *key,
 struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i);
 
 extern unsigned long nr_lock_classes;
+extern unsigned long nr_zapped_classes;
 extern unsigned long nr_list_entries;
 long lockdep_next_lockchain(long i);
 unsigned long lock_chain_count(void);
index c2224381c149d75483784e832162a155e3e535f9..99e2f3f6adca2acb9673846301d640f06ae0b043 100644 (file)
@@ -343,6 +343,12 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
        seq_printf(m, " debug_locks:                   %11u\n",
                        debug_locks);
 
+       /*
+        * Zappped classes and lockdep data buffers reuse statistics.
+        */
+       seq_puts(m, "\n");
+       seq_printf(m, " zapped classes:                %11lu\n",
+                       nr_zapped_classes);
        return 0;
 }