projects/linux·commit b4fe5182

do_wait() wakeup optimization: child_wait_callback: check __WNOTHREAD case

b4fe5182 · Oleg Nesterov <[email protected]> · 2009-09-23 15:56:47 -07:00

Suggested by Roland.

do_wait(__WNOTHREAD) can only succeed if the caller is either ptracer, or
it is ->real_parent and the child is not traced. IOW, caller == p->parent
otherwise we should not wake up.

Change child_wait_callback() to check this. Ratan reports the workload with
CPU load >99% caused by unnecessary wakeups, should be fixed by this patch.

Signed-off-by: Oleg Nesterov <[email protected]>
Acked-by: Roland McGrath <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Ratan Nalumasu <[email protected]>
Cc: Vitaly Mayatskikh <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
b4fe51823d797d6959b2eee7868023e61606daa9
Parents
0b7570e7

Changes

1 files changed · +3 −0

FileStatusAddDelContent
kernel/exit.cmodified+3−0View file

kernel/exit.c

View file
diff --git a/kernel/exit.c b/kernel/exit.c
index 7838b4d..270a68b 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1581,6 +1581,9 @@ static int child_wait_callback(wait_queue_t *wait, unsigned mode,
if (!eligible_child(wo, p))
return 0;
+ if ((wo->wo_flags & __WNOTHREAD) && wait->private != p->parent)
+ return 0;
+
return default_wake_function(wait, mode, sync, key);
}