Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2366049imm; Thu, 18 Oct 2018 13:26:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV62s28zEZRotZ6yyt4knVge7qj2Bnez1l+f81+9aawm1QhfOx6cb2pqLz3JmWhNUjFOiztm1 X-Received: by 2002:a63:8f09:: with SMTP id n9-v6mr29434391pgd.222.1539894381292; Thu, 18 Oct 2018 13:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539894381; cv=none; d=google.com; s=arc-20160816; b=ln6kWEqL7QEn8BcBV9V1OW/QcxE+gVNNFC4yDKfP/L1REe7lVHu/vlvjjmQYD8qiMY QLiM1uwE9Uu2pyhCMg/9yoj8hGcJycI2o1tzCV3WFBw1HOAEQbChbxfMXJfHtVWniA+1 2js/uagp35WM/DSoLAYWerj1BRomr5w4F9bZsxcqtXXrudCo1ZtaS20YaLu9efVbYY3f Rq3s/A0hn9+7fBVEXLr5ok4DpVLU9XowDyt9zyR8s09xQIq8D9fMJGDBEJTMY6Q4YbF3 UPzxuH45O/CSEuThL6ChP2eKnOPckbjPsX1u/nHeyQ6UVjufiVvuQKWjzrRqsFbnhkj/ pcwA== 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=rKyP8Ls0Ti7/tK9fYR24gK20Abe3Nq8AyKyII8117ihP14uXH2GFgKJLrRE/ketE+X XGotLpgmE23HyWlXn8hqflWY9+KjLs5/iedcnQUTcG+ZHxm5g9y8L2iVFFdody5N5yAl HO5J/86bSRNu0tGVMEMQWG/9dyFoPCKMES0BAbJfNAS0vrikB+mx3LYJfGzCtq4LUb7m Zsi1IxhfBnEgKpM9KF1hm9Yxamh/N5xDKAh+KkkhxTmGi2akbZZ17d/NazgurG8yFB8S 3j8ViqK9mvfz4+eh6w8r81MC4aQWFjMHQJQws8AC70QQFHnZtQdn4aPYUgB5GBHXjs/E m8eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=CsGd4MKY; 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 z191-v6si20370213pgd.451.2018.10.18.13.26.06; Thu, 18 Oct 2018 13:26:21 -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=CsGd4MKY; 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 S1727567AbeJSE0r (ORCPT + 99 others); Fri, 19 Oct 2018 00:26:47 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:43420 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727466AbeJSE0O (ORCPT ); Fri, 19 Oct 2018 00:26:14 -0400 Received: by mail-qt1-f194.google.com with SMTP id q41-v6so35842326qtq.10 for ; Thu, 18 Oct 2018 13:23:33 -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=CsGd4MKY/m+BPmdLJs1XHbIfFvNHSiitKVVvPPLGWo5GU4tkWD2chfSUrV5zjUnnpd MEUkQhixYy33qgfBuHB19UlLntUG7w/9YmUYulSdDJbj9IDIkEvv27avzNxO+ld+Rpcb 1ujI9o6Iwu5OcYN1l13rg0lrebrNiNCw/UqOPQOsCT68Lv0v1fdwV0hUAAYn6XNSfJ4N P5pZU2FQGAX3Trf0a/N1E5HQlDnUmAPue33l0Pp0OwRsnHUU0XbNvmOCnCcNBJWK4HWB z9TPDqwvl3zC3f308y+eCt9LAclba0uYOz3mN0EnOEzR/QNHs1iqquFfov2zw8VvRWqJ po3Q== 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=SC4c4ZoaEaKQSlqMsQVBowL6yG1Ka856JpEPF7LiAExmghHzJntPjbBYIhgvvqsJi4 LAvCHZEHkYQUGnO1vuUgUeBA19PJzHVWV9RNfOOcJGPipCMDqPaYho1b1w6vWGFPsn9q Y6/k/jeeGxobW1W8hvdaqKOe7pEUrYR9LHvcbRq4i2Y68fZXGI5X64UCWLb6abXPsisc tvIdnaMBrSzJE3tNY9tCuo8Yjx6w2db5BpmMdlmgiP2cblpryVK0MlOX2kVWrx0lq1DX ubpAoblXgfdZ/jgjAH/nvyh3wMYgZzE0JvSsL7SPf1BVwiKbZYHhB2v/pke6Ta9FyjJ1 valg== X-Gm-Message-State: ABuFfojUNwLWEJeZhngi+XH9NHPtA49eySsk6XaMX6jOwFOZO2XZlo6T KzQ0o8ETF/UQrm8oNi7sr1StEg== X-Received: by 2002:aed:2791:: with SMTP id a17-v6mr30183020qtd.303.1539894212661; Thu, 18 Oct 2018 13:23:32 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id n3-v6sm13614949qkc.48.2018.10.18.13.23.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 13:23:31 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, tj@kernel.org, david@fromorbit.com, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, riel@fb.com, linux-mm@kvack.org Subject: [PATCH 3/7] mm: drop the mmap_sem in all read fault cases Date: Thu, 18 Oct 2018 16:23:14 -0400 Message-Id: <20181018202318.9131-4-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181018202318.9131-1-josef@toxicpanda.com> References: <20181018202318.9131-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