From patchwork Mon Jul 24 18:54:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13325261 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 05C7DC0015E for ; Mon, 24 Jul 2023 18:54:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F90F6B007B; Mon, 24 Jul 2023 14:54:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57F596B007D; Mon, 24 Jul 2023 14:54:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46F6E6B007E; Mon, 24 Jul 2023 14:54:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 394156B007B for ; Mon, 24 Jul 2023 14:54:27 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0A776120AD2 for ; Mon, 24 Jul 2023 18:54:27 +0000 (UTC) X-FDA: 81047406174.16.18942CB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id A5FB010000F for ; Mon, 24 Jul 2023 18:54:24 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=pq4q53ip; dmarc=none; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690224864; 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=Bf2WSeVVnx5PtuK0GrdZC7nqaCiGfJc1owLWRc2d9S0=; b=5Bc+9n39OVQQWH+HI/BF0ZZNM2rb7ElirOUVhhNX+wvpIFUv/TgguEyvBhvzK4pMFd0Fxs XIIAijNpFFyNTqsJVNTmYLmvQkABW+sMDkmr08/0uzxmJP0INGTD23YBvhj8VMSc7/676d EmUPGG7CVyD0ukl0fy9H7HO2AXmZ144= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=pq4q53ip; dmarc=none; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690224864; a=rsa-sha256; cv=none; b=BT3z5CbNiQ2Ez4Z2b8o9+AU/Oav9Z8cZBSFAxximEiOZ1Z9+GHo1p35cK0mXVJ+3l1c2Sm XTFwa9P1EZ0Z35KTArmRtv/shP8/ayMh3LOgwBiJYj/2UB0bER4FoZKh0jrohFt8u92WTF 7XZ5ZQkTUfi1az1aSmATSWZXBvQDAmU= 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=Bf2WSeVVnx5PtuK0GrdZC7nqaCiGfJc1owLWRc2d9S0=; b=pq4q53ipW8imewozPRVRm9SF+m RVM+pPZTkW+xlAdqR4U8etpaEe/I/DDBVIxPfL9YcKgLPN700wsZFK/8HQ5tiM5SH9mlMAQeOGFQA pCDpj4vAGjQDG2G8pb6Xmrrw2nge32+b/8RHXob2OgRXXA53Z7FI7GZWoNnSVpT3xUtrrRsaP4FR6 tK7rBBJ1LALKGEDtjsDaIcr8sxHVwqGwW0SYlCDqoxT5OW/qwUT1M9eB4glQiild/Zb7Pqwbx9PUp /ECOtnxFdu74Lg9qhUaT959BflWAxgCMzx3rOnmDtJjeTqakbEK6eH6mVpXBfeR3DdLPiqoB/07ik DDyIR+Uw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qO0hA-004iRH-PM; Mon, 24 Jul 2023 18:54:12 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Punit Agrawal Subject: [PATCH v3 09/10] mm: Handle swap and NUMA PTE faults under the VMA lock Date: Mon, 24 Jul 2023 19:54:09 +0100 Message-Id: <20230724185410.1124082-10-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230724185410.1124082-1-willy@infradead.org> References: <20230724185410.1124082-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A5FB010000F X-Stat-Signature: ech6goq6xd8xnkmbnqz5fhgo1xjxx859 X-Rspam-User: X-HE-Tag: 1690224864-620869 X-HE-Meta: U2FsdGVkX1/yfmOYwkigWEit0VSPYAUJDW30HecbrMpxxSDMJj71DYCkqLwGAEeSVF1MjaDzW2OtjsC9mnW5CO8n9T+gIIlgY3lEqbE8pEw4liEFRzkLxB/LCqH81w8h1II8EP07/fBaMdmXPlycOt9lEAdNzCK1dbHLgKwAPO55utBppb2gWsLiEvSVAtuYfZZYqgmFFzdfVStzP6LaiPZM8EyrX20Qf7lkqYVce+m7idlC7Wqo7dUzYZlIwS6dBBrwy8NWDQNRaRUVoJYcXqcG+cGXOJsSGlRVcZBhRsKdOY6TRF14sertLPIYUcZZ9uteWhfQzmOqePWDovoldO3+oGJN06VhM4fjY/mSgIbtPbonSypVpGEH6pOkbdO5HUW5xrnj8RPMzpW5RX7hvDnVZiiziPv1iH4See9MX0g1BEMi6FF5u5udGLB9GEiIRcR+B6Pj6zVIPnixD3aY4cXHAaMU6DKcFFtSeK1+wFWPEo9p19Me1d4jZKPKbUXOR94yGUz2bhbHyNyArSP0NwwgJav+BJjpf5Vvw/mo0y9NdsKIuVrKALLcmkMNpDfzL9ThcL1XnXPiFrtzmawp/FAYCEPvittoVW8X6FotwRt52jSaC4Be3ykZyE6jcsCh03ZlV2+k/ibDAx09oVGT2qfx2LTtUofKR5coNtLNINT375OWEoWbY0JJL230LO5A3Y5MJw4yJ2lE75k+k7uq6MhQ4ZPdGCy08FjG8STYOwh2Z2EHotHJRhXcLVnvOJJwIRQ/l1cjaG8c57DmwrA96HQT2e9LFD9PccZz4wK3pur5UoQ5N+LupkRpM7ZAPU9y4eBkFyd492EZ8ufZQowzE5J2Iqu273+1IR3HCynFxKC2c+2BUr5ywVxzqGzlURO8YqCWRcDQvzwPb6xFBovtetk7YC5/zTQaWhKLh5UNH4Fa05auURE3wMsjvd1d7hyyYNB0cri6b+HvgdnXVZs NJdfferk 3DJMVcL1RYzKt2aoyucNPk592np7BqYQ/ZbsSkGtxarxU0Y6SktWzqIgOQ9O5AAlQNv2YcPfSccAW6+8kHO9e/+2W9+Vg9e/Jaj/GP+MT5WHvcmFt3GtsbCobD47Kx25roPn0tFRwIics4rsTEHLzdVSKXGtOk8Tvh2Xyqbh7p/JDTF661x5yUWyY+w== 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: Move the FAULT_FLAG_VMA_LOCK check down in handle_pte_fault(). This is probably not a huge win in its own right, but is a nicely separable bit from the next patch. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index cf28afe7a416..ad77ac7f8c9b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5107,18 +5107,18 @@ 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)) { - pte_unmap(vmf->pte); - vma_end_read(vmf->vma); - return VM_FAULT_RETRY; - } - if (!pte_present(vmf->orig_pte)) return do_swap_page(vmf); if (pte_protnone(vmf->orig_pte) && vma_is_accessible(vmf->vma)) return do_numa_page(vmf); + if ((vmf->flags & FAULT_FLAG_VMA_LOCK) && !vma_is_anonymous(vmf->vma)) { + pte_unmap(vmf->pte); + vma_end_read(vmf->vma); + return VM_FAULT_RETRY; + } + spin_lock(vmf->ptl); entry = vmf->orig_pte; if (unlikely(!pte_same(ptep_get(vmf->pte), entry))) {