Lines Matching refs:pid
46 struct pid init_struct_pid = {
103 void put_pid(struct pid *pid) in put_pid() argument
107 if (!pid) in put_pid()
110 ns = pid->numbers[pid->level].ns; in put_pid()
111 if (refcount_dec_and_test(&pid->count)) { in put_pid()
112 kmem_cache_free(ns->pid_cachep, pid); in put_pid()
120 struct pid *pid = container_of(rhp, struct pid, rcu); in delayed_put_pid() local
121 put_pid(pid); in delayed_put_pid()
124 void free_pid(struct pid *pid) in free_pid() argument
131 for (i = 0; i <= pid->level; i++) { in free_pid()
132 struct upid *upid = pid->numbers + i; in free_pid()
157 call_rcu(&pid->rcu, delayed_put_pid); in free_pid()
160 struct pid *alloc_pid(struct pid_namespace *ns) in alloc_pid()
162 struct pid *pid; in alloc_pid() local
169 pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL); in alloc_pid()
170 if (!pid) in alloc_pid()
174 pid->level = ns->level; in alloc_pid()
203 pid->numbers[i].nr = nr; in alloc_pid()
204 pid->numbers[i].ns = tmp; in alloc_pid()
208 if (unlikely(is_child_reaper(pid))) { in alloc_pid()
214 refcount_set(&pid->count, 1); in alloc_pid()
216 INIT_HLIST_HEAD(&pid->tasks[type]); in alloc_pid()
218 init_waitqueue_head(&pid->wait_pidfd); in alloc_pid()
220 upid = pid->numbers + ns->level; in alloc_pid()
224 for ( ; upid >= pid->numbers; --upid) { in alloc_pid()
226 idr_replace(&upid->ns->idr, pid, upid->nr); in alloc_pid()
231 return pid; in alloc_pid()
240 upid = pid->numbers + i; in alloc_pid()
250 kmem_cache_free(ns->pid_cachep, pid); in alloc_pid()
261 struct pid *find_pid_ns(int nr, struct pid_namespace *ns) in find_pid_ns()
267 struct pid *find_vpid(int nr) in find_vpid()
273 static struct pid **task_pid_ptr(struct task_struct *task, enum pid_type type) in task_pid_ptr()
285 struct pid *pid = *task_pid_ptr(task, type); in attach_pid() local
286 hlist_add_head_rcu(&task->pid_links[type], &pid->tasks[type]); in attach_pid()
290 struct pid *new) in __change_pid()
292 struct pid **pid_ptr = task_pid_ptr(task, type); in __change_pid()
293 struct pid *pid; in __change_pid() local
296 pid = *pid_ptr; in __change_pid()
302 if (!hlist_empty(&pid->tasks[tmp])) in __change_pid()
305 free_pid(pid); in __change_pid()
314 struct pid *pid) in change_pid() argument
316 __change_pid(task, type, pid); in change_pid()
329 struct task_struct *pid_task(struct pid *pid, enum pid_type type) in pid_task() argument
332 if (pid) { in pid_task()
334 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]), in pid_task()
371 struct pid *get_task_pid(struct task_struct *task, enum pid_type type) in get_task_pid()
373 struct pid *pid; in get_task_pid() local
375 pid = get_pid(rcu_dereference(*task_pid_ptr(task, type))); in get_task_pid()
377 return pid; in get_task_pid()
381 struct task_struct *get_pid_task(struct pid *pid, enum pid_type type) in get_pid_task() argument
385 result = pid_task(pid, type); in get_pid_task()
393 struct pid *find_get_pid(pid_t nr) in find_get_pid()
395 struct pid *pid; in find_get_pid() local
398 pid = get_pid(find_vpid(nr)); in find_get_pid()
401 return pid; in find_get_pid()
405 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns) in pid_nr_ns() argument
410 if (pid && ns->level <= pid->level) { in pid_nr_ns()
411 upid = &pid->numbers[ns->level]; in pid_nr_ns()
419 pid_t pid_vnr(struct pid *pid) in pid_vnr() argument
421 return pid_nr_ns(pid, task_active_pid_ns(current)); in pid_vnr()
452 struct pid *find_ge_pid(int nr, struct pid_namespace *ns) in find_ge_pid()
470 static int pidfd_create(struct pid *pid) in pidfd_create() argument
474 fd = anon_inode_getfd("[pidfd]", &pidfd_fops, get_pid(pid), in pidfd_create()
477 put_pid(pid); in pidfd_create()
498 SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags) in SYSCALL_DEFINE2() argument
501 struct pid *p; in SYSCALL_DEFINE2()
506 if (pid <= 0) in SYSCALL_DEFINE2()
509 p = find_get_pid(pid); in SYSCALL_DEFINE2()
538 init_pid_ns.pid_cachep = KMEM_CACHE(pid, in pid_idr_init()