Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp1121201oof; Tue, 25 Sep 2018 08:31:26 -0700 (PDT) X-Google-Smtp-Source: ACcGV60OfabLe3LAKIm9cDC8bUX+FmbslFp+4gZ1NBNX0zDCXfaSEbXwyItrKd6CHpbpBdEzJoVa X-Received: by 2002:a63:e255:: with SMTP id y21-v6mr1624440pgj.160.1537889486131; Tue, 25 Sep 2018 08:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537889486; cv=none; d=google.com; s=arc-20160816; b=QzATE82yRxkhrY/Myaj4gfJ4NRDjVgFspVQ9hYKcZGvLT7gZETEeApZjlfxBR8lcc7 O4+6WE2crQMKea9RYaTFmnB2lEw+rSbee3s1ZFYB1W1oa7xTKrAmRcV9/mHV+NcDisdg E8upGZ7UlGZFQXkYPPZP9X7CT2eEZpPa+RmePdUnSlEvJww8RFs4a1V6qke0Sgyj9WtU qNdai2X3pgBZuFbAsKorCtrOCoO3q+mOmJcDB2HvLk95oKCUKCT6/HmheaR/DguKqs4C 4d4r0zUPMBfxt2WbjhKBbRz8JON6KxBvd6EUhm1FD099A23oov2UtcAcxZZW7UneQkN0 IdWA== 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=yWPStJzj1cnk92wGkz2xvmxPe1HGXamT+Z/uYxQx2xjcmp+pSwb9q9suAbooFrFpC3 msLWhThNwhAC4vqg+vngzrmurl1KZpCtfyK0se1LOAGJwUgCTu1THZ/Qhs8ahMRZwqmw TOpIrbUYDBy4R23UOhttUInTndjRb19xm95Y6+PTgdnB+z850YUxGZMsxplgFgmNFtVg AXsnNxhmkNVvpMm7AagYJ9qONoEosSyn5xmIocUr8UrgGQlc//WWfyuDDqEPqU163jvH Y1kk0enMOuYJLklzMwHqVKf+yWLMsouszrmc1Bpn1EVGx1nRa/6HafK//71ZiO0e7YXZ 7F8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=DEmAPLzk; 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 a5-v6si2633029pgd.400.2018.09.25.08.31.10; Tue, 25 Sep 2018 08:31:26 -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=DEmAPLzk; 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 S1729845AbeIYVi1 (ORCPT + 99 others); Tue, 25 Sep 2018 17:38:27 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:46954 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729797AbeIYViZ (ORCPT ); Tue, 25 Sep 2018 17:38:25 -0400 Received: by mail-qt1-f194.google.com with SMTP id h22-v6so5828563qtr.13 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=ui2YUMg0OyRMph4U6m6zBt04Q+6dBZekzXsl0pKM+d/ElrHn3xAqyCsF7PkjqBW+xw OJxokVdlRl0fTrm6cInhKUzhUhk/y3iFDbt5UI34zERfKqkXW9cFGKE4jtETLJD0+H+k u9RPVCd229n8I7iYxSWa1fv79BqXQ9k/4tdo2+c2E9S9rapRG5H9F7Rqd2Qhu0xdRCe5 91ZTVzCwl8dQVBLXSTCSjeu8Q40mTa8fQ/McSC85ZBZIxxIFQJJ4RTfiFP+YqCIMQvax uaJSt8lCTZRIH/i+J+5uy/IFi6pv+KEqeHKMDDyMBGK7uIZ74YT6lwa1LsBXF5akD00c VC6w== X-Gm-Message-State: ABuFfogzDVLw4SR4PUovO3GUd56iGv0GeDWPhQm41mpXiy3Z52DaDfJN Wl/dxGGaCYEmbIxfwyo1/n9bww== 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-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