Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

exit: move core of do_wait() into helper

Rather than have a maze of gotos, put the actual logic in __do_wait()
and have do_wait() loop deal with waitqueue setup/teardown and whether
to call __do_wait() again.

No functional changes intended in this patch.

Acked-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

+31 -20
+31 -20
kernel/exit.c
··· 1590 1590 return 0; 1591 1591 } 1592 1592 1593 - static long do_wait(struct wait_opts *wo) 1593 + static long __do_wait(struct wait_opts *wo) 1594 1594 { 1595 - int retval; 1595 + long retval; 1596 1596 1597 - trace_sched_process_wait(wo->wo_pid); 1598 - 1599 - init_waitqueue_func_entry(&wo->child_wait, child_wait_callback); 1600 - wo->child_wait.private = current; 1601 - add_wait_queue(&current->signal->wait_chldexit, &wo->child_wait); 1602 - repeat: 1603 1597 /* 1604 1598 * If there is nothing that can match our criteria, just get out. 1605 1599 * We will clear ->notask_error to zero if we see any child that ··· 1605 1611 (!wo->wo_pid || !pid_has_task(wo->wo_pid, wo->wo_type))) 1606 1612 goto notask; 1607 1613 1608 - set_current_state(TASK_INTERRUPTIBLE); 1609 1614 read_lock(&tasklist_lock); 1610 1615 1611 1616 if (wo->wo_type == PIDTYPE_PID) { 1612 1617 retval = do_wait_pid(wo); 1613 1618 if (retval) 1614 - goto end; 1619 + return retval; 1615 1620 } else { 1616 1621 struct task_struct *tsk = current; 1617 1622 1618 1623 do { 1619 1624 retval = do_wait_thread(wo, tsk); 1620 1625 if (retval) 1621 - goto end; 1626 + return retval; 1622 1627 1623 1628 retval = ptrace_do_wait(wo, tsk); 1624 1629 if (retval) 1625 - goto end; 1630 + return retval; 1626 1631 1627 1632 if (wo->wo_flags & __WNOTHREAD) 1628 1633 break; ··· 1631 1638 1632 1639 notask: 1633 1640 retval = wo->notask_error; 1634 - if (!retval && !(wo->wo_flags & WNOHANG)) { 1635 - retval = -ERESTARTSYS; 1636 - if (!signal_pending(current)) { 1637 - schedule(); 1638 - goto repeat; 1639 - } 1640 - } 1641 - end: 1641 + if (!retval && !(wo->wo_flags & WNOHANG)) 1642 + return -ERESTARTSYS; 1643 + 1644 + return retval; 1645 + } 1646 + 1647 + static long do_wait(struct wait_opts *wo) 1648 + { 1649 + int retval; 1650 + 1651 + trace_sched_process_wait(wo->wo_pid); 1652 + 1653 + init_waitqueue_func_entry(&wo->child_wait, child_wait_callback); 1654 + wo->child_wait.private = current; 1655 + add_wait_queue(&current->signal->wait_chldexit, &wo->child_wait); 1656 + 1657 + do { 1658 + set_current_state(TASK_INTERRUPTIBLE); 1659 + retval = __do_wait(wo); 1660 + if (retval != -ERESTARTSYS) 1661 + break; 1662 + if (signal_pending(current)) 1663 + break; 1664 + schedule(); 1665 + } while (1); 1666 + 1642 1667 __set_current_state(TASK_RUNNING); 1643 1668 remove_wait_queue(&current->signal->wait_chldexit, &wo->child_wait); 1644 1669 return retval;