Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1238438imm; Wed, 26 Sep 2018 14:11:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV6061WHeqaesswi4os4Mz/LiykzTR0Mzg+lz5Yq0IxQH0zHd0WBFm2gIQjMWZAaF7ArtVO+f X-Received: by 2002:a63:1342:: with SMTP id 2-v6mr7219920pgt.19.1537996304393; Wed, 26 Sep 2018 14:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537996304; cv=none; d=google.com; s=arc-20160816; b=zBWCbq889+RWfMBy42qhi8lS9e26wtC1EiM5SAKYiRVxC7qqNjXaP1/dclAQqxxXy2 DkXU8vdlZO1NpoKm77roO4wYzos4oTXSiLdRLdd+NLb86OIEDBL2KeFm8gh6cZyy2eP5 LggJ6Q3Du4d71UsGGbRoKzblSPff1oOG5uGmZGmgmOfOmPoj8Z8PfkOeWQGgELCUUaRC i2PdTCc4ogcfrY8zybWlY64whmmlGg98rmFc5zr0hz7m9dcfRHC/SGG3Oz8+boKs0iaG IiCYjZYmXPgYNd6tYSMvZa4yjL1umI1b3wrfC+NK5/SS/V9esjFGdOVSIdApLDY4Y6GU bQQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature; bh=fxF9egp/0MfNC6eP3oXuHL949t8miVwsCl5P35THCQ0=; b=XQ5XSr8uFDa1AeGLilbodV+jQE/5RsOvQIR0UUBWqFAA3PRY/bBfxtWqYOg0S4AJNz SYD99NK9ITwm98eQexF3qedCdTgWrIjM0DOWLkeJfIs2ASfR2oO1vLG5P0WFlLzFHI49 8ZA72k9FqW7CZUF21jJSPn6zBkVKRz1R9iZlw35f26K9smRDLOQYL+CSKCZMbdhsamg3 Rqc20nkNcWkY2WUJ7+loLEz3C7EAid/QyZiAyz99Ly05gxDsP9ajWGmUvyNJTIm1iY7s 1++NGqbd7F0uMQqJFrtr0NjnTf+fHIimbpqjnCVe8Z7PeBxyMWVieJrJAA2MhduQzNKY KWGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=xOG6WUhz; 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 m23-v6si58388pgn.603.2018.09.26.14.11.29; Wed, 26 Sep 2018 14:11:44 -0700 (PDT) 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; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=xOG6WUhz; 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 S1727344AbeI0DYh (ORCPT + 99 others); Wed, 26 Sep 2018 23:24:37 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:38607 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727182AbeI0DX7 (ORCPT ); Wed, 26 Sep 2018 23:23:59 -0400 Received: by mail-qk1-f195.google.com with SMTP id s129-v6so288996qke.5 for ; Wed, 26 Sep 2018 14:09:08 -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=xOG6WUhzNHnJDZ8nzE96i5QNtT6Li8Q5zD7JZrUCY2qx9cUIzLHEP5+zgNwBSUtFyp Vsfjd4p80uZmD0X8I4mjGdoXPyZvnafq7f/RBkRbGjEddLbwCS/WwDEsPVkieZMO3WT7 9GYB6qMA/ROB+5KW8+jhZX3ScR0o+/oJHMadB8CL19veYAyrsYcy3UDgvQdXAdmVLpkp 3Lih8/OrYQEWboL0v9vg8SCRCFeaSEwiqoZebAIL5B0MyFM2arHx3endVqpa2rnLVSFF n40P6Ou4BESYXohRryM+Ny3UOyY2G+mJqJ3eWtgKvm8hpnmXLoKe2UZSeAxwErLr5ICk dqww== 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=SPrkWTdEqVC0tn1wXYPGmkJEyAzcs0pjE4PrNPdQtSKEuGkm0Ge8DwDbkyIoVHDeZq ZkKYyomjH/+f74Np3Q/ji998XnY3FyuOf1rPJ3TPcvyHp0g7H7QgV3DPFQ5lMnlRM0lH Ws2mrQxsL0RNu9XmHNJqllJRY0JJxmNpfpnv9UGBTHXMejgm5DiEOaOY6+Bkn0mFYjr/ OWJfGg3kX3nrvSWAPuL5x+6F6Y9DXPBdXGnHTrIZq07LkCJaySOArKSkklKyN9IympBZ TzW8C1bCBsKlkxAXWcaZTyXABViSfXi0EyR/IE8mdgsuFf6ZEVV7pUe+9CWgGbS2F6gJ XfNw== X-Gm-Message-State: ABuFfoitaszvgQK1TTx3bYFmz0MWq3QfQ6R3ejkiPg5hyyZlRp+3Lwdu zfAiETB5Dt5+Y4Wz69ElAZrUzg== X-Received: by 2002:ae9:e892:: with SMTP id a140-v6mr5494846qkg.242.1537996148385; Wed, 26 Sep 2018 14:09:08 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id o7-v6sm50246qkc.67.2018.09.26.14.09.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 14:09:07 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-kernel@vger.kernel.org, hannes@cmpxchg.org, tj@kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, riel@redhat.com, linux-mm@kvack.org, linux-btrfs@vger.kernel.org Subject: [PATCH 5/9] mm: drop the mmap_sem in all read fault cases Date: Wed, 26 Sep 2018 17:08:52 -0400 Message-Id: <20180926210856.7895-6-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180926210856.7895-1-josef@toxicpanda.com> References: <20180926210856.7895-1-josef@toxicpanda.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.14.3