All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ravikiran G Thirumalai <kiran@scalex86.org>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org,
	Christoph Lameter <clameter@engr.sgi.com>,
	Manfred Spraul <manfred@colorfullife.com>,
	vatsa@in.ibm.com, penberg@cs.Helsinki.FI,
	"Shai Fultheim (Shai@scalex86.org)" <shai@scalex86.org>
Subject: [patch] slab: Avoid deadlock at kmem_cache_create/kmem_cache_destroy
Date: Thu, 9 Feb 2006 10:29:24 -0800	[thread overview]
Message-ID: <20060209182923.GA3576@localhost.localdomain> (raw)

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);

             reply	other threads:[~2006-02-09 18:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-09 18:29 Ravikiran G Thirumalai [this message]
2006-02-10  7:55 ` [patch] slab: Avoid deadlock at kmem_cache_create/kmem_cache_destroy Pekka J Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060209182923.GA3576@localhost.localdomain \
    --to=kiran@scalex86.org \
    --cc=akpm@osdl.org \
    --cc=clameter@engr.sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=penberg@cs.Helsinki.FI \
    --cc=shai@scalex86.org \
    --cc=vatsa@in.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.