Commit dc7ee2aac830e5423f41de87d50441f138f648da
Committed by
Linus Torvalds
1 parent
079148b919
Exists in
master
and in
20 other branches
coredump: change wait_for_dump_helpers() to use wait_event_interruptible()
wait_for_dump_helpers() calls wake_up/kill_fasync from inside the wait_event-like loop. This is not needed and in fact this is not strictly correct, we can/should do this only once after we change pipe->writers. We could even check if it becomes zero. Change this code to use use wait_event_interruptible(), this can also help to make this wait freezable. With this patch we check pipe->readers without pipe_lock(), this is fine. Once we see pipe->readers == 1 we know that the handler decremented the counter, this is all we need. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Mandeep Singh Baines <msb@chromium.org> Cc: Neil Horman <nhorman@redhat.com> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 9 additions and 6 deletions Side-by-side Diff
fs/coredump.c
... | ... | @@ -439,17 +439,20 @@ |
439 | 439 | pipe_lock(pipe); |
440 | 440 | pipe->readers++; |
441 | 441 | pipe->writers--; |
442 | + wake_up_interruptible_sync(&pipe->wait); | |
443 | + kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); | |
444 | + pipe_unlock(pipe); | |
442 | 445 | |
443 | - while ((pipe->readers > 1) && (!signal_pending(current))) { | |
444 | - wake_up_interruptible_sync(&pipe->wait); | |
445 | - kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); | |
446 | - pipe_wait(pipe); | |
447 | - } | |
446 | + /* | |
447 | + * We actually want wait_event_freezable() but then we need | |
448 | + * to clear TIF_SIGPENDING and improve dump_interrupted(). | |
449 | + */ | |
450 | + wait_event_interruptible(pipe->wait, pipe->readers == 1); | |
448 | 451 | |
452 | + pipe_lock(pipe); | |
449 | 453 | pipe->readers--; |
450 | 454 | pipe->writers++; |
451 | 455 | pipe_unlock(pipe); |
452 | - | |
453 | 456 | } |
454 | 457 | |
455 | 458 | /* |