From patchwork Tue Jul 11 20:20:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13309343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15350C001DE for ; Tue, 11 Jul 2023 20:21:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A24458D0006; Tue, 11 Jul 2023 16:21:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D4558D0002; Tue, 11 Jul 2023 16:21:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C4198D0006; Tue, 11 Jul 2023 16:21:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7B8FD8D0002 for ; Tue, 11 Jul 2023 16:21:16 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 30B7EA039B for ; Tue, 11 Jul 2023 20:21:16 +0000 (UTC) X-FDA: 81000450552.05.D524F1B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 6D3754001B for ; Tue, 11 Jul 2023 20:21:14 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="N/UAfb14"; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689106874; a=rsa-sha256; cv=none; b=8Coj2DSjK54wwtiEcFRsPtOO7VRt++GHJQvQOwbvHbw7mqgLMQlu6TyoZuQGisEw3C6cMK cWuvns6db5Jng/r2EMpgXDI1Uv1EEKqlPQr5Q3V/fpguHK08VuKlr9fjflBVwdw8bXfHsp l8yhABv7il7+1ab1mX3n9c2KljtuxtA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="N/UAfb14"; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689106874; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1J6AQ/unSE4IC1W70poNN/OYLEC8RIrhsKKg+sT5K2M=; b=SO8PR+o5n1RjBsHEEQ2AzsMWBSiGJOkWH+WdyFwwE6p6gl9yfiolRhGzRUtkAcwHBbLd6Q 50I1cgX4WOvYToTZpod7IW6QecEK2jNhMT7RslIfUYkSbbA2jrRohHVLPRDPdnjxOXPht3 HRytFT0JxAxLxAUMQTjpZ1nMvF9FT2Q= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=1J6AQ/unSE4IC1W70poNN/OYLEC8RIrhsKKg+sT5K2M=; b=N/UAfb14mocbi+tYXm4qnqDyG2 54o1KXDavmlW/bXWhMvMxUY0YE4V7uNEqi2dinDdzSmQaNlP0d+Yo6FQ2sFbcl0CI4HlzHr8GgyI3 1XULhcv0Vfox/1xF4oknDaW6xBMDp4a8gImwj39X+NOkn+YB4nvufbnG1EEQvBTxBx9D5U2xysqUK 7lgn9jqfuC3V29CCgIJTSn59h4STqEJYBLzWetZR48XDpxEouAj6oMF1+SnvSA0dsDRjjqbB7/ymW bq5CuSOEJW5NWZQrReS0SsFhu2hMZx+h3GJZFO0tayozQN0qenw3amuyVgKEuBcMmwrOV8B3rWlCf 6//Jqs+Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qJJqs-00G1QF-2B; Tue, 11 Jul 2023 20:20:50 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Arjun Roy , Eric Dumazet , Suren Baghdasaryan , linux-fsdevel@vger.kernel.org, Punit Agrawal Subject: [PATCH v2 5/9] mm: Move FAULT_FLAG_VMA_LOCK check down in handle_pte_fault() Date: Tue, 11 Jul 2023 21:20:43 +0100 Message-Id: <20230711202047.3818697-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230711202047.3818697-1-willy@infradead.org> References: <20230711202047.3818697-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 6D3754001B X-Stat-Signature: o31559jsbzyof8sk5xi5qtjh6hw1pgpd X-Rspam-User: X-HE-Tag: 1689106874-909667 X-HE-Meta: U2FsdGVkX1/1Gf0MdwQL8iNta3iluxTEE8tVPu7FStCqGrmxxsYL/8tFpGVRqHsUqj/NMpCkhtCrtScmNZEDhRsxNyEU3TDBMeKsY4FRYqeIr4pWC0rY96ViVCiRwsd10cidXN7F4OzT+n5NAb64D6Cj0RXCA5gvUKchJb8ktaJkxpORRpJbtH8n3qrxwyMLQhufgY7MGz4qeBKumUNz0RI6l0U1wSL1gdtnR0I/62ZIpzMpMYtSIbJ9mPzATCgDIMYgAuq6y8ES4MEYcqnBni556dFjCFxrMz3Vc3tu2m3SGejM0cqwfO+8RtyPBjQrx+XpsPsjvrctKDnJBBHP33C/3mYIeuUINVLtqkADn0LF3ZUPE+nB1CC9QBkiWuIDXxkUUwwUnuseG/OZT/NOoBOxwzxuuo2WHPlFSW1N22QkL8BU9k11wHjy841b0rpdB3JC6inyqjG7qqLpI86xfXm4HSgg2EZg/zI6kasuj3VZPGQCxo+2C2M3RPSqSl6NjD0S3vjXQ6oWhexl0h1w+OP2kOBFSdhXHXhiaE1atfQ0hN+r2s2uTVG96Q5yo/7KUxEht5x/GvQwi/UZkjhh2/rJ4fCMhCUs/EN8t7TEPv8X03bBeL2ruS/HNhGO0eEa2yfpWjND/IPTlL5hZJnvezkzOGNtPz9OBg3LXfLbST3Vojfm4CayQ0oT2x2oUptj++CPB3eIgbiYe1JJ1L1v1Ml7yMH/yWnT2mOqt/NozCQC2YMxDdAjqkhru2UIgOgo2UwEsCgAC+M25vorY0+dl6iKs0T0ONFFYTBy0Nn6eHHZcKf0r3C7NcIcxN1uQovRkPh2eymQ8vG1sJWuCmjY6s2+MZt71Adu2Jgaxjys3b5beS5CxjXecBJHPnSgJS+Qu2P/uyKB20YYbibffr+/DqUH43hBIEP/bLnPZHG4H35dEq7U+gfKQwdPx9rvCnkQkS5+k2CtO6/h+17reeg 724mkyDD 8nmVZKp6ijp3Gvu72yVQKV7cR80CXRwbHduC3ihkfybfWlYUvir3j8+/jspTIqzc7aUSZDaMhGo8cLvxp2SpVn80v9nWXko2fO6gXAw2PTEFSVi4D+zKw0UmmJ8B0ZL2iusKMIRvDei0SoXqHe91GvD9vy44Hp0/fYYKkhKwqNZszgbfKCenbsSPeQqIsn0ep3tTpn5cpUI/lFNrwFSI5Hz2vWu6XfjmYGj/N 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: Call do_pte_missing() under the VMA lock ... then immediately retry in do_fault(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Suren Baghdasaryan --- mm/memory.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 52f7fdd78380..88cf9860f17e 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4661,6 +4661,11 @@ static vm_fault_t do_fault(struct vm_fault *vmf) struct mm_struct *vm_mm = vma->vm_mm; vm_fault_t ret; + if (vmf->flags & FAULT_FLAG_VMA_LOCK){ + vma_end_read(vma); + return VM_FAULT_RETRY; + } + /* * The VMA was not fully populated on mmap() or missing VM_DONTEXPAND */ @@ -4924,11 +4929,6 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf) { pte_t entry; - if ((vmf->flags & FAULT_FLAG_VMA_LOCK) && !vma_is_anonymous(vmf->vma)) { - vma_end_read(vmf->vma); - return VM_FAULT_RETRY; - } - if (unlikely(pmd_none(*vmf->pmd))) { /* * Leave __pte_alloc() until later: because vm_ops->fault may @@ -4961,6 +4961,11 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf) if (!vmf->pte) return do_pte_missing(vmf); + if ((vmf->flags & FAULT_FLAG_VMA_LOCK) && !vma_is_anonymous(vmf->vma)) { + vma_end_read(vmf->vma); + return VM_FAULT_RETRY; + } + if (!pte_present(vmf->orig_pte)) return do_swap_page(vmf);