[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-feb0a3865ed2f7d66a1f2686f7ad784422c249ad@git.kernel.org>
Date: Wed, 27 Feb 2019 23:06:38 -0800
From: tip-bot for Bart Van Assche <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, will.deacon@....com, hpa@...or.com,
torvalds@...ux-foundation.org, mingo@...nel.org,
bvanassche@....org, akpm@...ux-foundation.org,
paulmck@...ux.vnet.ibm.com, johannes@...solutions.net,
tglx@...utronix.de, longman@...hat.com, peterz@...radead.org
Subject: [tip:locking/core] locking/lockdep: Initialize the locks_before and
locks_after lists earlier
Commit-ID: feb0a3865ed2f7d66a1f2686f7ad784422c249ad
Gitweb: https://git.kernel.org/tip/feb0a3865ed2f7d66a1f2686f7ad784422c249ad
Author: Bart Van Assche <bvanassche@....org>
AuthorDate: Thu, 14 Feb 2019 15:00:42 -0800
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Thu, 28 Feb 2019 07:55:41 +0100
locking/lockdep: Initialize the locks_before and locks_after lists earlier
This patch does not change any functionality. A later patch will reuse
lock classes that have been freed. In combination with that patch this
patch wil have the effect of initializing lock class order lists once
instead of every time a lock class structure is reinitialized.
Signed-off-by: Bart Van Assche <bvanassche@....org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Johannes Berg <johannes@...solutions.net>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Waiman Long <longman@...hat.com>
Cc: Will Deacon <will.deacon@....com>
Cc: johannes.berg@...el.com
Cc: tj@...nel.org
Link: https://lkml.kernel.org/r/20190214230058.196511-8-bvanassche@acm.org
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
kernel/locking/lockdep.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 28fbeb2a10cc..d1a6daf1f51f 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -735,6 +735,25 @@ static bool assign_lock_key(struct lockdep_map *lock)
return true;
}
+/*
+ * Initialize the lock_classes[] array elements.
+ */
+static void init_data_structures_once(void)
+{
+ static bool initialization_happened;
+ int i;
+
+ if (likely(initialization_happened))
+ return;
+
+ initialization_happened = true;
+
+ for (i = 0; i < ARRAY_SIZE(lock_classes); i++) {
+ INIT_LIST_HEAD(&lock_classes[i].locks_after);
+ INIT_LIST_HEAD(&lock_classes[i].locks_before);
+ }
+}
+
/*
* Register a lock's class in the hash-table, if the class is not present
* yet. Otherwise we look it up. We cache the result in the lock object
@@ -775,6 +794,8 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
goto out_unlock_set;
}
+ init_data_structures_once();
+
/*
* Allocate a new key from the static array, and add it to
* the hash:
@@ -793,8 +814,8 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
class->key = key;
class->name = lock->name;
class->subclass = subclass;
- INIT_LIST_HEAD(&class->locks_before);
- INIT_LIST_HEAD(&class->locks_after);
+ WARN_ON_ONCE(!list_empty(&class->locks_before));
+ WARN_ON_ONCE(!list_empty(&class->locks_after));
class->name_version = count_matching_names(class);
/*
* We use RCU's safe list-add method to make
@@ -4155,6 +4176,8 @@ void lockdep_free_key_range(void *start, unsigned long size)
int i;
int locked;
+ init_data_structures_once();
+
raw_local_irq_save(flags);
locked = graph_lock();
@@ -4218,6 +4241,8 @@ void lockdep_reset_lock(struct lockdep_map *lock)
unsigned long flags;
int j, locked;
+ init_data_structures_once();
+
raw_local_irq_save(flags);
locked = graph_lock();
Powered by blists - more mailing lists