From patchwork Thu Oct 18 20:23:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10648107 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 7E12617D4 for ; Thu, 18 Oct 2018 20:23:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 702D428D94 for ; Thu, 18 Oct 2018 20:23:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64F5728D9D; Thu, 18 Oct 2018 20:23:52 +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 063D328D94 for ; Thu, 18 Oct 2018 20:23:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD8176B0269; Thu, 18 Oct 2018 16:23:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A35AF6B026A; Thu, 18 Oct 2018 16:23:39 -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 8ADE56B026C; Thu, 18 Oct 2018 16:23:39 -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 586916B0269 for ; Thu, 18 Oct 2018 16:23:39 -0400 (EDT) Received: by mail-qt1-f200.google.com with SMTP id u28-v6so33941709qtu.3 for ; Thu, 18 Oct 2018 13:23:39 -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=Hfe+8/p9IgmtmhKjFsy8lPGB052ph7HB1j0v1iwnQq4=; b=sWxv83nC+tQEu62NDUWPgC6yQkWqt4SOzSnBQhk22UG6S2nzCfJrOa0/mbcpyGZwpe +ScmpUNLa4q5VgF6/Wz4H6a2SToa6bc0m0xJ1RWxahHFEKIw76eMnmWUmQD9GKYvjwPE tFMvF2s2sqfbWUiOYhU3Bgl1iH2CoDiKilwbX/8xa/WHb8wAPvtYv6JOfPjDiegDSv2K XHZnjLuWEZgoUqw54d0pXn+m2EdOe9Yf9MIX42Y4c+FnWGoeMLMr9E2SHLdrKanzm6EM LZDz/z1dwtGSFA8lTi0UDPytT2zTir/3DR0ANzaF8CREbQNb6WUJ6K0mu5qHuSSwbUIi NvoQ== X-Gm-Message-State: ABuFfogGQqW4hnrFNsoWxjHlHPp95q7GGUz21+5WjWLzzv92oBjh0ltr rQ886L8ToUuqBzErQpjI34I1667KAvy6R7qjxNlrcYTPcIqtOX8kewzRuehkMfS2bcSQUDf/cx2 g5De699vwT9z+j38hTFFbH4KeNeaOlaBHPDtkXcs03Ho9u35q56vgc/jPOSoI65rUHu7xRu8IGi 3P2cTpNYfeWuCoX0SteLvPRMrxgnvCaywJLreV2oyn08pRR9zDVXCutwTDiKngnt2g2VtugoD0x gBN6N144pZSuwdPnp3M95usHqqywxg7xfbH0O3lwfZqtwOX6bss/feZmMPeH435HjkIRouYeu6d sDS7iqqsA0mVOVrQDZebiG4ThC/RnLxwF8J9SwxOGrXyaTTQe+KJAnCgrKsmC0KQwwUMQ5zgG7e / X-Received: by 2002:a37:c50f:: with SMTP id p15-v6mr30043148qki.61.1539894218963; Thu, 18 Oct 2018 13:23:38 -0700 (PDT) X-Received: by 2002:a37:c50f:: with SMTP id p15-v6mr30043120qki.61.1539894218391; Thu, 18 Oct 2018 13:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539894218; cv=none; d=google.com; s=arc-20160816; b=Gq5lbcez1jyW0xt8V6N1ruF2km9hlnEM2oMNck2B5PABu2og0H4smvXHrmKty7c+5S Rsbq+2Xjdhe7oFXM6+O+KTT81unISP6MpDF87qRwvfzpYV/AOPc5hUb+WzcDmvAqiWTv UidHtoqmx7a/s7I+7qVghbwuoeclYDrbqZ4aM1vbHnjXZoDvGN9iKHw3RYZiCbAWlhNf /Lo8Y3lQcIne82hpsZ3pNDHUQCRV/ACKszHNf2MiL7Osc+PtmMXCyz2WGd6Qk3coeFj1 T9wtihC7j0Q+qVFKMg67UBt8VKfF70bk4DrpmEQ35bor1P1FLr39X8caKqaUcdZIUV91 7tNw== 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=Hfe+8/p9IgmtmhKjFsy8lPGB052ph7HB1j0v1iwnQq4=; b=cWisv24PcBPoKYTxcV1sYC25Zg9CZ1V5gsVOntWcUwX7nCJbUfFnd7Lsx5b6KFzSWs gtMm523btnJML+FcTYlmBEzlKmSEs9EXWNIf+hPGLRlZt0FaAw/QUXH9LMnfhnn21X0X 3GyIkSbuT4Qqu8ojLb/miYxuvV8vgaNp3Jqq7bpdMZNLVMEiu8gxNIz08Ad1GMegXC5H WFYcqfMrPngBBtWKKoLCFhZnsYSfaTG1SpaTEwHmaqu8W2LhGTw7mfXmIG98EZpQ6YOu gxVpzkYP2iLPIExbewhQNzdqlJ8O/q83YX9vqfdvhHftnHruWcLh/pAQZOCkiKT8CVlJ WHnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=UD0ffWno; 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 y23-v6sor3540275qkj.70.2018.10.18.13.23.38 for (Google Transport Security); Thu, 18 Oct 2018 13:23:38 -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=UD0ffWno; 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=Hfe+8/p9IgmtmhKjFsy8lPGB052ph7HB1j0v1iwnQq4=; b=UD0ffWnoYdPxKmTAMvZoPxfbJC2KjBM/0Dcke0Ix6eSsVKjz9w7PYY8IK5N/nliLs3 VKmL8ZilBFRVfgEFj4StsMtMacPmSj9fKdydrrp8MEdxHEBBHTjtfhNByMyaVQ6jmVDG 3pOD6FCc30sXmTBFxp10qrT6K5mIdQjc9qXJbO+NgJRMatDFX1llMM7vgC1AuDki7ooy M/mCG6iBBraimIwkStOhg1t99t6Gzt5NpSpRZA04TD8ixFlnHYQkbB07vorA+vrBGuUD J7eeJkEBe3nSSFsS7Uzho/RKCr5AJjLtHSEZQfwKA95Qog8VoemHHVSDUUd3bd6YSpOI 0YGA== X-Google-Smtp-Source: ACcGV614w/+TGK2yLbQdZinPDCwxR2AIYh2D2xLFqtySMLNCGQJ40gas3jrhoUBZu3wueQSc2xXrgA== X-Received: by 2002:a37:9ac2:: with SMTP id c185-v6mr29524234qke.162.1539894217991; Thu, 18 Oct 2018 13:23:37 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id 14-v6sm5525307qki.73.2018.10.18.13.23.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 13:23:37 -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 6/7] mm: allow ->page_mkwrite to do retries Date: Thu, 18 Oct 2018 16:23:17 -0400 Message-Id: <20181018202318.9131-7-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 Before we didn't set the retry flag on our vm_fault. We want to allow file systems to drop the mmap_sem if they so choose, so set this flag and deal with VM_FAULT_RETRY appropriately. Signed-off-by: Josef Bacik --- mm/memory.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 433075f722ea..c5e81edd94f9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2384,11 +2384,13 @@ static vm_fault_t do_page_mkwrite(struct vm_fault *vmf) unsigned int old_flags = vmf->flags; vmf->flags = FAULT_FLAG_WRITE|FAULT_FLAG_MKWRITE; + vmf->flags |= old_flags & FAULT_FLAG_ALLOW_RETRY; ret = vmf->vma->vm_ops->page_mkwrite(vmf); /* Restore original flags so that caller is not surprised */ vmf->flags = old_flags; - if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE))) + if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | + VM_FAULT_RETRY))) return ret; if (unlikely(!(ret & VM_FAULT_LOCKED))) { lock_page(page); @@ -2683,7 +2685,8 @@ static vm_fault_t wp_page_shared(struct vm_fault *vmf) pte_unmap_unlock(vmf->pte, vmf->ptl); tmp = do_page_mkwrite(vmf); if (unlikely(!tmp || (tmp & - (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { + (VM_FAULT_ERROR | VM_FAULT_NOPAGE | + VM_FAULT_RETRY)))) { put_page(vmf->page); return tmp; } @@ -3716,7 +3719,8 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf) unlock_page(vmf->page); tmp = do_page_mkwrite(vmf); if (unlikely(!tmp || - (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { + (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | + VM_FAULT_RETRY)))) { put_page(vmf->page); return tmp; }