Commit 634d7c45 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by James Toy

child_wait_callback()->eligible_child() is not right, we can miss the

wakeup if the task was detached before __wake_up_parent() and the caller
of do_wait() didn't use __WALL.

Move ->wo_pid checks from eligible_child() to the new helper,
eligible_pid(), and change child_wait_callback() to use it instead of
eligible_child().

Note: actually I think it would be better to fix the __WCLONE check in
eligible_child(), it doesn't look exactly right.  But it is not clear what
is the supposed behaviour, and any change is user-visible.
Reported-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent c6c326b8
...@@ -1107,13 +1107,16 @@ static struct pid *task_pid_type(struct task_struct *task, enum pid_type type) ...@@ -1107,13 +1107,16 @@ static struct pid *task_pid_type(struct task_struct *task, enum pid_type type)
return pid; return pid;
} }
static int eligible_child(struct wait_opts *wo, struct task_struct *p) static inline int eligible_pid(struct wait_opts *wo, struct task_struct *p)
{ {
if (wo->wo_type < PIDTYPE_MAX) { return wo->wo_type == PIDTYPE_MAX ||
if (task_pid_type(p, wo->wo_type) != wo->wo_pid) task_pid_type(p, wo->wo_type) == wo->wo_pid;
return 0; }
}
static int eligible_child(struct wait_opts *wo, struct task_struct *p)
{
if (!eligible_pid(wo, p))
return 0;
/* Wait for all children (clone and not) if __WALL is set; /* Wait for all children (clone and not) if __WALL is set;
* otherwise, wait for clone children *only* if __WCLONE is * otherwise, wait for clone children *only* if __WCLONE is
* set; otherwise, wait for non-clone children *only*. (Note: * set; otherwise, wait for non-clone children *only*. (Note:
...@@ -1574,7 +1577,7 @@ static int child_wait_callback(wait_queue_t *wait, unsigned mode, ...@@ -1574,7 +1577,7 @@ static int child_wait_callback(wait_queue_t *wait, unsigned mode,
child_wait); child_wait);
struct task_struct *p = key; struct task_struct *p = key;
if (!eligible_child(wo, p)) if (!eligible_pid(wo, p))
return 0; return 0;
if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent) if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment