]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
kernel/pid.c: improve flow of a loop inside alloc_pidmap.
authorRaphael S. Carvalho <raphael.scarv@gmail.com>
Sat, 23 Mar 2013 02:32:56 +0000 (13:32 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 26 Mar 2013 05:11:38 +0000 (16:11 +1100)
find_next_offset() searches for an available "cleaned bit" in the
respective pid bitmap (page), so returns the offset if found, otherwise it
returns a value equals to BITS_PER_PAGE.

For example, suppose find_next_offset didn't find any available bit, so
there's no purpose to call mk_pid (Wasteful Cpu Cycles).

Therefore, I found it could be better to call mk_pid after the checking
(offset < BITS_PER_PAGE) returned sucessfully!  Another point: If (offset
< BITS_PER_PAGE) results in a "failure", then mk_pid would be called again
afterwards.

Signed-off-by: Raphael S. Carvalho <raphael.scarv@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/pid.c

index 047dc62646389fd5abdf5fc63cb8db963a1a5b60..53a78d41331c7e16b0d8ec42eb97ac531f364332 100644 (file)
@@ -190,8 +190,8 @@ static int alloc_pidmap(struct pid_namespace *pid_ns)
                                        return pid;
                                }
                                offset = find_next_offset(map, offset);
-                               pid = mk_pid(pid_ns, map, offset);
-                       } while (offset < BITS_PER_PAGE && pid < pid_max);
+                       } while (offset < BITS_PER_PAGE &&
+                               (pid = mk_pid(pid_ns, map, offset)) < pid_max);
                }
                if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) {
                        ++map;