Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1132993imu; Thu, 13 Dec 2018 09:51:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/XRBMv7If/H6QluCAKN+oiSvh+QRn2kEiag41XzuO6ul6vFX20nTxwDHieffCh7j1r5TejQ X-Received: by 2002:a63:5455:: with SMTP id e21mr22893656pgm.316.1544723507172; Thu, 13 Dec 2018 09:51:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544723507; cv=none; d=google.com; s=arc-20160816; b=s26rpdxIDkHVl2QFSO9grB09Kk0aSQ8Sb7mdbbW7RiNTnzUkEcCDE2JucBtjGC+Ecd ffsQwlQRxC11b8zEbNoi/YDSCiu9u04Moa4BzwO9fVursLeweOA1w2z5qVVih7pHq2T9 SMdlwvrHJUIcJHgyRQcO0K0HyCLKPuLTZKv9Tl0DwkAvCRoQ8v/bpUmcw1ZzAP/8+p/N MRKSE5L4XMt+uQiK0Ji30a0JLSHR7jXr/a7ujoWrNgkF4QwHu6e3/Pd9x4oCLXFCAHtS oKS+6OhiSFIh3cmkgCMANz1BvPx7KyxkCJilzJFgufzEOC0utwo6H2PLk73LXF0OiNxt 9AXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PogBqA+fBJj6sK/78xs7DA6YWsHlgmMskBW4MTiSzwo=; b=xJLlJjNPgN7I64pEZ9a1X45sNN3fzsr7nX1xwpCkPw1vOqAANHyQeCc3JKP+Fzkf58 WbupKGlHizu0F0/lAkjox4dan8sMbiOBFfrBfmqY6xXRNL8liefoRkHO+p1G4kcGI4q+ akgh7OayvD+jeGp8JKA7KMKrYk/t+zRNPl7Ga0HUOwqHYhdRg2OJabVlNKVigNZG4bPe mK3igwMVEwtdQ2kepfu2GofBf98tJEwwGsr8J4yN4OSk9oiacU4gMve7Tb1TTsaaGNcy 4sSUI4ZfUepv4m0za9Y8TBgRcz7NYdRHviTloKaV/Nw5tRkh5FxnPOI6KFeAI1t1T5Sy Owdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j24si2026881pgh.362.2018.12.13.09.51.30; Thu, 13 Dec 2018 09:51:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729192AbeLMQBX (ORCPT + 99 others); Thu, 13 Dec 2018 11:01:23 -0500 Received: from mx2.suse.de ([195.135.220.15]:33674 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727942AbeLMQBW (ORCPT ); Thu, 13 Dec 2018 11:01:22 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A7132AED2; Thu, 13 Dec 2018 16:01:20 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 518BF1E13E6; Thu, 13 Dec 2018 17:01:18 +0100 (CET) Date: Thu, 13 Dec 2018 17:01:18 +0100 From: Jan Kara To: Andrew Morton Cc: Josef Bacik , kernel-team@fb.com, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, tj@kernel.org, david@fromorbit.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, riel@redhat.com, jack@suse.cz Subject: Re: [PATCH][v6] filemap: drop the mmap_sem for all blocking operations Message-ID: <20181213160118.GA27517@quack2.suse.cz> References: <20181211173801.29535-4-josef@toxicpanda.com> <20181212152757.10017-1-josef@toxicpanda.com> <20181212155536.5fb770a0c9b4f2399d4794e4@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181212155536.5fb770a0c9b4f2399d4794e4@linux-foundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 12-12-18 15:55:36, Andrew Morton wrote: > On Wed, 12 Dec 2018 10:27:57 -0500 Josef Bacik wrote: > > > v5->v6: > > - added more comments as per Andrew's suggestion. > > - fixed the fpin leaks in the two error paths that were pointed out. > > > > hm, > > > --- a/mm/filemap.c~filemap-drop-the-mmap_sem-for-all-blocking-operations-v6 > > +++ a/mm/filemap.c > > @@ -2461,7 +2476,8 @@ static struct file *do_sync_mmap_readahe > > > > /* > > * Asynchronous readahead happens when we find the page and PG_readahead, > > - * so we want to possibly extend the readahead further.. > > + * so we want to possibly extend the readahead further. We return the file that > > + * was pinned if we have to drop the mmap_sem in order to do IO. > > */ > > static struct file *do_async_mmap_readahead(struct vm_fault *vmf, > > struct page *page) > > @@ -2545,14 +2561,15 @@ retry_find: > > page = pagecache_get_page(mapping, offset, > > FGP_CREAT|FGP_FOR_MMAP, > > vmf->gfp_mask); > > - if (!page) > > + if (!page) { > > + if (fpin) > > + goto out_retry; > > Is this right? If pagecache_get_page() returns NULL we can now return > VM_FAULT_MAJOR|VM_FAULT_RETRY whereas we used to return ENOMEM. Yes, but once we've dropped mmap_sem, there's no way safely return -ENOMEM. So VM_FAULT_RETRY is really the only option to tell the caller that mmap_sem is not held anymore... So the patch looks good to me now. You can add: Reviewed-by: Jan Kara Honza -- Jan Kara SUSE Labs, CR