From 9cd20377fd1b8c4dce98428d256dacedb4937651 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Sun, 10 Mar 2013 21:55:18 +1100 Subject: [PATCH] coredump: make wait_for_dump_helpers() freezable 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. With this change it is trivial to convert this code to use wait_event_freezable() and make this function freezable/killable, only SIGKILL can set TIF_SIGPENDING. 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. Note: wait_event_freezable() is "strange", perhaps it should be changed or simply removed. In the latter case we can change this code again to use freezer_do_not_count + wait_event_interruptible. Signed-off-by: Oleg Nesterov Acked-by: Mandeep Singh Baines Cc: Neil Horman Cc: Tejun Heo Cc: "Rafael J. Wysocki" a Signed-off-by: Andrew Morton --- fs/coredump.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/coredump.c b/fs/coredump.c index b0168c798923..7638895df974 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -428,17 +429,16 @@ static void wait_for_dump_helpers(struct file *file) pipe_lock(pipe); pipe->readers++; pipe->writers--; + wake_up_interruptible_sync(&pipe->wait); + kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); + pipe_unlock(pipe); - while ((pipe->readers > 1) && (!signal_pending(current))) { - wake_up_interruptible_sync(&pipe->wait); - kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); - pipe_wait(pipe); - } + wait_event_freezable(pipe->wait, pipe->readers == 1); + pipe_lock(pipe); pipe->readers--; pipe->writers++; pipe_unlock(pipe); - } /* -- 2.39.5