From 886e4e832d5969ff14a979985ed2fb297e278a15 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 20 Mar 2013 15:08:43 +1100 Subject: [PATCH] kernel-pidc-improve-flow-of-a-loop-inside-alloc_pidmap-fix simplify code Cc: Raphael S. Carvalho Cc: "Eric W. Biederman" Cc: Serge Hallyn Signed-off-by: Andrew Morton --- kernel/pid.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/pid.c b/kernel/pid.c index 53a78d41331c..8147bdf22f36 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -183,15 +183,19 @@ static int alloc_pidmap(struct pid_namespace *pid_ns) break; } if (likely(atomic_read(&map->nr_free))) { - do { + for ( ; ; ) { if (!test_and_set_bit(offset, map->page)) { atomic_dec(&map->nr_free); set_last_pid(pid_ns, last, pid); return pid; } offset = find_next_offset(map, offset); - } while (offset < BITS_PER_PAGE && - (pid = mk_pid(pid_ns, map, offset)) < pid_max); + if (offset >= BITS_PER_PAGE) + break; + pid = mk_pid(pid_ns, map, offset); + if (pid >= pid_max) + break; + } } if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) { ++map; -- 2.39.5