From patchwork Thu Feb 15 10:31:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 201388 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp324453dyb; Thu, 15 Feb 2024 03:17:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUQ6Vu89/khi1773S2/fYcNOtgYNdNS7mXLoaDykqBqFwtbyM5ZeHp/xMX8pE3I0YMRxFv3CM56vV8BQl5fygrkMYetTA== X-Google-Smtp-Source: AGHT+IEaCcaHpN/Y1vcsy7WfvY4YHw3GWON2iaw7Q3cgW6NGlGAsIJpAQpMZ3to40K5KHvURCSq8 X-Received: by 2002:a17:90a:468f:b0:296:454f:1e72 with SMTP id z15-20020a17090a468f00b00296454f1e72mr7232037pjf.4.1707995861544; Thu, 15 Feb 2024 03:17:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707995861; cv=pass; d=google.com; s=arc-20160816; b=gEEjBYgOaW86Pe+QI1rH/gKR7krfcGZUHnPy68sxpLAk34vyi+xbk2uaofPLWuSUos qBt5gdeAiPlZup3TXrBTKUd8OgdToHoqFJWlG300mO+Ja3l/XUHXBNKknn+cTW5L1Y6G prVdhIs70imbshirEFxbkhcLvpdsaOmK8HbtpSoERt/FVFWjuhGKQ4AMz7HRdCeoZZUT v8vvFmD3klUq2fmbJu41g3ZXlXmigAhq10SLGdWRGTzwNs/rjXalVroOrUF27yKeSCjP /pGedKr0usyKhx8INUnh/1p/Bj74hiD/2gPvpSHlYqRsMapre5k0ThVumvVZuZwOiQvg cgZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=AKllLFpkdBdD4+23+umGEBd3K5r9BpGIsgRkHDi52Cw=; fh=Heagowc1O8zVDXTyU76nJjOwDjz9r3Gi+0zmhF4ZELQ=; b=m9lwhzVrGmKLOoKzmIgrp/jRXeERDHxg8evFAln4b8ErND3PAnVub3HYsCYLiU0jIM YcOTbtxqm1y2UwGegHMhFMy7NGn0mAHyWDrSkp+7FTM2yQjiRzMSg6QLrUdAqRLBdlPF ePbESe5T5OyliTbJXPWbqYAaw58hadkpQOdFMR7UzJthQlWpkgzvvRoWJ/GUtgn2TwKN TtxHK8EISBADCqC6D2uDzJXhuO5VqX+NAZIYacGy4ndNEIcf8sCyjnkizJQm/L9SlrML tF+Npc5IUHlHLJ4o9DNGM+edd8fK29zVQRGZxUo69vFwXu/8536qGudPgABw07fSTYc2 iIyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-66638-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66638-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o8-20020a17090aac0800b00296f14f50b8si2891130pjq.50.2024.02.15.03.17.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 03:17:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66638-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-66638-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66638-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0D6C6B31746 for ; Thu, 15 Feb 2024 10:34:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A10B12BF29; Thu, 15 Feb 2024 10:32:34 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 71C0F12AAD7 for ; Thu, 15 Feb 2024 10:32:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707993152; cv=none; b=P1kDGAlHTh8gAGGpwJt/seqShl2H7Q76bHqMe323OGEndj5dk1dZy8JJl2ptTBFoJVYo/iEXnlWQPC9DLyfE9fO8jU4J6OV7FOZn4dcdyGXj7zw1l4lHWZqL9JIvqouahe8C5E2gm5cORkHz+IJRxcjqLMzWO+A/4nr3EMIhvnA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707993152; c=relaxed/simple; bh=f9J310tQ1bNpyfSQ928lGyLybpb8KOoR/8xzLYJEgEk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TqCyAeHphWpLmoofEzi8E9V1mTmwwG545uZZpH1wEabXDB/FsaIpFsyAY1GUqpWKIU088UjSqKY1gz0GBucC1wkib/rXXhgQ2sn/sE4PVL9J7r6qVQ+9g8jWlP/Jg+lm8gEmANIihaq242LtGsYsygrS3iWLlyuAmaiApZ9z4mM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 149FD14BF; Thu, 15 Feb 2024 02:33:11 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0B7CA3F7B4; Thu, 15 Feb 2024 02:32:26 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 03/18] mm: Introduce pte_advance_pfn() and use for pte_next_pfn() Date: Thu, 15 Feb 2024 10:31:50 +0000 Message-Id: <20240215103205.2607016-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240215103205.2607016-1-ryan.roberts@arm.com> References: <20240215103205.2607016-1-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790962106240322004 X-GMAIL-MSGID: 1790963468492282768 The goal is to be able to advance a PTE by an arbitrary number of PFNs. So introduce a new API that takes a nr param. Define the default implementation here and allow for architectures to override. pte_next_pfn() becomes a wrapper around pte_advance_pfn(). Follow up commits will convert each overriding architecture's pte_next_pfn() to pte_advance_pfn(). Signed-off-by: Ryan Roberts --- include/linux/pgtable.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 231370e1b80f..b7ac8358f2aa 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -212,14 +212,17 @@ static inline int pmd_dirty(pmd_t pmd) #define arch_flush_lazy_mmu_mode() do {} while (0) #endif - #ifndef pte_next_pfn -static inline pte_t pte_next_pfn(pte_t pte) +#ifndef pte_advance_pfn +static inline pte_t pte_advance_pfn(pte_t pte, unsigned long nr) { - return __pte(pte_val(pte) + (1UL << PFN_PTE_SHIFT)); + return __pte(pte_val(pte) + (nr << PFN_PTE_SHIFT)); } #endif +#define pte_next_pfn(pte) pte_advance_pfn(pte, 1) +#endif + #ifndef set_ptes /** * set_ptes - Map consecutive pages to a contiguous range of addresses.