do_wait() wakeup optimization: child_wait_callback: check __WNOTHREAD case
authorOleg Nesterov <[email protected]>
Wed, 23 Sep 2009 22:56:47 +0000 (15:56 -0700)
committerLinus Torvalds <[email protected]>
Thu, 24 Sep 2009 14:21:00 +0000 (07:21 -0700)
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]>
kernel/exit.c

index 7838b4d687743cb2e927e13d9cefe482e1b662d0..270a68b7f22fd8259512f97be2696d451fc8a744 100644 (file)
@@ -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);
 }