Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp241727imu; Wed, 12 Dec 2018 15:57:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/V7bHJbqJdiajkZRp5L3/CUv0XdMKROg9HD74PWUIeyXwAhjLUQAU4wfLm/ErsZ99ep2/HY X-Received: by 2002:a62:1f53:: with SMTP id f80mr22007166pff.92.1544659075739; Wed, 12 Dec 2018 15:57:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544659075; cv=none; d=google.com; s=arc-20160816; b=NqedkoXJZwzzyji7fgzB77t/643cQ/TNo3VG6v/MWazJq61h5aNnJ5Cp+rFuZGizOQ w1R+nQQXeqObqyu0DpoGP0rnC04n8jNL+WRRwvvw1ajvPJskldoQ6IrJKfRqblYXnECg jL7cErCepwaO9N8mMNDbMKHK806hj6So/tLjHsJNuAUAsYxiJrA51Eakqj4LlnuD1Ty0 uMycKnb6Y1+C49jHFgAYiy+aquhNXQSh+Ix/U0HxgxigwQ80jrURmmgy7reeWBSlieUN 4g5ONmrER+sYgrXPlXa4Bo5vaoLeW8UYxYi5tL/Emallt6H3vveehOCPtf0MxjiWxmt7 kMgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=/deChP1b15EkTLrG20t3gqFOQjnu/BHeYkk+YPVMFCE=; b=AtFn94qu7hysHyHm77TBxf/J2d72QD63asosqflIbcLMo3CUEszXGAirXf+d66DE0j eVcHXjoOAdOg86/bX70JeH02kM2uMJ1SlkmFjJglD1u+7xDAZu8V8oa1OkGdDuTGvssl RXsntUQLtIfCRkIwAPMcXIuXWwDVrUlIZHf5L9B8EFMzX89oDD9uPh7hRRqVWHZcNBIO ZEgvf9e8R7ZuGcp2lvy4qn5kjg5OeRXGe/4hrPRaPFqGIn+7XS8OmX9jt1ByGmvKcR8h Wp/jgUu5VVu3K0A4VUG9HzbjmK1NKRkJcKrolSe7Q+dnON8x9Sq2jmyYrIHr4iSVLFCs rnDw== 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 c76si137031pga.70.2018.12.12.15.57.40; Wed, 12 Dec 2018 15:57:55 -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 S1728530AbeLLXzk (ORCPT + 99 others); Wed, 12 Dec 2018 18:55:40 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43322 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726790AbeLLXzj (ORCPT ); Wed, 12 Dec 2018 18:55:39 -0500 Received: from localhost.localdomain (c-24-6-170-16.hsd1.ca.comcast.net [24.6.170.16]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E4E0DB55; Wed, 12 Dec 2018 23:55:37 +0000 (UTC) Date: Wed, 12 Dec 2018 15:55:36 -0800 From: Andrew Morton To: Josef Bacik Cc: 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: <20181212155536.5fb770a0c9b4f2399d4794e4@linux-foundation.org> In-Reply-To: <20181212152757.10017-1-josef@toxicpanda.com> References: <20181211173801.29535-4-josef@toxicpanda.com> <20181212152757.10017-1-josef@toxicpanda.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > return vmf_error(-ENOMEM); > + } > } > > - if (!lock_page_maybe_drop_mmap(vmf, page, &fpin)) { > - put_page(page); > - return ret | VM_FAULT_RETRY; > - } > + if (!lock_page_maybe_drop_mmap(vmf, page, &fpin)) > + goto out_retry; > > /* Did it get truncated? */ > if (unlikely(page->mapping != mapping)) {