Lines Matching refs:p

123 static void __unhash_process(struct task_struct *p, bool group_dead)  in __unhash_process()  argument
126 detach_pid(p, PIDTYPE_PID); in __unhash_process()
128 detach_pid(p, PIDTYPE_TGID); in __unhash_process()
129 detach_pid(p, PIDTYPE_PGID); in __unhash_process()
130 detach_pid(p, PIDTYPE_SID); in __unhash_process()
132 list_del_rcu(&p->tasks); in __unhash_process()
133 list_del_init(&p->sibling); in __unhash_process()
136 list_del_rcu(&p->thread_group); in __unhash_process()
137 list_del_rcu(&p->thread_node); in __unhash_process()
239 void release_task(struct task_struct *p) in release_task() argument
248 dec_rlimit_ucounts(task_ucounts(p), UCOUNT_RLIMIT_NPROC, 1); in release_task()
251 cgroup_release(p); in release_task()
254 ptrace_release_task(p); in release_task()
255 thread_pid = get_pid(p->thread_pid); in release_task()
256 __exit_signal(p); in release_task()
264 leader = p->group_leader; in release_task()
265 if (leader != p && thread_group_empty(leader) in release_task()
278 seccomp_filter_release(p); in release_task()
281 release_thread(p); in release_task()
282 put_task_struct_rcu_user(p); in release_task()
284 p = leader; in release_task()
329 struct task_struct *p; in will_become_orphaned_pgrp() local
331 do_each_pid_task(pgrp, PIDTYPE_PGID, p) { in will_become_orphaned_pgrp()
332 if ((p == ignored_task) || in will_become_orphaned_pgrp()
333 (p->exit_state && thread_group_empty(p)) || in will_become_orphaned_pgrp()
334 is_global_init(p->real_parent)) in will_become_orphaned_pgrp()
337 if (task_pgrp(p->real_parent) != pgrp && in will_become_orphaned_pgrp()
338 task_session(p->real_parent) == task_session(p)) in will_become_orphaned_pgrp()
340 } while_each_pid_task(pgrp, PIDTYPE_PGID, p); in will_become_orphaned_pgrp()
358 struct task_struct *p; in has_stopped_jobs() local
360 do_each_pid_task(pgrp, PIDTYPE_PGID, p) { in has_stopped_jobs()
361 if (p->signal->flags & SIGNAL_STOP_STOPPED) in has_stopped_jobs()
363 } while_each_pid_task(pgrp, PIDTYPE_PGID, p); in has_stopped_jobs()
448 struct task_struct *c, *g, *p = current; in mm_update_next_owner() local
455 if (mm->owner != p) in mm_update_next_owner()
471 list_for_each_entry(c, &p->children, sibling) { in mm_update_next_owner()
479 list_for_each_entry(c, &p->real_parent->children, sibling) { in mm_update_next_owner()
509 BUG_ON(c == p); in mm_update_next_owner()
574 static struct task_struct *find_alive_thread(struct task_struct *p) in find_alive_thread() argument
578 for_each_thread(p, t) { in find_alive_thread()
592 struct task_struct *p, *n; in find_child_reaper() local
605 list_for_each_entry_safe(p, n, dead, ptrace_entry) { in find_child_reaper()
606 list_del_init(&p->ptrace_entry); in find_child_reaper()
607 release_task(p); in find_child_reaper()
661 static void reparent_leader(struct task_struct *father, struct task_struct *p, in reparent_leader() argument
664 if (unlikely(p->exit_state == EXIT_DEAD)) in reparent_leader()
668 p->exit_signal = SIGCHLD; in reparent_leader()
671 if (!p->ptrace && in reparent_leader()
672 p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) { in reparent_leader()
673 if (do_notify_parent(p, p->exit_signal)) { in reparent_leader()
674 p->exit_state = EXIT_DEAD; in reparent_leader()
675 list_add(&p->ptrace_entry, dead); in reparent_leader()
679 kill_orphaned_pgrp(p, father); in reparent_leader()
693 struct task_struct *p, *t, *reaper; in forget_original_parent() local
704 list_for_each_entry(p, &father->children, sibling) { in forget_original_parent()
705 for_each_thread(p, t) { in forget_original_parent()
720 reparent_leader(father, p, dead); in forget_original_parent()
732 struct task_struct *p, *n; in exit_notify() local
765 list_for_each_entry_safe(p, n, &dead, ptrace_entry) { in exit_notify()
766 list_del_init(&p->ptrace_entry); in exit_notify()
767 release_task(p); in exit_notify()
1059 static int eligible_pid(struct wait_opts *wo, struct task_struct *p) in eligible_pid() argument
1062 task_pid_type(p, wo->wo_type) == wo->wo_pid; in eligible_pid()
1066 eligible_child(struct wait_opts *wo, bool ptrace, struct task_struct *p) in eligible_child() argument
1068 if (!eligible_pid(wo, p)) in eligible_child()
1086 if ((p->exit_signal != SIGCHLD) ^ !!(wo->wo_flags & __WCLONE)) in eligible_child()
1098 static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p) in wait_task_zombie() argument
1101 pid_t pid = task_pid_vnr(p); in wait_task_zombie()
1102 uid_t uid = from_kuid_munged(current_user_ns(), task_uid(p)); in wait_task_zombie()
1109 status = (p->signal->flags & SIGNAL_GROUP_EXIT) in wait_task_zombie()
1110 ? p->signal->group_exit_code : p->exit_code; in wait_task_zombie()
1111 get_task_struct(p); in wait_task_zombie()
1115 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_zombie()
1116 put_task_struct(p); in wait_task_zombie()
1122 state = (ptrace_reparented(p) && thread_group_leader(p)) ? in wait_task_zombie()
1124 if (cmpxchg(&p->exit_state, EXIT_ZOMBIE, state) != EXIT_ZOMBIE) in wait_task_zombie()
1135 if (state == EXIT_DEAD && thread_group_leader(p)) { in wait_task_zombie()
1136 struct signal_struct *sig = p->signal; in wait_task_zombie()
1161 thread_group_cputime_adjusted(p, &tgutime, &tgstime); in wait_task_zombie()
1166 psig->cgtime += task_gtime(p) + sig->gtime + sig->cgtime; in wait_task_zombie()
1168 p->min_flt + sig->min_flt + sig->cmin_flt; in wait_task_zombie()
1170 p->maj_flt + sig->maj_flt + sig->cmaj_flt; in wait_task_zombie()
1172 p->nvcsw + sig->nvcsw + sig->cnvcsw; in wait_task_zombie()
1174 p->nivcsw + sig->nivcsw + sig->cnivcsw; in wait_task_zombie()
1176 task_io_get_inblock(p) + in wait_task_zombie()
1179 task_io_get_oublock(p) + in wait_task_zombie()
1184 task_io_accounting_add(&psig->ioac, &p->ioac); in wait_task_zombie()
1191 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_zombie()
1192 status = (p->signal->flags & SIGNAL_GROUP_EXIT) in wait_task_zombie()
1193 ? p->signal->group_exit_code : p->exit_code; in wait_task_zombie()
1199 ptrace_unlink(p); in wait_task_zombie()
1203 if (do_notify_parent(p, p->exit_signal)) in wait_task_zombie()
1205 p->exit_state = state; in wait_task_zombie()
1209 release_task(p); in wait_task_zombie()
1228 static int *task_stopped_code(struct task_struct *p, bool ptrace) in task_stopped_code() argument
1231 if (task_is_traced(p) && !(p->jobctl & JOBCTL_LISTENING)) in task_stopped_code()
1232 return &p->exit_code; in task_stopped_code()
1234 if (p->signal->flags & SIGNAL_STOP_STOPPED) in task_stopped_code()
1235 return &p->signal->group_exit_code; in task_stopped_code()
1259 int ptrace, struct task_struct *p) in wait_task_stopped() argument
1272 if (!task_stopped_code(p, ptrace)) in wait_task_stopped()
1276 spin_lock_irq(&p->sighand->siglock); in wait_task_stopped()
1278 p_code = task_stopped_code(p, ptrace); in wait_task_stopped()
1289 uid = from_kuid_munged(current_user_ns(), task_uid(p)); in wait_task_stopped()
1291 spin_unlock_irq(&p->sighand->siglock); in wait_task_stopped()
1302 get_task_struct(p); in wait_task_stopped()
1303 pid = task_pid_vnr(p); in wait_task_stopped()
1308 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_stopped()
1309 put_task_struct(p); in wait_task_stopped()
1330 static int wait_task_continued(struct wait_opts *wo, struct task_struct *p) in wait_task_continued() argument
1339 if (!(p->signal->flags & SIGNAL_STOP_CONTINUED)) in wait_task_continued()
1342 spin_lock_irq(&p->sighand->siglock); in wait_task_continued()
1344 if (!(p->signal->flags & SIGNAL_STOP_CONTINUED)) { in wait_task_continued()
1345 spin_unlock_irq(&p->sighand->siglock); in wait_task_continued()
1349 p->signal->flags &= ~SIGNAL_STOP_CONTINUED; in wait_task_continued()
1350 uid = from_kuid_munged(current_user_ns(), task_uid(p)); in wait_task_continued()
1351 spin_unlock_irq(&p->sighand->siglock); in wait_task_continued()
1353 pid = task_pid_vnr(p); in wait_task_continued()
1354 get_task_struct(p); in wait_task_continued()
1358 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_continued()
1359 put_task_struct(p); in wait_task_continued()
1383 struct task_struct *p) in wait_consider_task() argument
1390 int exit_state = READ_ONCE(p->exit_state); in wait_consider_task()
1396 ret = eligible_child(wo, ptrace, p); in wait_consider_task()
1410 if (likely(!ptrace) && unlikely(p->ptrace)) { in wait_consider_task()
1422 if (!ptrace_reparented(p)) in wait_consider_task()
1429 if (!delay_group_leader(p)) { in wait_consider_task()
1435 if (unlikely(ptrace) || likely(!p->ptrace)) in wait_consider_task()
1436 return wait_task_zombie(wo, p); in wait_consider_task()
1473 ret = wait_task_stopped(wo, ptrace, p); in wait_consider_task()
1482 return wait_task_continued(wo, p); in wait_consider_task()
1496 struct task_struct *p; in do_wait_thread() local
1498 list_for_each_entry(p, &tsk->children, sibling) { in do_wait_thread()
1499 int ret = wait_consider_task(wo, 0, p); in do_wait_thread()
1510 struct task_struct *p; in ptrace_do_wait() local
1512 list_for_each_entry(p, &tsk->ptraced, ptrace_entry) { in ptrace_do_wait()
1513 int ret = wait_consider_task(wo, 1, p); in ptrace_do_wait()
1527 struct task_struct *p = key; in child_wait_callback() local
1529 if (!eligible_pid(wo, p)) in child_wait_callback()
1532 if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent) in child_wait_callback()
1538 void __wake_up_parent(struct task_struct *p, struct task_struct *parent) in __wake_up_parent() argument
1541 TASK_INTERRUPTIBLE, p); in __wake_up_parent()