From: Manfred <manfred@colorfullife.com>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: [uPATCH] bugfix for slab tuning race
Date: Sun, 10 Dec 2000 12:37:12 +0100 (CET) [thread overview]
Message-ID: <Pine.LNX.4.21.0012101224560.1447-100000@clmsdevli> (raw)
Hi Linus,
the patch below fixes a race in the slab allocator:
If one cpu increases the batch count (kmem_tune_cpucache, just before
smp_call_function_all_cpus()) and another cpu allocates a new batch
of slab entries before the IPI arrives, then kmem_cache_alloc_batch
writes behind the end of the cpu local array.
The patch is against 2.4.0-test11.
--
Manfred
<<<<<<<<<<<<<<
--- 2.4/mm/slab.c Tue Oct 3 20:03:44 2000
+++ build-2.4/mm/slab.c Sat Dec 2 15:00:32 2000
@@ -188,7 +188,7 @@
unsigned int num; /* # of objs per slab */
spinlock_t spinlock;
#ifdef CONFIG_SMP
- unsigned int batchcount;
+ volatile unsigned int batchcount;
#endif
/* 2) slab additions /removals */
@@ -1637,11 +1637,19 @@
}
}
new.cachep = cachep;
- spin_lock_irq(&cachep->spinlock);
- cachep->batchcount = batchcount;
- spin_unlock_irq(&cachep->spinlock);
+ if(batchcount < cachep->batchcount) {
+ spin_lock_irq(&cachep->spinlock);
+ cachep->batchcount = batchcount;
+ spin_unlock_irq(&cachep->spinlock);
+ }
smp_call_function_all_cpus(do_ccupdate_local, (void *)&new);
+
+ if(batchcount > cachep->batchcount) {
+ spin_lock_irq(&cachep->spinlock);
+ cachep->batchcount = batchcount;
+ spin_unlock_irq(&cachep->spinlock);
+ }
for (i = 0; i < smp_num_cpus; i++) {
cpucache_t* ccold = new.new[cpu_logical_map(i)];
>>>>>>>>>>>>>>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
reply other threads:[~2000-12-10 13:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Pine.LNX.4.21.0012101224560.1447-100000@clmsdevli \
--to=manfred@colorfullife.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).