[PATCH v3 11/14] tools/lib/lockdep: switch to using lockdep_init_map_waits

From: Sasha Levin
Date: Mon Jun 22 2020 - 18:43:35 EST


As of de8f5e4f2dc1 ("lockdep: Introduce wait-type checks") lockdep
exports lockdep_init_map_waits() instead of lockdep_init_map() for
initialization.

Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
tools/include/linux/kernel.h | 2 ++
tools/include/linux/lockdep.h | 1 +
tools/lib/lockdep/include/liblockdep/common.h | 4 ++--
tools/lib/lockdep/include/liblockdep/mutex.h | 2 +-
tools/lib/lockdep/include/liblockdep/rwlock.h | 2 +-
tools/lib/lockdep/preload.c | 2 +-
6 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h
index 902d3b9ab4c17..5ac493eef4237 100644
--- a/tools/include/linux/kernel.h
+++ b/tools/include/linux/kernel.h
@@ -124,4 +124,6 @@ static __maybe_unused int system_state;
#define rcu_read_lock()
#define rcu_read_unlock()

+#define in_nmi() 0
+
#endif
diff --git a/tools/include/linux/lockdep.h b/tools/include/linux/lockdep.h
index 3a9924d6d3ae8..4e5f31f28ca3e 100644
--- a/tools/include/linux/lockdep.h
+++ b/tools/include/linux/lockdep.h
@@ -34,6 +34,7 @@ struct task_struct {
int pid;
int state;
int softirqs_enabled, hardirqs_enabled, softirqs_disabled, hardirqs_disabled, irq_events;
+ int hardirq_threaded, irq_config;
unsigned long softirq_disable_ip, softirq_enable_ip;
unsigned int softirq_disable_event, softirq_enable_event;
unsigned long hardirq_disable_ip, hardirq_enable_ip;
diff --git a/tools/lib/lockdep/include/liblockdep/common.h b/tools/lib/lockdep/include/liblockdep/common.h
index a6d7ee5f18ba9..5f698671f45c2 100644
--- a/tools/lib/lockdep/include/liblockdep/common.h
+++ b/tools/lib/lockdep/include/liblockdep/common.h
@@ -37,8 +37,8 @@ struct lockdep_map {
#endif
};

-void lockdep_init_map(struct lockdep_map *lock, const char *name,
- struct lock_class_key *key, int subclass);
+void lockdep_init_map_waits(struct lockdep_map *lock, const char *name,
+ struct lock_class_key *key, int subclass, short inner, short outer);
void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
int trylock, int read, int check,
struct lockdep_map *nest_lock, unsigned long ip);
diff --git a/tools/lib/lockdep/include/liblockdep/mutex.h b/tools/lib/lockdep/include/liblockdep/mutex.h
index bd106b82759b7..6106fc73da687 100644
--- a/tools/lib/lockdep/include/liblockdep/mutex.h
+++ b/tools/lib/lockdep/include/liblockdep/mutex.h
@@ -24,7 +24,7 @@ static inline int __mutex_init(liblockdep_pthread_mutex_t *lock,
struct lock_class_key *key,
const pthread_mutexattr_t *__mutexattr)
{
- lockdep_init_map(&lock->dep_map, name, key, 0);
+ lockdep_init_map_waits(&lock->dep_map, name, key, 0, 0, 0);
return pthread_mutex_init(&lock->mutex, __mutexattr);
}

diff --git a/tools/lib/lockdep/include/liblockdep/rwlock.h b/tools/lib/lockdep/include/liblockdep/rwlock.h
index 6d5d2932bf4d9..222748d04219d 100644
--- a/tools/lib/lockdep/include/liblockdep/rwlock.h
+++ b/tools/lib/lockdep/include/liblockdep/rwlock.h
@@ -23,7 +23,7 @@ static inline int __rwlock_init(liblockdep_pthread_rwlock_t *lock,
struct lock_class_key *key,
const pthread_rwlockattr_t *attr)
{
- lockdep_init_map(&lock->dep_map, name, key, 0);
+ lockdep_init_map_waits(&lock->dep_map, name, key, 0, 0, 0);

return pthread_rwlock_init(&lock->rwlock, attr);
}
diff --git a/tools/lib/lockdep/preload.c b/tools/lib/lockdep/preload.c
index 578fdeda9422c..5bd58c51066c4 100644
--- a/tools/lib/lockdep/preload.c
+++ b/tools/lib/lockdep/preload.c
@@ -199,7 +199,7 @@ static struct lock_lookup *__get_lock(void *lock)
* TODO: Get the real name of the lock using libdwarf
*/
sprintf(l->name, "%p", lock);
- lockdep_init_map(&l->dep_map, l->name, &l->key, 0);
+// lockdep_init_map_waits(&l->dep_map, l->name, &l->key, 0, 0, 0);

ll_pthread_rwlock_wrlock(&locks_rwlock);
/* This might have changed since the last time we fetched it */
--
2.25.1