]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
coredump: change wait_for_dump_helpers() to use wait_event_interruptible()
authorOleg Nesterov <oleg@redhat.com>
Sat, 23 Mar 2013 02:32:48 +0000 (13:32 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 26 Mar 2013 05:11:34 +0000 (16:11 +1100)
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>
fs/coredump.c

index 0bf4f44f1faa49a3571b14178c3096c919c599fd..ae862fa030b78be46f7afd60a4994f697e9d4b1b 100644 (file)
@@ -439,17 +439,20 @@ 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);
-       }
+       /*
+        * We actually want wait_event_freezable() but then we need
+        * to clear TIF_SIGPENDING and improve dump_interrupted().
+        */
+       wait_event_interruptible(pipe->wait, pipe->readers == 1);
 
+       pipe_lock(pipe);
        pipe->readers--;
        pipe->writers++;
        pipe_unlock(pipe);
-
 }
 
 /*