aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/exit.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2009-09-23 18:56:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-24 10:21:00 -0400
commit5c01ba49e6647d86bc7576105f82027200d1f303 (patch)
tree700aa5dbda7c726e8b60803225587a1bc4fdbdb5 /kernel/exit.c
parentb4fe51823d797d6959b2eee7868023e61606daa9 (diff)
do_wait-wakeup-optimization: fix child_wait_callback()->eligible_child() usage
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: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Tested-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 270a68b7f22f..3fb9a77863d5 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1111,13 +1111,16 @@ static struct pid *task_pid_type(struct task_struct *task, enum pid_type type)
1111 return pid; 1111 return pid;
1112} 1112}
1113 1113
1114static int eligible_child(struct wait_opts *wo, struct task_struct *p) 1114static inline int eligible_pid(struct wait_opts *wo, struct task_struct *p)
1115{ 1115{
1116 if (wo->wo_type < PIDTYPE_MAX) { 1116 return wo->wo_type == PIDTYPE_MAX ||
1117 if (task_pid_type(p, wo->wo_type) != wo->wo_pid) 1117 task_pid_type(p, wo->wo_type) == wo->wo_pid;
1118 return 0; 1118}
1119 }
1120 1119
1120static int eligible_child(struct wait_opts *wo, struct task_struct *p)
1121{
1122 if (!eligible_pid(wo, p))
1123 return 0;
1121 /* Wait for all children (clone and not) if __WALL is set; 1124 /* Wait for all children (clone and not) if __WALL is set;
1122 * otherwise, wait for clone children *only* if __WCLONE is 1125 * otherwise, wait for clone children *only* if __WCLONE is
1123 * set; otherwise, wait for non-clone children *only*. (Note: 1126 * set; otherwise, wait for non-clone children *only*. (Note:
@@ -1578,7 +1581,7 @@ static int child_wait_callback(wait_queue_t *wait, unsigned mode,
1578 child_wait); 1581 child_wait);
1579 struct task_struct *p = key; 1582 struct task_struct *p = key;
1580 1583
1581 if (!eligible_child(wo, p)) 1584 if (!eligible_pid(wo, p))
1582 return 0; 1585 return 0;
1583 1586
1584 if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent) 1587 if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent)