Lines Matching refs:pid

50 struct pid init_struct_pid = {
90 void put_pid(struct pid *pid) in put_pid() argument
94 if (!pid) in put_pid()
97 ns = pid->numbers[pid->level].ns; in put_pid()
98 if (refcount_dec_and_test(&pid->count)) { in put_pid()
99 pidfs_free_pid(pid); in put_pid()
100 kmem_cache_free(ns->pid_cachep, pid); in put_pid()
108 struct pid *pid = container_of(rhp, struct pid, rcu); in delayed_put_pid() local
109 put_pid(pid); in delayed_put_pid()
112 void free_pid(struct pid *pid) in free_pid() argument
119 active_ns = pid->numbers[pid->level].ns; in free_pid()
123 for (i = 0; i <= pid->level; i++) { in free_pid()
124 struct upid *upid = pid->numbers + i; in free_pid()
144 pidfs_remove_pid(pid); in free_pid()
147 call_rcu(&pid->rcu, delayed_put_pid); in free_pid()
150 void free_pids(struct pid **pids) in free_pids()
162 struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid, in alloc_pid()
165 struct pid *pid; in alloc_pid() local
183 pid = kmem_cache_alloc(ns->pid_cachep, GFP_KERNEL); in alloc_pid()
184 if (!pid) in alloc_pid()
188 pid->level = ns->level; in alloc_pid()
248 pid->numbers[i].nr = nr; in alloc_pid()
249 pid->numbers[i].ns = tmp; in alloc_pid()
264 refcount_set(&pid->count, 1); in alloc_pid()
265 spin_lock_init(&pid->lock); in alloc_pid()
267 INIT_HLIST_HEAD(&pid->tasks[type]); in alloc_pid()
269 init_waitqueue_head(&pid->wait_pidfd); in alloc_pid()
270 INIT_HLIST_HEAD(&pid->inodes); in alloc_pid()
272 upid = pid->numbers + ns->level; in alloc_pid()
277 pidfs_add_pid(pid); in alloc_pid()
278 for ( ; upid >= pid->numbers; --upid) { in alloc_pid()
280 idr_replace(&upid->ns->idr, pid, upid->nr); in alloc_pid()
287 return pid; in alloc_pid()
297 upid = pid->numbers + i; in alloc_pid()
307 kmem_cache_free(ns->pid_cachep, pid); in alloc_pid()
318 struct pid *find_pid_ns(int nr, struct pid_namespace *ns) in find_pid_ns()
324 struct pid *find_vpid(int nr) in find_vpid()
330 static struct pid **task_pid_ptr(struct task_struct *task, enum pid_type type) in task_pid_ptr()
342 struct pid *pid; in attach_pid() local
346 pid = *task_pid_ptr(task, type); in attach_pid()
347 hlist_add_head_rcu(&task->pid_links[type], &pid->tasks[type]); in attach_pid()
350 static void __change_pid(struct pid **pids, struct task_struct *task, in __change_pid()
351 enum pid_type type, struct pid *new) in __change_pid()
353 struct pid **pid_ptr, *pid; in __change_pid() local
359 pid = *pid_ptr; in __change_pid()
365 if (pid_has_task(pid, tmp)) in __change_pid()
369 pids[type] = pid; in __change_pid()
372 void detach_pid(struct pid **pids, struct task_struct *task, enum pid_type type) in detach_pid()
377 void change_pid(struct pid **pids, struct task_struct *task, enum pid_type type, in change_pid()
378 struct pid *pid) in change_pid() argument
380 __change_pid(pids, task, type, pid); in change_pid()
386 struct pid *pid1 = left->thread_pid; in exchange_tids()
387 struct pid *pid2 = right->thread_pid; in exchange_tids()
401 WRITE_ONCE(left->pid, pid_nr(pid2)); in exchange_tids()
402 WRITE_ONCE(right->pid, pid_nr(pid1)); in exchange_tids()
414 struct task_struct *pid_task(struct pid *pid, enum pid_type type) in pid_task() argument
417 if (pid) { in pid_task()
419 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]), in pid_task()
456 struct pid *get_task_pid(struct task_struct *task, enum pid_type type) in get_task_pid()
458 struct pid *pid; in get_task_pid() local
460 pid = get_pid(rcu_dereference(*task_pid_ptr(task, type))); in get_task_pid()
462 return pid; in get_task_pid()
466 struct task_struct *get_pid_task(struct pid *pid, enum pid_type type) in get_pid_task() argument
470 result = pid_task(pid, type); in get_pid_task()
478 struct pid *find_get_pid(pid_t nr) in find_get_pid()
480 struct pid *pid; in find_get_pid() local
483 pid = get_pid(find_vpid(nr)); in find_get_pid()
486 return pid; in find_get_pid()
490 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns) in pid_nr_ns() argument
495 if (pid && ns && ns->level <= pid->level) { in pid_nr_ns()
496 upid = &pid->numbers[ns->level]; in pid_nr_ns()
504 pid_t pid_vnr(struct pid *pid) in pid_vnr() argument
506 return pid_nr_ns(pid, task_active_pid_ns(current)); in pid_vnr()
537 struct pid *find_ge_pid(int nr, struct pid_namespace *ns) in find_ge_pid()
543 struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags) in pidfd_get_pid()
546 struct pid *pid; in pidfd_get_pid() local
551 pid = pidfd_pid(fd_file(f)); in pidfd_get_pid()
552 if (!IS_ERR(pid)) { in pidfd_get_pid()
553 get_pid(pid); in pidfd_get_pid()
556 return pid; in pidfd_get_pid()
574 struct pid *pid; in pidfd_get_task() local
581 pid = get_task_pid(current, type); in pidfd_get_task()
585 pid = get_task_pid(current, type); in pidfd_get_task()
588 pid = pidfd_get_pid(pidfd, &f_flags); in pidfd_get_task()
589 if (IS_ERR(pid)) in pidfd_get_task()
590 return ERR_CAST(pid); in pidfd_get_task()
595 task = get_pid_task(pid, type); in pidfd_get_task()
596 put_pid(pid); in pidfd_get_task()
620 static int pidfd_create(struct pid *pid, unsigned int flags) in pidfd_create() argument
625 pidfd = pidfd_prepare(pid, flags, &pidfd_file); in pidfd_create()
646 SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags) in SYSCALL_DEFINE2() argument
649 struct pid *p; in SYSCALL_DEFINE2()
654 if (pid <= 0) in SYSCALL_DEFINE2()
657 p = find_get_pid(pid); in SYSCALL_DEFINE2()
721 struct pid *new_pid; in proc_do_cad_pid()
814 struct_size_t(struct pid, numbers, 1), in pid_idr_init()
815 __alignof__(struct pid), in pid_idr_init()
868 static int pidfd_getfd(struct pid *pid, int fd) in pidfd_getfd() argument
874 task = get_pid_task(pid, PIDTYPE_PID); in pidfd_getfd()
908 struct pid *pid; in SYSCALL_DEFINE3() local
918 pid = pidfd_pid(fd_file(f)); in SYSCALL_DEFINE3()
919 if (IS_ERR(pid)) in SYSCALL_DEFINE3()
920 return PTR_ERR(pid); in SYSCALL_DEFINE3()
922 return pidfd_getfd(pid, fd); in SYSCALL_DEFINE3()