diff options
Diffstat (limited to 'kernel/pid.c')
-rw-r--r-- | kernel/pid.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index 047dc6264638..0db3e791a06d 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/pid_namespace.h> | 36 | #include <linux/pid_namespace.h> |
37 | #include <linux/init_task.h> | 37 | #include <linux/init_task.h> |
38 | #include <linux/syscalls.h> | 38 | #include <linux/syscalls.h> |
39 | #include <linux/proc_ns.h> | ||
39 | #include <linux/proc_fs.h> | 40 | #include <linux/proc_fs.h> |
40 | 41 | ||
41 | #define pid_hashfn(nr, ns) \ | 42 | #define pid_hashfn(nr, ns) \ |
@@ -51,9 +52,6 @@ int pid_max = PID_MAX_DEFAULT; | |||
51 | int pid_max_min = RESERVED_PIDS + 1; | 52 | int pid_max_min = RESERVED_PIDS + 1; |
52 | int pid_max_max = PID_MAX_LIMIT; | 53 | int pid_max_max = PID_MAX_LIMIT; |
53 | 54 | ||
54 | #define BITS_PER_PAGE (PAGE_SIZE*8) | ||
55 | #define BITS_PER_PAGE_MASK (BITS_PER_PAGE-1) | ||
56 | |||
57 | static inline int mk_pid(struct pid_namespace *pid_ns, | 55 | static inline int mk_pid(struct pid_namespace *pid_ns, |
58 | struct pidmap *map, int off) | 56 | struct pidmap *map, int off) |
59 | { | 57 | { |
@@ -183,15 +181,19 @@ static int alloc_pidmap(struct pid_namespace *pid_ns) | |||
183 | break; | 181 | break; |
184 | } | 182 | } |
185 | if (likely(atomic_read(&map->nr_free))) { | 183 | if (likely(atomic_read(&map->nr_free))) { |
186 | do { | 184 | for ( ; ; ) { |
187 | if (!test_and_set_bit(offset, map->page)) { | 185 | if (!test_and_set_bit(offset, map->page)) { |
188 | atomic_dec(&map->nr_free); | 186 | atomic_dec(&map->nr_free); |
189 | set_last_pid(pid_ns, last, pid); | 187 | set_last_pid(pid_ns, last, pid); |
190 | return pid; | 188 | return pid; |
191 | } | 189 | } |
192 | offset = find_next_offset(map, offset); | 190 | offset = find_next_offset(map, offset); |
191 | if (offset >= BITS_PER_PAGE) | ||
192 | break; | ||
193 | pid = mk_pid(pid_ns, map, offset); | 193 | pid = mk_pid(pid_ns, map, offset); |
194 | } while (offset < BITS_PER_PAGE && pid < pid_max); | 194 | if (pid >= pid_max) |
195 | break; | ||
196 | } | ||
195 | } | 197 | } |
196 | if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) { | 198 | if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) { |
197 | ++map; | 199 | ++map; |