Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp370423rdb; Thu, 15 Feb 2024 02:48:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXC5QEQGqMduRDdfFLy4GOz6a88ESPpHvg/iOFbITMEEm90rzLArK/+gHwxk6AkiKgah1mHv4F86F2WQjBBLQArHN/KGrt2d/9pFnYwSQ== X-Google-Smtp-Source: AGHT+IHkigagvJy2EwojUtwC/qJUVROd6d12cTPED5QCS6KSt2JwMEWFhLFd2q5fO25Rnw7wH75Y X-Received: by 2002:a05:6a20:9592:b0:19e:5e0c:3bb8 with SMTP id iu18-20020a056a20959200b0019e5e0c3bb8mr2220639pzb.7.1707994082575; Thu, 15 Feb 2024 02:48:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707994082; cv=pass; d=google.com; s=arc-20160816; b=gUGMkGJz9wAQicrnyWdbZyaQNhbm8MghK2/Fp7b5rn/kBpvNDomLNsRKKXSGZHNn5/ MLtgUH/phbkjlpAbqKcy/lTwGRjvhQVcGy3c7awyXY8GZfCfkD7Ft8VLaXATrFVPWf3w StNDwqp2Z/yR2TpYIwZzI86fD9OJMj+V1vdTPviY6iJfl+6yUozep93OSiuc0B24DmDi k0pOS6e4sXkrBXig26z6rNwUvsaGwuFnDiJ0y67TbflypE5jwYw1PkU+47LKdLFoYuAh QVuKUVBATzw8uOz00hpm6dX2Rj8k88FVRIHxu+uqDHzf0/oGdD5ZyEb5zDxFmUEf6N1g mFxw== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66638-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r5-20020aa79ec5000000b006e10e47ad08si932125pfq.355.2024.02.15.02.48.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 02:48:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66638-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66638-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 86D22282779 for ; Thu, 15 Feb 2024 10:34:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5870B12B17F; Thu, 15 Feb 2024 10:32:33 +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 Content-Transfer-Encoding: 8bit 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. -- 2.25.1