Lines Matching refs:p
124 static void __unhash_process(struct task_struct *p, bool group_dead) in __unhash_process() argument
127 detach_pid(p, PIDTYPE_PID); in __unhash_process()
129 detach_pid(p, PIDTYPE_TGID); in __unhash_process()
130 detach_pid(p, PIDTYPE_PGID); in __unhash_process()
131 detach_pid(p, PIDTYPE_SID); in __unhash_process()
133 list_del_rcu(&p->tasks); in __unhash_process()
134 list_del_init(&p->sibling); in __unhash_process()
137 list_del_rcu(&p->thread_group); in __unhash_process()
138 list_del_rcu(&p->thread_node); in __unhash_process()
240 void release_task(struct task_struct *p) in release_task() argument
249 dec_rlimit_ucounts(task_ucounts(p), UCOUNT_RLIMIT_NPROC, 1); in release_task()
252 cgroup_release(p); in release_task()
255 ptrace_release_task(p); in release_task()
256 thread_pid = get_pid(p->thread_pid); in release_task()
257 __exit_signal(p); in release_task()
265 leader = p->group_leader; in release_task()
266 if (leader != p && thread_group_empty(leader) in release_task()
279 seccomp_filter_release(p); in release_task()
282 release_thread(p); in release_task()
283 put_task_struct_rcu_user(p); in release_task()
285 p = leader; in release_task()
330 struct task_struct *p; in will_become_orphaned_pgrp() local
332 do_each_pid_task(pgrp, PIDTYPE_PGID, p) { in will_become_orphaned_pgrp()
333 if ((p == ignored_task) || in will_become_orphaned_pgrp()
334 (p->exit_state && thread_group_empty(p)) || in will_become_orphaned_pgrp()
335 is_global_init(p->real_parent)) in will_become_orphaned_pgrp()
338 if (task_pgrp(p->real_parent) != pgrp && in will_become_orphaned_pgrp()
339 task_session(p->real_parent) == task_session(p)) in will_become_orphaned_pgrp()
341 } while_each_pid_task(pgrp, PIDTYPE_PGID, p); in will_become_orphaned_pgrp()
359 struct task_struct *p; in has_stopped_jobs() local
361 do_each_pid_task(pgrp, PIDTYPE_PGID, p) { in has_stopped_jobs()
362 if (p->signal->flags & SIGNAL_STOP_STOPPED) in has_stopped_jobs()
364 } while_each_pid_task(pgrp, PIDTYPE_PGID, p); in has_stopped_jobs()
446 struct task_struct *c, *g, *p = current; in mm_update_next_owner() local
453 if (mm->owner != p) in mm_update_next_owner()
469 list_for_each_entry(c, &p->children, sibling) { in mm_update_next_owner()
477 list_for_each_entry(c, &p->real_parent->children, sibling) { in mm_update_next_owner()
505 BUG_ON(c == p); in mm_update_next_owner()
571 static struct task_struct *find_alive_thread(struct task_struct *p) in find_alive_thread() argument
575 for_each_thread(p, t) { in find_alive_thread()
589 struct task_struct *p, *n; in find_child_reaper() local
602 list_for_each_entry_safe(p, n, dead, ptrace_entry) { in find_child_reaper()
603 list_del_init(&p->ptrace_entry); in find_child_reaper()
604 release_task(p); in find_child_reaper()
658 static void reparent_leader(struct task_struct *father, struct task_struct *p, in reparent_leader() argument
661 if (unlikely(p->exit_state == EXIT_DEAD)) in reparent_leader()
665 p->exit_signal = SIGCHLD; in reparent_leader()
668 if (!p->ptrace && in reparent_leader()
669 p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) { in reparent_leader()
670 if (do_notify_parent(p, p->exit_signal)) { in reparent_leader()
671 p->exit_state = EXIT_DEAD; in reparent_leader()
672 list_add(&p->ptrace_entry, dead); in reparent_leader()
676 kill_orphaned_pgrp(p, father); in reparent_leader()
690 struct task_struct *p, *t, *reaper; in forget_original_parent() local
701 list_for_each_entry(p, &father->children, sibling) { in forget_original_parent()
702 for_each_thread(p, t) { in forget_original_parent()
717 reparent_leader(father, p, dead); in forget_original_parent()
729 struct task_struct *p, *n; in exit_notify() local
762 list_for_each_entry_safe(p, n, &dead, ptrace_entry) { in exit_notify()
763 list_del_init(&p->ptrace_entry); in exit_notify()
764 release_task(p); in exit_notify()
1061 static int eligible_pid(struct wait_opts *wo, struct task_struct *p) in eligible_pid() argument
1064 task_pid_type(p, wo->wo_type) == wo->wo_pid; in eligible_pid()
1068 eligible_child(struct wait_opts *wo, bool ptrace, struct task_struct *p) in eligible_child() argument
1070 if (!eligible_pid(wo, p)) in eligible_child()
1088 if ((p->exit_signal != SIGCHLD) ^ !!(wo->wo_flags & __WCLONE)) in eligible_child()
1100 static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p) in wait_task_zombie() argument
1103 pid_t pid = task_pid_vnr(p); in wait_task_zombie()
1104 uid_t uid = from_kuid_munged(current_user_ns(), task_uid(p)); in wait_task_zombie()
1111 status = (p->signal->flags & SIGNAL_GROUP_EXIT) in wait_task_zombie()
1112 ? p->signal->group_exit_code : p->exit_code; in wait_task_zombie()
1113 get_task_struct(p); in wait_task_zombie()
1117 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_zombie()
1118 put_task_struct(p); in wait_task_zombie()
1124 state = (ptrace_reparented(p) && thread_group_leader(p)) ? in wait_task_zombie()
1126 if (cmpxchg(&p->exit_state, EXIT_ZOMBIE, state) != EXIT_ZOMBIE) in wait_task_zombie()
1137 if (state == EXIT_DEAD && thread_group_leader(p)) { in wait_task_zombie()
1138 struct signal_struct *sig = p->signal; in wait_task_zombie()
1163 thread_group_cputime_adjusted(p, &tgutime, &tgstime); in wait_task_zombie()
1168 psig->cgtime += task_gtime(p) + sig->gtime + sig->cgtime; in wait_task_zombie()
1170 p->min_flt + sig->min_flt + sig->cmin_flt; in wait_task_zombie()
1172 p->maj_flt + sig->maj_flt + sig->cmaj_flt; in wait_task_zombie()
1174 p->nvcsw + sig->nvcsw + sig->cnvcsw; in wait_task_zombie()
1176 p->nivcsw + sig->nivcsw + sig->cnivcsw; in wait_task_zombie()
1178 task_io_get_inblock(p) + in wait_task_zombie()
1181 task_io_get_oublock(p) + in wait_task_zombie()
1186 task_io_accounting_add(&psig->ioac, &p->ioac); in wait_task_zombie()
1193 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_zombie()
1194 status = (p->signal->flags & SIGNAL_GROUP_EXIT) in wait_task_zombie()
1195 ? p->signal->group_exit_code : p->exit_code; in wait_task_zombie()
1201 ptrace_unlink(p); in wait_task_zombie()
1205 if (do_notify_parent(p, p->exit_signal)) in wait_task_zombie()
1207 p->exit_state = state; in wait_task_zombie()
1211 release_task(p); in wait_task_zombie()
1230 static int *task_stopped_code(struct task_struct *p, bool ptrace) in task_stopped_code() argument
1233 if (task_is_traced(p) && !(p->jobctl & JOBCTL_LISTENING)) in task_stopped_code()
1234 return &p->exit_code; in task_stopped_code()
1236 if (p->signal->flags & SIGNAL_STOP_STOPPED) in task_stopped_code()
1237 return &p->signal->group_exit_code; in task_stopped_code()
1261 int ptrace, struct task_struct *p) in wait_task_stopped() argument
1274 if (!task_stopped_code(p, ptrace)) in wait_task_stopped()
1278 spin_lock_irq(&p->sighand->siglock); in wait_task_stopped()
1280 p_code = task_stopped_code(p, ptrace); in wait_task_stopped()
1291 uid = from_kuid_munged(current_user_ns(), task_uid(p)); in wait_task_stopped()
1293 spin_unlock_irq(&p->sighand->siglock); in wait_task_stopped()
1304 get_task_struct(p); in wait_task_stopped()
1305 pid = task_pid_vnr(p); in wait_task_stopped()
1310 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_stopped()
1311 put_task_struct(p); in wait_task_stopped()
1332 static int wait_task_continued(struct wait_opts *wo, struct task_struct *p) in wait_task_continued() argument
1341 if (!(p->signal->flags & SIGNAL_STOP_CONTINUED)) in wait_task_continued()
1344 spin_lock_irq(&p->sighand->siglock); in wait_task_continued()
1346 if (!(p->signal->flags & SIGNAL_STOP_CONTINUED)) { in wait_task_continued()
1347 spin_unlock_irq(&p->sighand->siglock); in wait_task_continued()
1351 p->signal->flags &= ~SIGNAL_STOP_CONTINUED; in wait_task_continued()
1352 uid = from_kuid_munged(current_user_ns(), task_uid(p)); in wait_task_continued()
1353 spin_unlock_irq(&p->sighand->siglock); in wait_task_continued()
1355 pid = task_pid_vnr(p); in wait_task_continued()
1356 get_task_struct(p); in wait_task_continued()
1360 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_continued()
1361 put_task_struct(p); in wait_task_continued()
1385 struct task_struct *p) in wait_consider_task() argument
1392 int exit_state = READ_ONCE(p->exit_state); in wait_consider_task()
1398 ret = eligible_child(wo, ptrace, p); in wait_consider_task()
1412 if (likely(!ptrace) && unlikely(p->ptrace)) { in wait_consider_task()
1424 if (!ptrace_reparented(p)) in wait_consider_task()
1431 if (!delay_group_leader(p)) { in wait_consider_task()
1437 if (unlikely(ptrace) || likely(!p->ptrace)) in wait_consider_task()
1438 return wait_task_zombie(wo, p); in wait_consider_task()
1475 ret = wait_task_stopped(wo, ptrace, p); in wait_consider_task()
1484 return wait_task_continued(wo, p); in wait_consider_task()
1498 struct task_struct *p; in do_wait_thread() local
1500 list_for_each_entry(p, &tsk->children, sibling) { in do_wait_thread()
1501 int ret = wait_consider_task(wo, 0, p); in do_wait_thread()
1512 struct task_struct *p; in ptrace_do_wait() local
1514 list_for_each_entry(p, &tsk->ptraced, ptrace_entry) { in ptrace_do_wait()
1515 int ret = wait_consider_task(wo, 1, p); in ptrace_do_wait()
1529 struct task_struct *p = key; in child_wait_callback() local
1531 if (!eligible_pid(wo, p)) in child_wait_callback()
1534 if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent) in child_wait_callback()
1540 void __wake_up_parent(struct task_struct *p, struct task_struct *parent) in __wake_up_parent() argument
1543 TASK_INTERRUPTIBLE, p); in __wake_up_parent()