From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kent Overstreet Subject: Re: [PATCH RFC] fs/aio: fix sleeping while TASK_INTERRUPTIBLE Date: Wed, 24 Dec 2014 18:59:58 -0800 Message-ID: <20141225025958.GA30938@moria.home.lan> References: <20141223001619.GA26385@ret.masoncoding.com> <20141223184328.GB17185@kvack.org> <1419360926.13012.12@mail.thefacebook.com> <20141223215847.GD17185@kvack.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Chris Mason , linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, Peter Zijlstra To: Benjamin LaHaise Return-path: Received: from mail-pd0-f180.google.com ([209.85.192.180]:44104 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751637AbaLYCyt (ORCPT ); Wed, 24 Dec 2014 21:54:49 -0500 Received: by mail-pd0-f180.google.com with SMTP id w10so10819123pde.25 for ; Wed, 24 Dec 2014 18:54:48 -0800 (PST) Content-Disposition: inline In-Reply-To: <20141223215847.GD17185@kvack.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, Dec 23, 2014 at 04:58:47PM -0500, Benjamin LaHaise wrote: > Hi Chris, > > On Tue, Dec 23, 2014 at 01:55:26PM -0500, Chris Mason wrote: > > Works for me, the patch is mostly a (somewhat commented) list of all > > the places we're currently doing it wrong. > > I think the following change should suffice to fix this issue, and it's a > lot easier to review, too. I've given this a quick test, and it works for > me. I do have one concern: is it safe to call mutex_lock() when the current > task is already on other wait queues? If the answer is no, then it may be > necessary to convert ->ring_lock back into spinlock as it was prior to 3.10 > to avoid using mutex_lock(). The same question applies to kmap() and > copy_to_user(), and those concerns might have implications across the rest > of the kernel. Thoughts? > > + __set_current_state(state); I don't think this is safe - if we race, and another thread wakes us up, we're setting our state back to TASK_INTERRUPTIBLE _without_ us being on the waitlist.