diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-04-30 18:28:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-30 20:04:06 -0400 |
commit | dc7ee2aac830e5423f41de87d50441f138f648da (patch) | |
tree | 735a75c2d2455721dffed758632f07f62cbf2206 /fs/coredump.c | |
parent | 079148b919d0c58b796f9ae98bdb53028dbcd5e7 (diff) |
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>
Diffstat (limited to 'fs/coredump.c')
-rw-r--r-- | fs/coredump.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/coredump.c b/fs/coredump.c index 7300e312fb3a..ec306cc9a28a 100644 --- a/fs/coredump.c +++ b/fs/coredump.c | |||
@@ -439,17 +439,20 @@ static void wait_for_dump_helpers(struct file *file) | |||
439 | pipe_lock(pipe); | 439 | pipe_lock(pipe); |
440 | pipe->readers++; | 440 | pipe->readers++; |
441 | pipe->writers--; | 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))) { | 446 | /* |
444 | wake_up_interruptible_sync(&pipe->wait); | 447 | * We actually want wait_event_freezable() but then we need |
445 | kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); | 448 | * to clear TIF_SIGPENDING and improve dump_interrupted(). |
446 | pipe_wait(pipe); | 449 | */ |
447 | } | 450 | wait_event_interruptible(pipe->wait, pipe->readers == 1); |
448 | 451 | ||
452 | pipe_lock(pipe); | ||
449 | pipe->readers--; | 453 | pipe->readers--; |
450 | pipe->writers++; | 454 | pipe->writers++; |
451 | pipe_unlock(pipe); | 455 | pipe_unlock(pipe); |
452 | |||
453 | } | 456 | } |
454 | 457 | ||
455 | /* | 458 | /* |