From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Mandeep Singh Baines <msb@chromium.org>,
Neil Horman <nhorman@redhat.com>,
"Rafael J. Wysocki" <rjw@sisk.pl>, Tejun Heo <tj@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] coredump: make wait_for_dump_helpers() freezable
Date: Sun, 24 Feb 2013 18:32:09 +0100 [thread overview]
Message-ID: <20130224173209.GA32209@redhat.com> (raw)
In-Reply-To: <20130224173144.GA32179@redhat.com>
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 <oleg@redhat.com>
---
fs/coredump.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/coredump.c b/fs/coredump.c
index 4f3c8d1..284d841 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -32,6 +32,7 @@
#include <linux/pipe_fs_i.h>
#include <linux/oom.h>
#include <linux/compat.h>
+#include <linux/freezer.h>
#include <asm/uaccess.h>
#include <asm/mmu_context.h>
@@ -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);
-
}
/*
--
1.5.5.1
next prev parent reply other threads:[~2013-02-24 17:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-24 17:31 [PATCH -mm 0/3] coredump: make it freezable (almost) Oleg Nesterov
2013-02-24 17:32 ` [PATCH 1/3] coredump: factor out the setting of PF_DUMPCORE Oleg Nesterov
2013-02-24 17:32 ` [PATCH 2/3] freezer: do not send a fake signal to a PF_DUMPCORE thread Oleg Nesterov
2013-02-24 18:36 ` [PATCH v2 " Oleg Nesterov
2013-02-24 23:39 ` Rafael J. Wysocki
2013-02-26 16:37 ` Mandeep Singh Baines
2013-02-26 19:43 ` Mandeep Singh Baines
2013-02-27 18:08 ` Oleg Nesterov
2013-02-27 18:55 ` Oleg Nesterov
2013-02-28 15:39 ` Mandeep Singh Baines
2013-02-24 17:32 ` Oleg Nesterov [this message]
2013-02-28 20:19 ` [PATCH 3/3] coredump: make wait_for_dump_helpers() freezable Mandeep Singh Baines
2013-02-24 18:09 ` [PATCH -mm 0/3] coredump: make it freezable (almost) Oleg Nesterov
2013-02-25 23:05 ` Andrew Morton
2013-02-28 18:46 ` Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130224173209.GA32209@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=msb@chromium.org \
--cc=nhorman@redhat.com \
--cc=rjw@sisk.pl \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).