Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757097Ab3CHUWc (ORCPT ); Fri, 8 Mar 2013 15:22:32 -0500 Received: from mail-oa0-f53.google.com ([209.85.219.53]:59085 "EHLO mail-oa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752929Ab3CHUW3 (ORCPT ); Fri, 8 Mar 2013 15:22:29 -0500 MIME-Version: 1.0 In-Reply-To: <20130308175920.GA26332@redhat.com> References: <20130308175852.GA26300@redhat.com> <20130308175920.GA26332@redhat.com> Date: Fri, 8 Mar 2013 12:22:29 -0800 X-Google-Sender-Auth: 1WeX0tcwzyhLdMlP6lzrTEauEpc Message-ID: Subject: Re: [PATCH 3/3] coredump: change wait_for_dump_helpers() to use wait_event_interruptible() From: Mandeep Singh Baines To: Oleg Nesterov Cc: Andrew Morton , Neil Horman , "Rafael J. Wysocki" , Tejun Heo , Linux Kernel Mailing List Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2122 Lines: 60 On Fri, Mar 8, 2013 at 9:59 AM, Oleg Nesterov wrote: > 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 Acked-by: Mandeep Singh Baines > --- > fs/coredump.c | 15 +++++++++------ > 1 files changed, 9 insertions(+), 6 deletions(-) > > diff --git a/fs/coredump.c b/fs/coredump.c > index 477f393..667413c 100644 > --- a/fs/coredump.c > +++ b/fs/coredump.c > @@ -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); > - > } > > /* > -- > 1.5.5.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/