Skip to content

Commit 1d44bcb

Browse files
Waiman-LongIngo Molnar
authored andcommitted
locking/lockdep: Track number of zapped classes
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
1 parent b9875e9 commit 1d44bcb

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

kernel/locking/lockdep.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ static DECLARE_BITMAP(list_entries_in_use, MAX_LOCKDEP_ENTRIES);
147147
#define KEYHASH_SIZE (1UL << KEYHASH_BITS)
148148
static struct hlist_head lock_keys_hash[KEYHASH_SIZE];
149149
unsigned long nr_lock_classes;
150+
unsigned long nr_zapped_classes;
150151
#ifndef CONFIG_DEBUG_LOCKDEP
151152
static
152153
#endif
@@ -4880,6 +4881,7 @@ static void zap_class(struct pending_free *pf, struct lock_class *class)
48804881
}
48814882

48824883
remove_class_from_lock_chains(pf, class);
4884+
nr_zapped_classes++;
48834885
}
48844886

48854887
static void reinit_class(struct lock_class *class)

kernel/locking/lockdep_internals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ extern const char *__get_key_name(const struct lockdep_subclass_key *key,
130130
struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i);
131131

132132
extern unsigned long nr_lock_classes;
133+
extern unsigned long nr_zapped_classes;
133134
extern unsigned long nr_list_entries;
134135
long lockdep_next_lockchain(long i);
135136
unsigned long lock_chain_count(void);

kernel/locking/lockdep_proc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,12 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
343343
seq_printf(m, " debug_locks: %11u\n",
344344
debug_locks);
345345

346+
/*
347+
* Zappped classes and lockdep data buffers reuse statistics.
348+
*/
349+
seq_puts(m, "\n");
350+
seq_printf(m, " zapped classes: %11lu\n",
351+
nr_zapped_classes);
346352
return 0;
347353
}
348354

0 commit comments

Comments
 (0)