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>,
Alok Kataria <alok.kataria@calsoftinc.com>,
"Shai Fultheim (Shai@scalex86.org)" <shai@scalex86.org>,
"Benzi Galili (Benzi@ScaleMP.com)" <benzi@scalemp.com>
Subject: [patch] slab: Fix a cpu hotplug race condition while tuning slab cpu caches
Date: Mon, 16 Oct 2006 01:54:39 -0700 [thread overview]
Message-ID: <20061016085439.GA6651@localhost.localdomain> (raw)
Fix a cpu hotplug race condition while tuning slab cpu caches.
CPU online (cpu_up) and tuning slab caches (do_tune_cpucache)
can race and can lead to a situation where we do not have an
arraycache allocated for a newly onlined cpu.
The race can be explained as follows:
cpu_online_map 00000111
cpu_up(3)
cpuup_callback CPU_UP_PREPARE:
mutex_lock(&cache_chain_mutex);
...
allocate_array_cache for cpu 3
...
mutex_unlock(&cache_chain_mutex);
... slabinfo_write
... mutex_lock(&cache_chain_mutex);
... do_tune_cpucache
... allocate new arraycache for cpu0,1,2, NULL rest
... ...
mutex_lock(&cpu_bitmask_lock); ...
cpu_online_map 00001111
mutex_unlock(&cpu_bitmask_lock); ...
on_each_cpu swap the new array_cache with old
^^^^
CPU 3 gets assigned with a NULL array cache
Hence, when do_ccupdate_local is run on CPU 3, CPU 3 gets a NULL array_cache,
and caused badness thereon.
So don't allow cpus to come and go while in do_tune_cpucache.
The other code path of do_tune_cpucache through kmem_cache_create
is already protected through lock_cpu_hotplug.
Signed-off-by: Alok N Kataria <alokk@calsoftinc.com>
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Signed-off-by: Shai Fultheim <shai@scalex86.org>
Index: linux-2.6.19-rc1slab/mm/slab.c
===================================================================
--- linux-2.6.19-rc1slab.orig/mm/slab.c 2006-10-13 12:35:02.578841000 -0700
+++ linux-2.6.19-rc1slab/mm/slab.c 2006-10-13 12:35:46.848841000 -0700
@@ -4072,6 +4072,7 @@ ssize_t slabinfo_write(struct file *file
return -EINVAL;
/* Find the cache in the chain of caches. */
+ lock_cpu_hotplug();
mutex_lock(&cache_chain_mutex);
res = -EINVAL;
list_for_each_entry(cachep, &cache_chain, next) {
@@ -4087,6 +4088,7 @@ ssize_t slabinfo_write(struct file *file
}
}
mutex_unlock(&cache_chain_mutex);
+ unlock_cpu_hotplug();
if (res >= 0)
res = count;
return res;
next reply other threads:[~2006-10-16 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-16 8:54 Ravikiran G Thirumalai [this message]
2006-10-16 9:12 ` [patch] slab: Fix a cpu hotplug race condition while tuning slab cpu caches Christoph Lameter
2006-10-16 18:15 ` Andrew Morton
2006-10-16 19:26 ` Ravikiran G Thirumalai
2006-10-16 19:48 ` Andrew Morton
2006-10-16 22:43 ` 2.6.19-rc2 cpu hotplug lockdep warning: possible circular locking dependency Ravikiran G Thirumalai
2006-10-16 22:58 ` Neil Brown
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=20061016085439.GA6651@localhost.localdomain \
--to=kiran@scalex86.org \
--cc=akpm@osdl.org \
--cc=alok.kataria@calsoftinc.com \
--cc=benzi@scalemp.com \
--cc=clameter@engr.sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=shai@scalex86.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox