]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - kernel/pid.c
kernel/pid.c: improve flow of a loop inside alloc_pidmap.
[karo-tx-linux.git] / kernel / pid.c
index 047dc62646389fd5abdf5fc63cb8db963a1a5b60..8147bdf22f36a498f0ed108be8e50b20d5f02ed5 100644 (file)
@@ -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);
+                               if (offset >= BITS_PER_PAGE)
+                                       break;
                                pid = mk_pid(pid_ns, map, offset);
-                       } while (offset < BITS_PER_PAGE && pid < pid_max);
+                               if (pid >= pid_max)
+                                       break;
+                       }
                }
                if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) {
                        ++map;