The following commit has been merged into the locking/core branch of tip: Commit-ID: 7c17590a20dc9008bf073e86de3be60efdb6dfb4 Gitweb: https://git.kernel.org/tip/7c17590a20dc9008bf073e86de3be60efdb6dfb4 Author: Waiman Long <longman@xxxxxxxxxx> AuthorDate: Thu, 13 Feb 2025 15:02:26 -05:00 Committer: Boqun Feng <boqun.feng@xxxxxxxxx> CommitterDate: Sun, 23 Feb 2025 18:24:46 -08:00 locking/lock_events: Add locking events for lockdep Add some lock events to the lockdep for profiling its behavior. Signed-off-by: Waiman Long <longman@xxxxxxxxxx> Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx> Link: https://lore.kernel.org/r/20250213200228.1993588-3-longman@xxxxxxxxxx --- kernel/locking/lock_events_list.h | 7 +++++++ kernel/locking/lockdep.c | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/kernel/locking/lock_events_list.h b/kernel/locking/lock_events_list.h index 80b11f1..9ef9850 100644 --- a/kernel/locking/lock_events_list.h +++ b/kernel/locking/lock_events_list.h @@ -88,3 +88,10 @@ LOCK_EVENT(rtmutex_slow_acq3) /* # of locks acquired in *block() */ LOCK_EVENT(rtmutex_slow_sleep) /* # of sleeps */ LOCK_EVENT(rtmutex_slow_wake) /* # of wakeup's */ LOCK_EVENT(rtmutex_deadlock) /* # of rt_mutex_handle_deadlock()'s */ + +/* + * Locking events for lockdep + */ +LOCK_EVENT(lockdep_acquire) +LOCK_EVENT(lockdep_lock) +LOCK_EVENT(lockdep_nocheck) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 4470680..8436f01 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -61,6 +61,7 @@ #include <asm/sections.h> #include "lockdep_internals.h" +#include "lock_events.h" #include <trace/events/lock.h> @@ -170,6 +171,7 @@ static struct task_struct *lockdep_selftest_task_struct; static int graph_lock(void) { lockdep_lock(); + lockevent_inc(lockdep_lock); /* * Make sure that if another CPU detected a bug while * walking the graph we dont change it (while the other @@ -5091,8 +5093,12 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, if (unlikely(lock->key == &__lockdep_no_track__)) return 0; - if (!prove_locking || lock->key == &__lockdep_no_validate__) + lockevent_inc(lockdep_acquire); + + if (!prove_locking || lock->key == &__lockdep_no_validate__) { check = 0; + lockevent_inc(lockdep_nocheck); + } if (subclass < NR_LOCKDEP_CACHING_CLASSES) class = lock->class_cache[subclass];
![]() |