diff options
Diffstat (limited to 'kernel/pid.c')
-rw-r--r-- | kernel/pid.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index 047dc6264638..6283d6412aff 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -51,9 +51,6 @@ int pid_max = PID_MAX_DEFAULT; | |||
51 | int pid_max_min = RESERVED_PIDS + 1; | 51 | int pid_max_min = RESERVED_PIDS + 1; |
52 | int pid_max_max = PID_MAX_LIMIT; | 52 | int pid_max_max = PID_MAX_LIMIT; |
53 | 53 | ||
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, | 54 | static inline int mk_pid(struct pid_namespace *pid_ns, |
58 | struct pidmap *map, int off) | 55 | struct pidmap *map, int off) |
59 | { | 56 | { |
@@ -183,15 +180,19 @@ static int alloc_pidmap(struct pid_namespace *pid_ns) | |||
183 | break; | 180 | break; |
184 | } | 181 | } |
185 | if (likely(atomic_read(&map->nr_free))) { | 182 | if (likely(atomic_read(&map->nr_free))) { |
186 | do { | 183 | for ( ; ; ) { |
187 | if (!test_and_set_bit(offset, map->page)) { | 184 | if (!test_and_set_bit(offset, map->page)) { |
188 | atomic_dec(&map->nr_free); | 185 | atomic_dec(&map->nr_free); |
189 | set_last_pid(pid_ns, last, pid); | 186 | set_last_pid(pid_ns, last, pid); |
190 | return pid; | 187 | return pid; |
191 | } | 188 | } |
192 | offset = find_next_offset(map, offset); | 189 | offset = find_next_offset(map, offset); |
190 | if (offset >= BITS_PER_PAGE) | ||
191 | break; | ||
193 | pid = mk_pid(pid_ns, map, offset); | 192 | pid = mk_pid(pid_ns, map, offset); |
194 | } while (offset < BITS_PER_PAGE && pid < pid_max); | 193 | if (pid >= pid_max) |
194 | break; | ||
195 | } | ||
195 | } | 196 | } |
196 | if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) { | 197 | if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) { |
197 | ++map; | 198 | ++map; |