Commit 90c5029e authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] Undo mempolicy shared policy rbtree microoptimization

All mempolicy changes must be inside the spinlock and readding the rb_erase
prevents a crash while doing:

> echo "1" > /tmp/numatest
> numactl --length=0x4000 --shm /tmp/numatest --localalloc
> numactl --length=0x2000 --offset=0 --shm /tmp/numatest --membind=0
> numactl --length=0x2000 --offset=0x2000 --shm /tmp/numatest --membind=1
> ipcs
> ipcrm -M "the_key_value_of_this_shm_area"

Based on a patch by John Blackwood

Cc: <john.blackwood@ccur.com>
Cc: <andrea@suse.de>
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c2236956
...@@ -1138,11 +1138,11 @@ void mpol_free_shared_policy(struct shared_policy *p) ...@@ -1138,11 +1138,11 @@ void mpol_free_shared_policy(struct shared_policy *p)
while (next) { while (next) {
n = rb_entry(next, struct sp_node, nd); n = rb_entry(next, struct sp_node, nd);
next = rb_next(&n->nd); next = rb_next(&n->nd);
rb_erase(&n->nd, &p->root);
mpol_free(n->policy); mpol_free(n->policy);
kmem_cache_free(sn_cache, n); kmem_cache_free(sn_cache, n);
} }
spin_unlock(&p->lock); spin_unlock(&p->lock);
p->root = RB_ROOT;
} }
/* assumes fs == KERNEL_DS */ /* assumes fs == KERNEL_DS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment