From: André Goddard Rosa Date: Wed, 16 Dec 2009 00:47:39 +0000 (-0800) Subject: pid: tighten pidmap spinlock critical section by removing kfree() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7be6d991bca63bbcdc5bc3b09789f367a3486537;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Cc: Pekka Enberg Cc: Oleg Nesterov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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; }