public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] slab: Avoid deadlock at kmem_cache_create/kmem_cache_destroy
@ 2006-02-09 18:29 Ravikiran G Thirumalai
  2006-02-10  7:55 ` Pekka J Enberg
  0 siblings, 1 reply; 2+ messages in thread
From: Ravikiran G Thirumalai @ 2006-02-09 18:29 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, Christoph Lameter, Manfred Spraul, vatsa, penberg,
	Shai Fultheim (Shai@scalex86.org)

Prevents deadlock situation between kmem_cache_create()/kmem_cache_destory(),
and kmem_cache_create() /cpu hotplug.  The locking order probably got 
moved over time.

Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Signed-off-by: Shai Fultheim <shai@scalex86.org>

Index: linux-2.6/mm/slab.c
===================================================================
--- linux-2.6.orig/mm/slab.c	2006-02-08 13:13:23.000000000 -0800
+++ linux-2.6/mm/slab.c	2006-02-09 01:58:02.000000000 -0800
@@ -1718,6 +1718,13 @@ kmem_cache_create (const char *name, siz
 		BUG();
 	}
 
+	/* 
+	 * Don't let CPUs to come and go.
+	 * Note: preserve lock taking order -- lock_cpu_hotplug first,
+	 * cache_chain_mutex then.
+	 */
+	lock_cpu_hotplug();
+
 	mutex_lock(&cache_chain_mutex);
 
 	list_for_each(p, &cache_chain) {
@@ -1918,8 +1925,6 @@ kmem_cache_create (const char *name, siz
 	cachep->dtor = dtor;
 	cachep->name = name;
 
-	/* Don't let CPUs to come and go */
-	lock_cpu_hotplug();
 
 	if (g_cpucache_up == FULL) {
 		enable_cpucache(cachep);
@@ -1978,12 +1983,12 @@ kmem_cache_create (const char *name, siz
 
 	/* cache setup completed, link it into the list */
 	list_add(&cachep->next, &cache_chain);
-	unlock_cpu_hotplug();
       oops:
 	if (!cachep && (flags & SLAB_PANIC))
 		panic("kmem_cache_create(): failed to create slab `%s'\n",
 		      name);
 	mutex_unlock(&cache_chain_mutex);
+	unlock_cpu_hotplug();
 	return cachep;
 }
 EXPORT_SYMBOL(kmem_cache_create);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-10  7:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-09 18:29 [patch] slab: Avoid deadlock at kmem_cache_create/kmem_cache_destroy Ravikiran G Thirumalai
2006-02-10  7:55 ` Pekka J Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox