Lines Matching refs:pid
46 struct pid init_struct_pid = INIT_STRUCT_PID;
141 static void set_last_pid(struct pid_namespace *pid_ns, int base, int pid) in set_last_pid() argument
147 last_write = cmpxchg(&pid_ns->last_pid, prev, pid); in set_last_pid()
148 } while ((prev != last_write) && (pid_before(base, last_write, pid))); in set_last_pid()
153 int i, offset, max_scan, pid, last = pid_ns->last_pid; in alloc_pidmap() local
156 pid = last + 1; in alloc_pidmap()
157 if (pid >= pid_max) in alloc_pidmap()
158 pid = RESERVED_PIDS; in alloc_pidmap()
159 offset = pid & BITS_PER_PAGE_MASK; in alloc_pidmap()
160 map = &pid_ns->pidmap[pid/BITS_PER_PAGE]; in alloc_pidmap()
188 set_last_pid(pid_ns, last, pid); in alloc_pidmap()
189 return pid; in alloc_pidmap()
194 pid = mk_pid(pid_ns, map, offset); in alloc_pidmap()
195 if (pid >= pid_max) in alloc_pidmap()
208 pid = mk_pid(pid_ns, map, offset); in alloc_pidmap()
234 void put_pid(struct pid *pid) in put_pid() argument
238 if (!pid) in put_pid()
241 ns = pid->numbers[pid->level].ns; in put_pid()
242 if ((atomic_read(&pid->count) == 1) || in put_pid()
243 atomic_dec_and_test(&pid->count)) { in put_pid()
244 kmem_cache_free(ns->pid_cachep, pid); in put_pid()
252 struct pid *pid = container_of(rhp, struct pid, rcu); in delayed_put_pid() local
253 put_pid(pid); in delayed_put_pid()
256 void free_pid(struct pid *pid) in free_pid() argument
263 for (i = 0; i <= pid->level; i++) { in free_pid()
264 struct upid *upid = pid->numbers + i; in free_pid()
288 for (i = 0; i <= pid->level; i++) in free_pid()
289 free_pidmap(pid->numbers + i); in free_pid()
291 call_rcu(&pid->rcu, delayed_put_pid); in free_pid()
294 struct pid *alloc_pid(struct pid_namespace *ns) in alloc_pid()
296 struct pid *pid; in alloc_pid() local
302 pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL); in alloc_pid()
303 if (!pid) in alloc_pid()
307 pid->level = ns->level; in alloc_pid()
313 pid->numbers[i].nr = nr; in alloc_pid()
314 pid->numbers[i].ns = tmp; in alloc_pid()
318 if (unlikely(is_child_reaper(pid))) { in alloc_pid()
324 atomic_set(&pid->count, 1); in alloc_pid()
326 INIT_HLIST_HEAD(&pid->tasks[type]); in alloc_pid()
328 upid = pid->numbers + ns->level; in alloc_pid()
332 for ( ; upid >= pid->numbers; --upid) { in alloc_pid()
340 return pid; in alloc_pid()
348 free_pidmap(pid->numbers + i); in alloc_pid()
350 kmem_cache_free(ns->pid_cachep, pid); in alloc_pid()
351 pid = NULL; in alloc_pid()
362 struct pid *find_pid_ns(int nr, struct pid_namespace *ns) in find_pid_ns()
369 return container_of(pnr, struct pid, in find_pid_ns()
376 struct pid *find_vpid(int nr) in find_vpid()
388 hlist_add_head_rcu(&link->node, &link->pid->tasks[type]); in attach_pid()
392 struct pid *new) in __change_pid()
395 struct pid *pid; in __change_pid() local
399 pid = link->pid; in __change_pid()
402 link->pid = new; in __change_pid()
405 if (!hlist_empty(&pid->tasks[tmp])) in __change_pid()
408 free_pid(pid); in __change_pid()
417 struct pid *pid) in change_pid() argument
419 __change_pid(task, type, pid); in change_pid()
427 new->pids[type].pid = old->pids[type].pid; in transfer_pid()
431 struct task_struct *pid_task(struct pid *pid, enum pid_type type) in pid_task() argument
434 if (pid) { in pid_task()
436 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]), in pid_task()
461 struct pid *get_task_pid(struct task_struct *task, enum pid_type type) in get_task_pid()
463 struct pid *pid; in get_task_pid() local
467 pid = get_pid(task->pids[type].pid); in get_task_pid()
469 return pid; in get_task_pid()
473 struct task_struct *get_pid_task(struct pid *pid, enum pid_type type) in get_pid_task() argument
477 result = pid_task(pid, type); in get_pid_task()
485 struct pid *find_get_pid(pid_t nr) in find_get_pid()
487 struct pid *pid; in find_get_pid() local
490 pid = get_pid(find_vpid(nr)); in find_get_pid()
493 return pid; in find_get_pid()
497 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns) in pid_nr_ns() argument
502 if (pid && ns->level <= pid->level) { in pid_nr_ns()
503 upid = &pid->numbers[ns->level]; in pid_nr_ns()
511 pid_t pid_vnr(struct pid *pid) in pid_vnr() argument
513 return pid_nr_ns(pid, task_active_pid_ns(current)); in pid_vnr()
531 nr = pid_nr_ns(task->pids[type].pid, ns); in __task_pid_nr_ns()
550 struct pid *find_ge_pid(int nr, struct pid_namespace *ns) in find_ge_pid()
552 struct pid *pid; in find_ge_pid() local
555 pid = find_pid_ns(nr, ns); in find_ge_pid()
556 if (pid) in find_ge_pid()
561 return pid; in find_ge_pid()
600 init_pid_ns.pid_cachep = KMEM_CACHE(pid, in pidmap_init()