summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Goddard Rosa <andre.goddard@gmail.com>2009-12-16 01:47:39 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-16 16:20:12 +0100
commit7be6d991bca63bbcdc5bc3b09789f367a3486537 (patch)
tree79168c345c424ce7b80bfba382c9dc469bdcc70a
parentelf: kill USE_ELF_CORE_DUMP (diff)
downloadlinux-7be6d991bca63bbcdc5bc3b09789f367a3486537.tar.xz
linux-7be6d991bca63bbcdc5bc3b09789f367a3486537.zip
pid: tighten pidmap spinlock critical section by removing kfree()
Avoid calling kfree() under pidmap spinlock, calling it afterwards. Normally kfree() is fast, but sometimes it can be slow, so avoid calling it under the spinlock if we can do it. Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/pid.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/kernel/pid.c b/kernel/pid.c
index d3f722d20f9c..55fd5900bac8 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -141,11 +141,12 @@ static int alloc_pidmap(struct pid_namespace *pid_ns)
* installing it:
*/
spin_lock_irq(&pidmap_lock);
- if (map->page)
- kfree(page);
- else
+ if (!map->page) {
map->page = page;
+ page = NULL;
+ }
spin_unlock_irq(&pidmap_lock);
+ kfree(page);
if (unlikely(!map->page))
break;
}