From patchwork Tue Sep 25 15:30:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10614275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C90BD161F for ; Tue, 25 Sep 2018 15:30:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD3B02A889 for ; Tue, 25 Sep 2018 15:30:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1C342A8C8; Tue, 25 Sep 2018 15:30:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61BCA2A8BA for ; Tue, 25 Sep 2018 15:30:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729455AbeIYVi0 (ORCPT ); Tue, 25 Sep 2018 17:38:26 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:39729 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729791AbeIYViZ (ORCPT ); Tue, 25 Sep 2018 17:38:25 -0400 Received: by mail-qt1-f194.google.com with SMTP id c25-v6so8065773qtp.6 for ; Tue, 25 Sep 2018 08:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=fxF9egp/0MfNC6eP3oXuHL949t8miVwsCl5P35THCQ0=; b=DEmAPLzkrPKAHv0xbTFGpZ6jamzlToLR/cRumBykBnmJoZyUpkUvG6gNwTXEEEvyo9 FzeLKBbs0BBVsDOCDYe7Z+Kt3M7PelIG7cQnsJ+iLSS0Q0hbOoLbqqKjMD25QmSZj3z5 6K56i3YJEvNJ7B6CpBPv1+KXW2xSGvgAYAbgPmw5fsr4RGI9WsKfIyWFaBWMxqTcB0OR 40CUFcmwjK6YV/Uz6Lh4a6RxyGCPOE7GNqcdPm7xXuxJ5VknZBe8xNgSQakCklIAM9Y9 M/tXW7YerwILLQKONWAtGoKLqcTvBtzmBwY/IzR3jcvURZQglkbsM/g/KgB2NiS5a0ov vVoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=fxF9egp/0MfNC6eP3oXuHL949t8miVwsCl5P35THCQ0=; b=oEgZSPtgKNxB6f6kLqZdXQ9uWFqcFmIry8GzPzN6Bpv0ac9sj2gK2y8N75lKDbV0ep +Fh2Szlba0425HMOPaaZIzZ5uwYzRUI+tl8eHCeNyyz4ezecV7iR8DLv3k4/+ti25O2x jmyXZOFViKLeCltmslk8DWObR7TtwU7pBjxJhQ3TAj+0LakWb75tiHAGd4D8hy9V59wB 0w1xeIDIPrP32VJdCn8NF7HnUzrxICqZCidXLQNCbdRk/1/IZeyZ15rbZT3NGOYgDRAE 9iFZg93SRt3mTSLy81dZ96JoMwVQDImJC/cR5tDJJzKkZsh6h0gvFxIsX0Ei7TzhS3/I 1zLQ== X-Gm-Message-State: ABuFfojTRrxpmSoIdOYiTrkzpXrC6DJvhGJX1lr/6pdm8j+LbrtgHm+s 4C6vUJgU9LvkLh5xIZi4uq1jtQ== X-Google-Smtp-Source: ACcGV636ILuqRfdWOg/6E/YNgwltlS2o+vJZwooGLdmWZ+ffN3YpnBW1fp9l4X+RFEOUrIOJ5hu2bA== X-Received: by 2002:a0c:acad:: with SMTP id m42-v6mr1166622qvc.27.1537889423820; Tue, 25 Sep 2018 08:30:23 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id o2-v6sm1965827qkl.63.2018.09.25.08.30.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Sep 2018 08:30:22 -0700 (PDT) From: Josef Bacik To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, linux-btrfs@vger.kernel.org, riel@redhat.com, hannes@cmpxchg.org, tj@kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 5/8] mm: drop the mmap_sem in all read fault cases Date: Tue, 25 Sep 2018 11:30:08 -0400 Message-Id: <20180925153011.15311-6-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180925153011.15311-1-josef@toxicpanda.com> References: <20180925153011.15311-1-josef@toxicpanda.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Johannes' patches didn't quite cover all of the IO cases that we need to drop the mmap_sem for, this patch covers the rest of them. Signed-off-by: Josef Bacik --- mm/filemap.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 1ed35cd99b2c..65395ee132a0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2523,6 +2523,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) int error; struct mm_struct *mm = vmf->vma->vm_mm; struct file *file = vmf->vma->vm_file; + struct file *fpin = NULL; struct address_space *mapping = file->f_mapping; struct file_ra_state *ra = &file->f_ra; struct inode *inode = mapping->host; @@ -2610,11 +2611,15 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) return ret | VM_FAULT_LOCKED; no_cached_page: + fpin = maybe_unlock_mmap_for_io(vmf->vma, vmf->flags); + /* * We're only likely to ever get here if MADV_RANDOM is in * effect. */ error = page_cache_read(file, offset, vmf->gfp_mask); + if (fpin) + goto out_retry; /* * The page we want has now been added to the page cache. @@ -2634,6 +2639,8 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) return VM_FAULT_SIGBUS; page_not_uptodate: + fpin = maybe_unlock_mmap_for_io(vmf->vma, vmf->flags); + /* * Umm, take care of errors if the page isn't up-to-date. * Try to re-read it _once_. We do this synchronously, @@ -2647,6 +2654,8 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) if (!PageUptodate(page)) error = -EIO; } + if (fpin) + goto out_retry; put_page(page); if (!error || error == AOP_TRUNCATED_PAGE) @@ -2665,6 +2674,8 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) } out_retry: + if (fpin) + fput(fpin); if (page) put_page(page); return ret | VM_FAULT_RETRY;