Skip to contentSkip to conversation

lockdep: Clear whole lockdep_map on initialization

PATCH In review Tejun Heo 1 participant 2 messages Jul 14, 2011 – Aug 4, 2011

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 lockdep: Clear whole lockdep_map on initialization

lockdep_init_map() only initializes parts of lockdep_map and triggers kmemcheck warning when it is copied as a whole. There isn't anything to be gained by clearing selectively. memset() the whole structure and remove loop for ->class_cache[] clearing.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=35532

---
 kernel/lockdep.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/lockdep.c +1 -4
index 298c927..7b9b4f1 100644
@@ -2859,10 +2859,7 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
 void lockdep_init_map(struct lockdep_map *lock, const char *name,
 		      struct lock_class_key *key, int subclass)
 {
-	int i;
-
-	for (i = 0; i < NR_LOCKDEP_CACHING_CLASSES; i++)
-		lock->class_cache[i] = NULL;
+	memset(lock, 0, sizeof(*lock));
 
 #ifdef CONFIG_LOCK_STAT
 	lock->cpu = raw_smp_processor_id();
#1 lore raw
Commit-ID:  f59de8992aa6dc85e81aadc26b0f69e17809721d
Gitweb:     http://git.kernel.org/tip/f59de8992aa6dc85e81aadc26b0f69e17809721d
Author:     Tejun Heo <[email protected]>
AuthorDate: Thu, 14 Jul 2011 15:19:09 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 4 Aug 2011 10:17:56 +0200

lockdep: Clear whole lockdep_map on initialization

lockdep_init_map() only initializes parts of lockdep_map and triggers kmemcheck warning when it is copied as a whole. There isn't anything to be gained by clearing selectively. memset() the whole structure and remove loop for ->class_cache[] clearing.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=35532

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=35532

---
 kernel/lockdep.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
kernel/lockdep.c +1 -4
index 5903586..8c24294 100644
@@ -2874,10 +2874,7 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
 void lockdep_init_map(struct lockdep_map *lock, const char *name,
 		      struct lock_class_key *key, int subclass)
 {
-	int i;
-
-	for (i = 0; i < NR_LOCKDEP_CACHING_CLASSES; i++)
-		lock->class_cache[i] = NULL;
+	memset(lock, 0, sizeof(*lock));
 
 #ifdef CONFIG_LOCK_STAT
 	lock->cpu = raw_smp_processor_id();