From patchwork Thu Oct 18 20:23:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10648101 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 F155817D4 for ; Thu, 18 Oct 2018 20:23:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E489728D8F for ; Thu, 18 Oct 2018 20:23:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8BED28D92; Thu, 18 Oct 2018 20:23:42 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D1DF28D8F for ; Thu, 18 Oct 2018 20:23:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E3B66B000C; Thu, 18 Oct 2018 16:23:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 26A6C6B000D; Thu, 18 Oct 2018 16:23:34 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10BFA6B000E; Thu, 18 Oct 2018 16:23:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by kanga.kvack.org (Postfix) with ESMTP id D84CE6B000C for ; Thu, 18 Oct 2018 16:23:33 -0400 (EDT) Received: by mail-qt1-f200.google.com with SMTP id y23-v6so33192262qtc.7 for ; Thu, 18 Oct 2018 13:23:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:subject:date:message-id :in-reply-to:references; bh=fxF9egp/0MfNC6eP3oXuHL949t8miVwsCl5P35THCQ0=; b=i92paT1742ySk0kgNlndIywm8Qf0y/H8MqXYoSsLesGQ+5V2A6hO+VVCKqwrBKWWdv rMGs/cjFuemEklBY7I9wtMetmVbejp5uoJ3gng4MeN1CRqeJcrBsmh8vl5thqK5/6g/L LWZSCWDdWnTHVo5zza6dB2kQwKfb2KZIsoTcYSPFTeAMAx3Xoq2ftk/pO0jNw3AUP/XG 97ynYlgP20dq30w8eS2hHC+UoYoBcEEZ7WuOYtRBJmpnolWUiV1tT0dLVjIPY0eA/jn0 UKNXlShG3sYHREwEbRudOwp8wIsKfaL1UD18kk+oYShMANsGoNgvL8/HYfFv0a4Ghk1n yadw== X-Gm-Message-State: ABuFfoihh8wOeVLua2IogFA2UUqYDVoFevDsBfsjloFPbKi9fAp9yXbz BatoxPhx9TL+ntBJ8fy/liAwOltfUkUjgbndSNtG+9SAyvx0CkHYwor6Ai76edRpa8lgbnoJc0c BSHgds+8q3P2fJVLA+1S6QbPqvwnktrzGjimCpJ1F8Yx0gQHrw0Ibdcvx8NEit2weNxALKuOdFH Qz1klxpXSrleUp3uAjgd02mYnFhr6ejAiZtpIshD1b0XvICGHSfer+Jyd6Aip7GKViJrqJxo5oJ 6Bmt1shGFwNifskF8FB27iIec8C0aVRqdndYvaxe63bP4kXAr8PyaofNPloEW+nW5medfKr3+l0 GvCf1guxENaX5pXn+BC947XydAHjQ2H7CRoia7WMpo7RNVXJ0fNSqSS8vQgWiTXarmesdDc2UQJ g X-Received: by 2002:ac8:721a:: with SMTP id a26-v6mr9960396qtp.64.1539894213636; Thu, 18 Oct 2018 13:23:33 -0700 (PDT) X-Received: by 2002:ac8:721a:: with SMTP id a26-v6mr9960362qtp.64.1539894213026; Thu, 18 Oct 2018 13:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539894213; cv=none; d=google.com; s=arc-20160816; b=E7N+RQ5gS7S+WijIX2yjYuHoKvpV3EFy7h21doyw/iDQ3xB/Y9F3mE7M3ReZpHhZio pvuqgFOwihgvdjnHuuGjQJ8A4veuIrLHqBXxDuOJty1NjzFW4Yekc1fYjTPwnafEWAFe uR8pX8m6XQfM6nSL/JSNU/nmzKDoBr1CWRcW6gbM9VQBAftGRs3rGxn5ezMkAG5ds14C nK4EKKCw1PdnN/wZUftOQ+9Z83zwfH45bbAo+Djsr2pNnQSF6Y8jT00op9GYHGQgWnzV 2+1jk8nRwH3Aiooo0mrhGDY3KQY9gtD1Q5u6m2BR/GSXLSTkhlkBz1vf8JXu11j4b9xM jciw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=fxF9egp/0MfNC6eP3oXuHL949t8miVwsCl5P35THCQ0=; b=rE19SuGFnXLqlOlyqcWb1I3uM7qR05dTl7LIQf5MahNiF3wyOIKMTHmOlQyJNgfcbA mNHC6XbfoLw2NNQq2bd4mTXLOufJKWkhVgVH69JOyrepgBx9wqcFf7I/ZKQlhgEc2Onq Q00zY8j1VrWb142FH3MAKxn4NbB3YaqdfG1EEClTzNwp/HDi4/d+Iy3xSdx+ShbwVOHg 5zSFjnh1ITvojLpkdpUP6Or0yYenwu1h2Z4PsJU8MNErCq3LmmD1+kMvdsloBk8cCRND hSI9QlVqLiAlf+av00rjeihDyXTU9FJzBdPmxCGplGsxvLVZN3hOy7lzxTwYmJs8WYgr l4JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=CsGd4MKY; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) smtp.mailfrom=josef@toxicpanda.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m30-v6sor25788238qtd.70.2018.10.18.13.23.32 for (Google Transport Security); Thu, 18 Oct 2018 13:23:32 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=CsGd4MKY; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) smtp.mailfrom=josef@toxicpanda.com 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-Smtp-Source: ACcGV630Z4wH07uH115hll3vDXkYV06Zr9DVywG5L0C4yssKYm3wAfDGCW8PcK+V6OEPe9bJVZ2VLQ== 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;