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: 10614259 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 11C8D161F for ; Tue, 25 Sep 2018 15:30:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF8C62A857 for ; Tue, 25 Sep 2018 15:30:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED35B2A8A4; Tue, 25 Sep 2018 15:30:38 +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=ham 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 6C7CA2A857 for ; Tue, 25 Sep 2018 15:30:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78C528E00A1; Tue, 25 Sep 2018 11:30:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 713918E009E; Tue, 25 Sep 2018 11:30:25 -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 4F2698E00A1; Tue, 25 Sep 2018 11:30:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 1401B8E009E for ; Tue, 25 Sep 2018 11:30:25 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id z19-v6so7553285qts.11 for ; Tue, 25 Sep 2018 08:30:25 -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=T6QzvQVWqZPoNXFYto0ZzsKXapCpFeJ9Hns929GJ0jLHPh5loMpP08x/JkMYZlGqfV 0I9Er0EJ8mH0Z8hx2m855FroBDPyROhmJ+p26p2FdDQRBbp8lIj9MiqcRgFVFPkMVJ0G s3tLce8fsZb8Wp2RJcHQ21HPmMN/bxPxybOCtAV7VoZ3SGJYKIudfNP11jzoCpdzDpNz mtvWfvaDcn1CjtGmIqWpiaG4uS+BrD8bhVhvpI1w0heVF6IJVYrZLqgdUYTfRixEK3Tu PCVgNlsELbHsA9A8MPrU+6EZMsLsuOSCn6UyMhdwxHJNOcQXA+5XLfHCvQdgXfEFqw2C E76A== X-Gm-Message-State: ABuFfojhZRhxutscgx0dfAc7fwWeuhi2gNDTKMg4fvMhKaakpT2Arwjt agnxT6nv4B+PiFuk20Zb3epL6av4DUtkb9kDXkFIihOrEg+XZgMAd6vjcJl1kuEJZgGdQrZOnbK J+q+mp25zkuBcoXjFcxx9bLWIRifv1tpKXNC77tWygdu2OW9SYcKKUHDlueS1MWdw4pBnM+J1dW En9oPgoC+kBJNcByU9k8onUO0ZxY9g5rjnA3eXA6Vjf6qzCvPSXGRocMM3gRnnvCfJUPc1pjfwb 6vs1l4vY6WLdabfGYpOIARFrhZnm4NrrM2dpQtzvueCAqotLAAWFDpAEcD+eux0CylUUB+d2DOH L2Goe5JMq0f6ixDaWtJIC61ZrZROle6LYmA76DRTxRbrXS4xaJ+F4tXjxTSxkH/o5GxjjXGGZlv U X-Received: by 2002:ac8:2bc3:: with SMTP id n3-v6mr1267915qtn.152.1537889424810; Tue, 25 Sep 2018 08:30:24 -0700 (PDT) X-Received: by 2002:ac8:2bc3:: with SMTP id n3-v6mr1267863qtn.152.1537889424075; Tue, 25 Sep 2018 08:30:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537889424; cv=none; d=google.com; s=arc-20160816; b=bNGgWjupzvz2xIz8Wj4bxP9GNGjGJo+jd/DeTfF8FkZ3HwIr3yAxQelqavgf8GRMv+ loGTIGD6l20UWpw7/lEL6eCnkdrv7xM0H6hx4dWO1tNmTlYj9GKBe0J2Hn7pwd/xRl7T OAmQrJqyJC0vJZ0UitqUqXh0hHfT4Fy2Fw2+YAGszirN6C8Zo0LgdRdl0rlr7i5n/HuL lbkGebOQvGdCIF4Pb2c5+sXadoEt4ecL23voO9hXSF+ucaLOTcQ3KLiRtpiP8SiYMWQ5 1dD2dqOFSBOzO1NjvaGCior4kdjK6orRdKkYM9Mwnnb2s2x7rmPbH4mgIGJePz/xZhnE EVpg== 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=j1CyO9GbzFhi3v2AtQwH6UAsynygsjx3vV/6dBsH334vjsvOwqWjKxRE2nB7KrePtQ LffnJfqHh5rM0WNTQ0fAdiJJP4VdlgitLipXlIw6fvKE4F+DJ1yvLEqEaATM0IhHTF/t qcTEPFzuz1qvX05WnKqTEM/azUUhOPGSSy9jZKDx5A9kh7pfXlPkfVs0eZC2L6NwtJF+ Lx2fGEIuJNYlXAlSyNptPvI+Jb6WSbauDvZNzOHEswXgFNlQL3yxyzsbV6jmdCYAbYAQ gAy4e2b/oIKP1Vza0BnrJfwuPCdU8tCaUBz91RZ0AZkK6SYtDqYmlr96qNoNfH7HXi7b 6R4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=DEmAPLzk; 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 d7-v6sor887251qvp.134.2018.09.25.08.30.24 for (Google Transport Security); Tue, 25 Sep 2018 08:30:24 -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=DEmAPLzk; 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=DEmAPLzkrPKAHv0xbTFGpZ6jamzlToLR/cRumBykBnmJoZyUpkUvG6gNwTXEEEvyo9 FzeLKBbs0BBVsDOCDYe7Z+Kt3M7PelIG7cQnsJ+iLSS0Q0hbOoLbqqKjMD25QmSZj3z5 6K56i3YJEvNJ7B6CpBPv1+KXW2xSGvgAYAbgPmw5fsr4RGI9WsKfIyWFaBWMxqTcB0OR 40CUFcmwjK6YV/Uz6Lh4a6RxyGCPOE7GNqcdPm7xXuxJ5VknZBe8xNgSQakCklIAM9Y9 M/tXW7YerwILLQKONWAtGoKLqcTvBtzmBwY/IzR3jcvURZQglkbsM/g/KgB2NiS5a0ov vVoA== 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> 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;