Skip to content

Commit a94d324

Browse files
Waiman-LongIngo Molnar
authored andcommitted
locking/lock_events: Add locking events for lockdep
Add some lock events to lockdep to profile its behavior. Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Boqun Feng <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b76b44f commit a94d324

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

kernel/locking/lock_events_list.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,10 @@ LOCK_EVENT(rtmutex_slow_acq3) /* # of locks acquired in *block() */
8888
LOCK_EVENT(rtmutex_slow_sleep) /* # of sleeps */
8989
LOCK_EVENT(rtmutex_slow_wake) /* # of wakeup's */
9090
LOCK_EVENT(rtmutex_deadlock) /* # of rt_mutex_handle_deadlock()'s */
91+
92+
/*
93+
* Locking events for lockdep
94+
*/
95+
LOCK_EVENT(lockdep_acquire)
96+
LOCK_EVENT(lockdep_lock)
97+
LOCK_EVENT(lockdep_nocheck)

kernel/locking/lockdep.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include <asm/sections.h>
6262

6363
#include "lockdep_internals.h"
64+
#include "lock_events.h"
6465

6566
#include <trace/events/lock.h>
6667

@@ -170,6 +171,7 @@ static struct task_struct *lockdep_selftest_task_struct;
170171
static int graph_lock(void)
171172
{
172173
lockdep_lock();
174+
lockevent_inc(lockdep_lock);
173175
/*
174176
* Make sure that if another CPU detected a bug while
175177
* 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,
50915093
if (unlikely(lock->key == &__lockdep_no_track__))
50925094
return 0;
50935095

5094-
if (!prove_locking || lock->key == &__lockdep_no_validate__)
5096+
lockevent_inc(lockdep_acquire);
5097+
5098+
if (!prove_locking || lock->key == &__lockdep_no_validate__) {
50955099
check = 0;
5100+
lockevent_inc(lockdep_nocheck);
5101+
}
50965102

50975103
if (subclass < NR_LOCKDEP_CACHING_CLASSES)
50985104
class = lock->class_cache[subclass];

0 commit comments

Comments
 (0)