Skip to content

Commit 50405ed

Browse files
axboeopsiff
authored andcommitted
exit: abstract out should_wake helper for child_wait_callback()
Abstract out the helper that decides if we should wake up following a wake_up() callback on our internal waitqueue. No functional changes intended in this patch. Acked-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk> (cherry picked from commit 9d900d4) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 59efbac commit 50405ed

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

kernel/exit.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,20 +1529,28 @@ static int ptrace_do_wait(struct wait_opts *wo, struct task_struct *tsk)
15291529
return 0;
15301530
}
15311531

1532+
static bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p)
1533+
{
1534+
if (!eligible_pid(wo, p))
1535+
return false;
1536+
1537+
if ((wo->wo_flags & __WNOTHREAD) && wo->child_wait.private != p->parent)
1538+
return false;
1539+
1540+
return true;
1541+
}
1542+
15321543
static int child_wait_callback(wait_queue_entry_t *wait, unsigned mode,
15331544
int sync, void *key)
15341545
{
15351546
struct wait_opts *wo = container_of(wait, struct wait_opts,
15361547
child_wait);
15371548
struct task_struct *p = key;
15381549

1539-
if (!eligible_pid(wo, p))
1540-
return 0;
1550+
if (pid_child_should_wake(wo, p))
1551+
return default_wake_function(wait, mode, sync, key);
15411552

1542-
if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent)
1543-
return 0;
1544-
1545-
return default_wake_function(wait, mode, sync, key);
1553+
return 0;
15461554
}
15471555

15481556
void __wake_up_parent(struct task_struct *p, struct task_struct *parent)

0 commit comments

Comments
 (0)