diff options
Diffstat (limited to 'kernel/pid.c')
-rw-r--r-- | kernel/pid.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index 8387e8c681..ed89a73243 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -145,6 +145,23 @@ static int alloc_pidmap(void) | |||
145 | return -1; | 145 | return -1; |
146 | } | 146 | } |
147 | 147 | ||
148 | static int next_pidmap(int last) | ||
149 | { | ||
150 | int offset; | ||
151 | pidmap_t *map; | ||
152 | |||
153 | offset = (last + 1) & BITS_PER_PAGE_MASK; | ||
154 | map = &pidmap_array[(last + 1)/BITS_PER_PAGE]; | ||
155 | for (; map < &pidmap_array[PIDMAP_ENTRIES]; map++, offset = 0) { | ||
156 | if (unlikely(!map->page)) | ||
157 | continue; | ||
158 | offset = find_next_bit((map)->page, BITS_PER_PAGE, offset); | ||
159 | if (offset < BITS_PER_PAGE) | ||
160 | return mk_pid(map, offset); | ||
161 | } | ||
162 | return -1; | ||
163 | } | ||
164 | |||
148 | fastcall void put_pid(struct pid *pid) | 165 | fastcall void put_pid(struct pid *pid) |
149 | { | 166 | { |
150 | if (!pid) | 167 | if (!pid) |
@@ -303,6 +320,25 @@ struct pid *find_get_pid(pid_t nr) | |||
303 | } | 320 | } |
304 | 321 | ||
305 | /* | 322 | /* |
323 | * Used by proc to find the first pid that is greater then or equal to nr. | ||
324 | * | ||
325 | * If there is a pid at nr this function is exactly the same as find_pid. | ||
326 | */ | ||
327 | struct pid *find_ge_pid(int nr) | ||
328 | { | ||
329 | struct pid *pid; | ||
330 | |||
331 | do { | ||
332 | pid = find_pid(nr); | ||
333 | if (pid) | ||
334 | break; | ||
335 | nr = next_pidmap(nr); | ||
336 | } while (nr > 0); | ||
337 | |||
338 | return pid; | ||
339 | } | ||
340 | |||
341 | /* | ||
306 | * The pid hash table is scaled according to the amount of memory in the | 342 | * The pid hash table is scaled according to the amount of memory in the |
307 | * machine. From a minimum of 16 slots up to 4096 slots at one gigabyte or | 343 | * machine. From a minimum of 16 slots up to 4096 slots at one gigabyte or |
308 | * more. | 344 | * more. |