From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Roland McGrath <roland@redhat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH -mm 1/2] do_wait-wakeup-optimization: fix child_wait_callback()->eligible_child() usage
Date: Tue, 1 Sep 2009 14:23:25 +0200 [thread overview]
Message-ID: <20090901122325.GB20989@redhat.com> (raw)
In-Reply-To: <20090901122240.GA20989@redhat.com>
(on top of do_wait-wakeup-optimization-child_wait_callback-check-__wnothread-case.patch,
fixes do_wait-wakeup-optimization-change-__wake_up_parent-to-use-filtered-wakeup.patch)
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>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/exit.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
--- WAIT/kernel/exit.c~2_WAKE_PARENT_ELIGIBLE_FIX 2009-09-01 12:49:27.000000000 +0200
+++ WAIT/kernel/exit.c 2009-09-01 12:59:23.000000000 +0200
@@ -1106,13 +1106,16 @@ static struct pid *task_pid_type(struct
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) {
- if (task_pid_type(p, wo->wo_type) != wo->wo_pid)
- return 0;
- }
+ return wo->wo_type == PIDTYPE_MAX ||
+ task_pid_type(p, wo->wo_type) == wo->wo_pid;
+}
+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;
* otherwise, wait for clone children *only* if __WCLONE is
* set; otherwise, wait for non-clone children *only*. (Note:
@@ -1564,7 +1567,7 @@ static int child_wait_callback(wait_queu
child_wait);
struct task_struct *p = key;
- if (!eligible_child(wo, p))
+ if (!eligible_pid(wo, p))
return 0;
if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent)
next prev parent reply other threads:[~2009-09-01 12:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-24 23:28 mmotm 2009-08-24-16-24 uploaded akpm
2009-08-25 10:02 ` KAMEZAWA Hiroyuki
2009-08-26 4:52 ` Amerigo Wang
2009-08-26 6:54 ` KAMEZAWA Hiroyuki
2009-08-26 3:15 ` KAMEZAWA Hiroyuki
2009-08-26 3:36 ` Andrew Morton
2009-08-26 3:44 ` KAMEZAWA Hiroyuki
2009-08-27 5:44 ` KAMEZAWA Hiroyuki
2009-08-27 6:17 ` Hiroshi Shimamoto
2009-08-27 6:31 ` KAMEZAWA Hiroyuki
2009-08-27 7:05 ` KAMEZAWA Hiroyuki
2009-08-27 9:34 ` Oleg Nesterov
2009-08-27 9:43 ` KAMEZAWA Hiroyuki
2009-08-27 10:08 ` Oleg Nesterov
2009-08-27 10:31 ` KAMEZAWA Hiroyuki
2009-08-27 10:52 ` Oleg Nesterov
2009-08-28 17:17 ` eligible_child() && __WCLONE && task_detached() (Was: mmotm 2009-08-24-16-24 uploaded) Oleg Nesterov
2009-08-28 19:16 ` Roland McGrath
2009-09-01 12:22 ` [PATCH -mm 0/2] fix do_wait(!__WALL) hang " Oleg Nesterov
2009-09-01 12:23 ` Oleg Nesterov [this message]
2009-09-10 0:36 ` [PATCH -mm 1/2] do_wait-wakeup-optimization: fix child_wait_callback()->eligible_child() usage KAMEZAWA Hiroyuki
2009-09-01 12:24 ` [PATCH -mm 2/2] do_wait-wakeup-optimization: simplify task_pid_type() Oleg Nesterov
2009-08-27 10:17 ` mmotm 2009-08-24-16-24 uploaded KAMEZAWA Hiroyuki
2009-08-27 9:37 ` KAMEZAWA Hiroyuki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090901122325.GB20989@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.