Skip to content

Commit

Permalink
pid: tighten pidmap spinlock critical section by removing kfree()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
andre-rosa authored and torvalds committed Dec 16, 2009
1 parent 698ba7b commit 7be6d99
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kernel/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7be6d99

Please sign in to comment.