Skip to content

Commit

Permalink
do_wait() wakeup optimization: child_wait_callback: check __WNOTHREAD…
Browse files Browse the repository at this point in the history
… case

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 <oleg@redhat.com>
Acked-by: Roland McGrath <roland@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Ratan Nalumasu <rnalumasu@gmail.com>
Cc: Vitaly Mayatskikh <vmayatsk@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Sep 24, 2009
1 parent 0b7570e commit b4fe518
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit b4fe518

Please sign in to comment.