From patchwork Mon Jan 29 12:46:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535515 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 9F810C47422 for ; Mon, 29 Jan 2024 12:47:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 371F66B008A; Mon, 29 Jan 2024 07:47:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3225F6B008C; Mon, 29 Jan 2024 07:47:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EB7C6B0092; Mon, 29 Jan 2024 07:47:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0AFD56B008A for ; Mon, 29 Jan 2024 07:47:10 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 913AB80A41 for ; Mon, 29 Jan 2024 12:47:09 +0000 (UTC) X-FDA: 81732323778.15.82CCABB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id D3D91140004 for ; Mon, 29 Jan 2024 12:47:07 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X9eZ37T6; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532427; a=rsa-sha256; cv=none; b=cf8f8g+ghOU+SuDiLtscEkEY66v9kEtmfNk7eAuvidBGk5i2LFRyOxLhw7hYE3MIMsR51l 0kZqPwKpdFGE8OMuM0qhkLKaPpzF+cDdk7OrFCkZ8nMqLm9w+CRdEbz79gVX70ZPJYdxWq z3jkchNXNcaHfa17EfHYuPTGwNNuV7I= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X9eZ37T6; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532427; 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=3xazwhF5EUmMqWzaAq7c+f2E0xGFlCS1HyOOY3hDGx8=; b=IPcjPBuZLti3YBtrsajE1GENDtxlVMUYSTcensIZ6pfsOIhys9Ri6pBBxIvTRsv9uqxCkl Fx0TOuCTQvcMscVWuhZdMLdS9j7DfXuWmGE7C4wE7y56AocHewH24Q6YtHoBIJn6pN2Hju 2gfxGjKuu4K4A44tiyeZICbnU+14B40= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532427; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3xazwhF5EUmMqWzaAq7c+f2E0xGFlCS1HyOOY3hDGx8=; b=X9eZ37T6ZptrpLNqE8WpWFciKnIJazgtIcQ6ImCl1h2HUSzHWdTg8xSu8NxrDCWvl+i+i6 FLyGS4FkwjddEEaY0yf3WRXU2WsmszwvwrVICyJFU0lf7UfEnYPbBjzWkmf/UxIgpiyYuO 5YcVAux6aPpdxsKwhaXDIzfExVAbaNQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-583-MiBqcbXQPtSpFj1e-vh6bg-1; Mon, 29 Jan 2024 07:47:03 -0500 X-MC-Unique: MiBqcbXQPtSpFj1e-vh6bg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AFCBF867943; Mon, 29 Jan 2024 12:47:02 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 118438B; Mon, 29 Jan 2024 12:46:56 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 01/15] arm64/mm: Make set_ptes() robust when OAs cross 48-bit boundary Date: Mon, 29 Jan 2024 13:46:35 +0100 Message-ID: <20240129124649.189745-2-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D3D91140004 X-Stat-Signature: ex555j1a9gg1e4hkkh773c79pg3b54an X-HE-Tag: 1706532427-447820 X-HE-Meta: U2FsdGVkX18lWwl80JIEZz0ucZ15XqEGUXFyvGfVaRfLaXE1kAz2/W3NyowwjgddJKoA6Q2KaYdp75QGVoIHdKVXjDLGSj2GOuHuQPcAPra+S9NAcW4kEymJNCTYqqU7pPT9gjYMmptFzpd9394hMdQmUwsALbxu+OIJMTf2fSweBLofh21kXuadX+Hly9S8GLrBF7u262RDshD0h3uTPyJ+jqcow/M61v18am3FARDM0/XAOutfjzslnaGz5SKN6Ujyf3PPKn/mlPmKrkYqar2KN4cG+5JHxWfZL+wo4ZkCTpK9PsTieK8FGLpU6mshFj8GKHDhN7ygi9aMbNEqKaU7IB4mfcqDe5L5Gj10cbGRY9g5+zlLS754qicR7apT/qHLTt9QlblJHgC3lakPSaN5lHySH4D9GR+175Qg1TfiIyuFB46OSdq2xBm6UJa/eqzRBNiUAgcdSeXq1XbmrpIO+NB7N2BJgEPfMjrya9CCuWdEuGBBhP8ZAU9ysaeP2dHB/FMt52ENyIEZV47vTrUEA3ESHOP2haHCYuonOhoou1SCZZAFL7qW/rGx9G0QC+ebi5EK4agm3Pv+KdH5ofAP/OqZkOyOhM/EoHRZK4HziVUdP4AhWhvduUl2NNqhCxlCIr68iML+lQhjpOk5dsW69/mggDGsC7sfos4f02jvk7CngyQH3nz9YCT3/FbqERtJma3PcTTGwqmvFVmiaqQGL7mQo4XFBF01rce5I7HXlt5g9/SHXOrmv5VVCzX9slBmLiuRXbrYxNrUKNn+uw1+N6GqdLlUJxVAIAu+4+w3zOPsQ347pW5z/WDiMOoLDdDgFpXpbQEmH3V8gJInC0Z8HEbX3yuV2SVH8o+GVcSCovyXGnBxyATO3wKTYR3XGArYB1/Rutq7LQXyGkWKuk4F2vNuluCp1xoFRZ2wi0sxMlLNSqiO8aa6+nSd7R7i4o0+J4FnQLICQWGJ0n2 z6sQXUgT 6ZzfvIningcBi6s75OCVzWDW69VjGbhrxbT7ox+tg4EcoiPsu2pTGkllYdqT3jX8t8COYje57B00ZV7kA90HOA4REsFg9Y7ry0Mg31M13bqpGD3TiGbR9Ykra2dzoIR+2BV/EnPymgBrSf9HcOTPb/WUXcqO0Hf+yu3af/j8GpyhIqSpgrJX8lDuk5TP5nVKY7Pbenn/4xXVXM6BUD4De/TvwtULU90kJ+NF1AiuUBT6D7EaEaJOQ40U5Ulzu1uCJKkCxhY72qpFqYvahUwJQcGxYuHj0zgv710WhgF4+l0mvQSkkpxczX15sKgIDZK1B4CsAapWpEO5C1cYfRG06qmkYIA== 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: List-Subscribe: List-Unsubscribe: From: Ryan Roberts Since the high bits [51:48] of an OA are not stored contiguously in the PTE, there is a theoretical bug in set_ptes(), which just adds PAGE_SIZE to the pte to get the pte with the next pfn. This works until the pfn crosses the 48-bit boundary, at which point we overflow into the upper attributes. Of course one could argue (and Matthew Wilcox has :) that we will never see a folio cross this boundary because we only allow naturally aligned power-of-2 allocation, so this would require a half-petabyte folio. So its only a theoretical bug. But its better that the code is robust regardless. I've implemented pte_next_pfn() as part of the fix, which is an opt-in core-mm interface. So that is now available to the core-mm, which will be needed shortly to support forthcoming fork()-batching optimizations. Link: https://lkml.kernel.org/r/20240125173534.1659317-1-ryan.roberts@arm.com Fixes: 4a169d61c2ed ("arm64: implement the new page table range API") Closes: https://lore.kernel.org/linux-mm/fdaeb9a5-d890-499a-92c8-d171df43ad01@arm.com/ Signed-off-by: Ryan Roberts Reviewed-by: Catalin Marinas Reviewed-by: David Hildenbrand Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- arch/arm64/include/asm/pgtable.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index b50270107e2f..9428801c1040 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -341,6 +341,22 @@ static inline void __sync_cache_and_tags(pte_t pte, unsigned int nr_pages) mte_sync_tags(pte, nr_pages); } +/* + * Select all bits except the pfn + */ +static inline pgprot_t pte_pgprot(pte_t pte) +{ + unsigned long pfn = pte_pfn(pte); + + return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte)); +} + +#define pte_next_pfn pte_next_pfn +static inline pte_t pte_next_pfn(pte_t pte) +{ + return pfn_pte(pte_pfn(pte) + 1, pte_pgprot(pte)); +} + static inline void set_ptes(struct mm_struct *mm, unsigned long __always_unused addr, pte_t *ptep, pte_t pte, unsigned int nr) @@ -354,7 +370,7 @@ static inline void set_ptes(struct mm_struct *mm, if (--nr == 0) break; ptep++; - pte_val(pte) += PAGE_SIZE; + pte = pte_next_pfn(pte); } } #define set_ptes set_ptes @@ -433,16 +449,6 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) return clear_pte_bit(pte, __pgprot(PTE_SWP_EXCLUSIVE)); } -/* - * Select all bits except the pfn - */ -static inline pgprot_t pte_pgprot(pte_t pte) -{ - unsigned long pfn = pte_pfn(pte); - - return __pgprot(pte_val(pfn_pte(pfn, __pgprot(0))) ^ pte_val(pte)); -} - #ifdef CONFIG_NUMA_BALANCING /* * See the comment in include/linux/pgtable.h From patchwork Mon Jan 29 12:46:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535516 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 D9640C47DDB for ; Mon, 29 Jan 2024 12:47:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 597166B0092; Mon, 29 Jan 2024 07:47:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 51E976B0093; Mon, 29 Jan 2024 07:47:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 398926B0095; Mon, 29 Jan 2024 07:47:16 -0500 (EST) 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 281936B0092 for ; Mon, 29 Jan 2024 07:47:16 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F1B2212010C for ; Mon, 29 Jan 2024 12:47:15 +0000 (UTC) X-FDA: 81732324030.10.7CF1B3E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 5CF1618001C for ; Mon, 29 Jan 2024 12:47:14 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QntP4EtW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532434; 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=dZBuztrATUgWrwPaWrq4xl5RtiXYg83ssHnQD4Nso+0=; b=2PKZRDXR/fvY+0SZJ/vDrKRNTzKn+PW8AoBWsoO1Bzu9cDg2I3YevUgFkh8LPRKO8hmf5G GrbeLPdA4U2XiCFD7AZe1jMA5IfdNqOgIUlGsdMmuxZf1WC8ZctNJZyijuk9kHfRJUXTRh ymWdH4fvKqF6g0VcenvRASJO8LwdWsY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QntP4EtW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532434; a=rsa-sha256; cv=none; b=s4RDXFT/8EnsCBAUixD7enr5yYyTYdqxSK+EQCpkHJSv2z7kJ1XqGpCKm3eGFw/iGKEF79 L/wN3bqzrEmrP3fPGVmUjTDK/nAWbhNJoEyCWYUef6oHw2ZpnMAS4fbnKVS1DJwf3GZBQ3 maVa0N1taCUKssO1Zk+Ehuvfex89mNs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532433; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dZBuztrATUgWrwPaWrq4xl5RtiXYg83ssHnQD4Nso+0=; b=QntP4EtW51BYS+iiMun9hx+iE4+fCp+swcMqpbe7PxmcZasC02MkCoozks4XscqHA+WQSt mqUo04VixYCeCHXHpPwgrsDf287lFlQFPBMuCyk42X44Up74sLhHcoE6/pUWTGgoKXD+yV ae+Qyke0f9BXYa+jDf6fe7T+PYO/Ry4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-iEa3Fx0fMcCsFoiq-is6nw-1; Mon, 29 Jan 2024 07:47:10 -0500 X-MC-Unique: iEa3Fx0fMcCsFoiq-is6nw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D2C1F185A783; Mon, 29 Jan 2024 12:47:08 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B5E5107BD; Mon, 29 Jan 2024 12:47:02 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 02/15] arm/pgtable: define PFN_PTE_SHIFT Date: Mon, 29 Jan 2024 13:46:36 +0100 Message-ID: <20240129124649.189745-3-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: 5CF1618001C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: huqoqzxo9izo7qrqdg4bdnd6gupfbwmz X-HE-Tag: 1706532434-692196 X-HE-Meta: U2FsdGVkX19AZxAmbEX4b0LAeIOzdzxjTBOOuqteXxVHo5tQ+LRm+qWViiDGJkLL/IGALBR3H8G5yrXUEk6XdwqQCtWD6Tul55mPRwmV7i2QTrIxhPymkiwwO1SvzDs268h645Q3tkbFo+bxlLJ5ywJLjQDvlbPdHpVwaBrBv9eU0JQx/O9e0Ymog/qXjPBgNS+elKojkpYY43kH8oqmoB/pYNNq8ZEMr2HdtlHZoNSDD5pJuQn5DI+zWaKpyYGLGLpEnroNhVGGkWS/qO8BaV2Hgo64rGj1xt2H6hNoihg6lnEvwZquuK1vuvC9X7IMf6PqZ0UjGo9i6GOGaTdz15rF0zHae5oRuv3ynMGu0HLa2OAxVw4K3MgyJIjmoCDKyMY1WcrFuarEYxQyY3CXhvuHGPbCd2EOf7g7hWY9H/kCd+E2tuYfJMPHPPWvdE5K3i5C2Zu5ccdVpTNvi7tangs+u0Sa/oZIjbrslfQZUb21QOiAQXOp4xj6Bobz04XTiCkLyw3okuGja9a+cnGlqh/hNag3EqXj8+oyjoDGSUe3vXyMM06H+LW4tAutcRm49+t52wWUKwyYGaQusM5LekZ9ShwMJPA36Sm1Kix9QOzoum9ivlZpOUdYnC/x9eY/d6ZFgElfLh+YDhPrPyBkKncd78UUIVAFm7yjFWt3QqgZ8eRKF5RypWkzEwJo8C2h+DtEln8otUWIXdbdMG0bJH2EybkTecSfboENY5neFlMteZIEU0QlOtd4rz+DmYQnwVHLMQJGkNm104xzbInjKZ2KGIX24b+8RrdYgCTJdI94M5mAYPyX9b8ucY05rmW4Tb963oWBrSpTwo+V7Xq/gMp09SbI0l7r5mfL4LmHQ0JwlIgInfx+QnkqIa7roaK9stvxmIkWr8YpdYUsHHJc7ZlNBlzhW/Q9DmwKnnS0Crj5M+K5wq2WRW9MtxRED/zI 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: List-Subscribe: List-Unsubscribe: We want to make use of pte_next_pfn() outside of set_ptes(). Let's simply define PFN_PTE_SHIFT, required by pte_next_pfn(). Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- arch/arm/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index d657b84b6bf7..be91e376df79 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -209,6 +209,8 @@ static inline void __sync_icache_dcache(pte_t pteval) extern void __sync_icache_dcache(pte_t pteval); #endif +#define PFN_PTE_SHIFT PAGE_SHIFT + void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval, unsigned int nr); #define set_ptes set_ptes From patchwork Mon Jan 29 12:46:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535517 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 DAB8AC47DDB for ; Mon, 29 Jan 2024 12:47:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A78B6B0095; Mon, 29 Jan 2024 07:47:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 658466B0096; Mon, 29 Jan 2024 07:47:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F8296B0098; Mon, 29 Jan 2024 07:47:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3C9606B0095 for ; Mon, 29 Jan 2024 07:47:25 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0872E16058C for ; Mon, 29 Jan 2024 12:47:25 +0000 (UTC) X-FDA: 81732324450.17.64B8AEB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 53097C001D for ; Mon, 29 Jan 2024 12:47:23 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jOEmZSyk; spf=pass (imf10.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532443; a=rsa-sha256; cv=none; b=EzQDgIAyArc4kiTT5jgbdTSphYkYCnP4Iz8TTqS10sxKIOPxvZ+Utq2L1VWzEHzoNZXjrP HRYPVVSY7cDqc8EOuYnp+2fvz5Wdcp7w2fczHRCYvqbLqfMMD5dsJ92+1BntZsxw2ZRjNp dOOL9m13iiJYEFYL45Bk3c8iyt22q0E= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jOEmZSyk; spf=pass (imf10.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532443; 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=1kG4t4M9Qk6cle/o9WwWAIalbkRSmv8fU7P3A1XWjZk=; b=ynnn4vyBYyH+CSxrJxrjiFheSjfYDCGCltX1SiXl7znjJDuFuJEUM3BOOzq+KU6O54m/rI XW12ye+FVtkZLGw/60K7yc7VSsjpeP4tL3GEI+iZgfGUzRa4mEqqAQ9xG6DLVislUofKg1 ze2+Oi9ChygB6t/s0eQ87tHWKLatOA4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1kG4t4M9Qk6cle/o9WwWAIalbkRSmv8fU7P3A1XWjZk=; b=jOEmZSyky1LTA3ERxqzyct9P+Co7O+CCRTLBKeVKtY6irhgRHjgCufCUxT2iK6tMSPzaUf vVgLS5zFs3vGDrf++L9YKq4oWAd7c9kEuyVZtXIlvWNYAFWlmTkBMjWpoWabcDb5ViDMAl i/kFJeSYbjopvR461bsxBugcHNiOYSQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-669-B9qoHUmjOAyZ8jvL8Xcr8w-1; Mon, 29 Jan 2024 07:47:16 -0500 X-MC-Unique: B9qoHUmjOAyZ8jvL8Xcr8w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33D0A3CBD51E; Mon, 29 Jan 2024 12:47:15 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EC37111E6; Mon, 29 Jan 2024 12:47:09 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 03/15] nios2/pgtable: define PFN_PTE_SHIFT Date: Mon, 29 Jan 2024 13:46:37 +0100 Message-ID: <20240129124649.189745-4-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 53097C001D X-Stat-Signature: 6x3id7oq3s4w77iqp5uafj3kzouu4ewp X-Rspam-User: X-HE-Tag: 1706532443-692683 X-HE-Meta: U2FsdGVkX1/hq0Eie9TbiJzEqlfpUkIcS+ChhospPcL180AjBmKHJl3fs1SdfgpZjzZDUiTzihqirA5QhU0ONeVVmfdGjBKrpUhDE6nCyKZhLzagxIXhiEHDIu3IRv1zvhTrWnIHKqpeVkgezVUaStdG850ZXgrqXpggBnhSERpm4hsL9taynskmrnxj8v1PRgkEQIdlnqmujQMAVmgczYBAAbFSrD8sby52RU4YEgE3ILDT+lOquHfoLIBHchNqo5qLBFc8n7kO/uL6NZ4UOuKYk9wDDwrGpnUHOOhs2qvQ0a+G0hLeE6kfJytipcSQCGz8AWg+RO1hwOtTVRUjgIsDBD7S4pHvBnaFYrkJH1VRob+ga3y299Ta0M47sAOr+GXE4Q2OnzqJyLpnpeKzrDOz6RB+SwTHeZm3HcIjYVvM3iK3+5jAMPiSUdMZmrzxEWhDv0NFLKQW29JOG2OqO1+Xv8OnwzrjFCk8UVgvKMzrIP8QCAH9VRgyYiUqncHXutzNS0DhE6psfimBatHFueO4f21ODFObFEhnN5W+bHMKC8Qzs+NCfy+1pKm8a+pSOLRyvHCFJnoAvG7TadkhSacN1cyoXDh2Rbk6+hrPZmV/tpl2CV8kv+d97/xCBvLqws3xbNgcFlgTY83bWGTtJ35IEOt5lEXnQRqXuOb1L0YDxLGWSgVgVljrFZ3tTjDEJbQQ03PoEJHExOOIi4bpBe+0tdy1pqwaGJAMlPZbw9BKvuR2bsw/GvPL+AgWzP8psc+BB7HEEOUBTlYtCeDTbLo+0SHEfRuKVBbNqiBsAs5y1CN4h35mDLDR70njFrHmcYxfUP8muGDw3rb3MsYxSw8TnCp3zONt/YzuxonrgQ2GoOuVQbMS8l+6HQhT9Rk3i7Lq4vclG0WCLSNkkM9O88LGqIJ07mnu1oi3Izb4AkRvWPCtnuoTGYRS+Yo9dHPEFQ9Gxfyhz27ukjY8Zob 3IFUx6U8 vQEXOL2gttFPUXJXHdI26zQ74jAheN6elUIftEzMU26UTTFAMPsZn7x6d74yJ+ZDVChJgZQ309+dn2LCZjRvBgUc/J4VTgWlzwRgn0yGqpPfbMvZ5ySan/FVwSTh3ixzqifcX9nA+3+SADR5b5V+igJoqKvecVNdChU0ZKCToGaawR9uEavsMz1UrEUxpg/sWvVU4u4DoMnJ0LMQho7FEru7lo3oUL0y/We+i 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: List-Subscribe: List-Unsubscribe: We want to make use of pte_next_pfn() outside of set_ptes(). Let's simply define PFN_PTE_SHIFT, required by pte_next_pfn(). Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- arch/nios2/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/nios2/include/asm/pgtable.h b/arch/nios2/include/asm/pgtable.h index 5144506dfa69..d052dfcbe8d3 100644 --- a/arch/nios2/include/asm/pgtable.h +++ b/arch/nios2/include/asm/pgtable.h @@ -178,6 +178,8 @@ static inline void set_pte(pte_t *ptep, pte_t pteval) *ptep = pteval; } +#define PFN_PTE_SHIFT 0 + static inline void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte, unsigned int nr) { From patchwork Mon Jan 29 12:46:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535518 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 51A7EC47DA9 for ; Mon, 29 Jan 2024 12:47:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C9B806B0098; Mon, 29 Jan 2024 07:47:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C4C0E6B0099; Mon, 29 Jan 2024 07:47:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEC846B009A; Mon, 29 Jan 2024 07:47:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9DFCF6B0098 for ; Mon, 29 Jan 2024 07:47:30 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 45010A1878 for ; Mon, 29 Jan 2024 12:47:30 +0000 (UTC) X-FDA: 81732324660.03.15939E2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 91CD012001B for ; Mon, 29 Jan 2024 12:47:28 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="B/7MsjCe"; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532448; 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=L0fTElPXKbhRcKZPS8pXPd43BafZhSoj1KxvgrbHzPI=; b=Y4W4D7O3I3ecwrDc1d3U1ySfchEwF+1NvJfeLHGAiWY7ob8aVbCsQjoGFdWJEuWYSMatIy oIBo3b72NKB/lS5Zl+ezzLjwxl8XJ8bh4jgrFcYEB/klGRzguXsuJJJVkp1my9lQzp9UQo X7tEJmg/uac0zuS5KJZqjYYu03+wKzY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="B/7MsjCe"; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532448; a=rsa-sha256; cv=none; b=eGrxMtiHS47fXVK+TxhoP25cn5HQ08Z+XpFL6ippRbkhX6CrZl7R7hxu3uOtowZw86HPbF YULZpUvOkaCatRUL1fAloEBDKfrewuRx6HrK5HOFkpiD8vqqib86ZpyCdRNK8vi4sHgOSY N4RzjSq5TnOFMAFjwCeZ/3QQlZCZhqA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532448; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L0fTElPXKbhRcKZPS8pXPd43BafZhSoj1KxvgrbHzPI=; b=B/7MsjCensDAWyR4imcgMAg9gIs+ROjS5MOjNdf+aprzTrLkRgJjWE9l5i9cWv1UTXljq3 HDbwUrP9QE8xR8HZawDgCwzYRhqc31U9BObaB/tKaUqOrtSYhf5Vig0h9fK6AM0mMBmSa3 hk49rzYFPVjW+5N9OyZEVmS8PzFQaWs= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-176-gZS2zg1RPJqdlEPYFP4sAA-1; Mon, 29 Jan 2024 07:47:22 -0500 X-MC-Unique: gZS2zg1RPJqdlEPYFP4sAA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C24D3CBD50A; Mon, 29 Jan 2024 12:47:21 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 850D28B; Mon, 29 Jan 2024 12:47:15 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 04/15] powerpc/pgtable: define PFN_PTE_SHIFT Date: Mon, 29 Jan 2024 13:46:38 +0100 Message-ID: <20240129124649.189745-5-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: 91CD012001B X-Rspam-User: X-Stat-Signature: fwqonijb67yjws444doitwkdsn93zosd X-Rspamd-Server: rspam01 X-HE-Tag: 1706532448-357161 X-HE-Meta: U2FsdGVkX19Tskf8/5iDk6pcw8k2Zppl8Qq5RXyxpnO/jLGamNteTVbkP5Tvd2eOVYlYHkc8s1RtPP+a9wTm46GVDC/42LptfVdbW04yIU44FVxWLMv19bNafqz5yJGV9ycDIhuZfZdjdgJdQE1dvPvt16vc3IE/j+7u8KHqlupfnpXl+0HnShyxc9mC8UfbXftJCuhNwyBKdITY+b9XsVYypcHHeDT9HzjDZDezyi3TBKPFPh9VpJ1xga+wru2E0RVOBN1Qq3NjckDdaUv25xD9zEWX6RK2KKbby8nPpGRy5LAbKybKQkKuUQSGaI+OU9faRQjGFyu0PhcmzhSG6Gexe2pwoNV3G8AZzIyhGTD4KOQ2KykOvtGsR7xLiNYeTJr0fFp/ihgdMTG+tG6Nz0DKUEPhWJhZYwAJL4Nl8DS9GBbptseBNFAMaHcTtIGJhCkwtUEHov5eVO6+rxTkih6As8u71oBpH9R+gqa+4Ym6ugoK/1dtHKIK1BpvHO104sQH8HXzjZlaGROebRXC5UDFU9jc6UOrj7ibdPjg926smFzvLgDPtn+Qn61jKPZCN5BmxB3kVNkWObdQJnrFx3P/4ZYO1zKXZhHAXKxw8xr6O6pkicEoQbZ4jhNf0mveOnZMEOwHxX4gQvCCtgGa09IRy0IQWtOdkhmyssjDkVWpfbLaYnkMzG6BIgIkkqa5TeNINXu/UKEqQANNC/9cN00iYc3EKBcHPpKKAK9+w+xNnwwLU6DnZUSp3sejWNhOiGUb8C1JT2T8iiRPOkG/K40ZJ0BJYSwd4+CbEUKi3VpI+k0Ut5n3lV2VX+Z7YQzGrm0flSgtFaSRFvbrdSsOnsXhSwjHgiJKgITU1JLqjicveue7ZodFaxGmqEYraKhMe1YbojUPOjIqFKw6X6hy7LFHOa5LeCK2Uxtk9NuU0tdNrjaTxfiEl3g8brEyJSwV5Ox3bCyiMorBpvkksse QPr3GgVa APP5tTeynmThIq30Balc2xrS5X25i2Qv1lycLzvl7v2tXwgNhYH+0muCGSqyV436cc5nhEjkBlJAAhp7XlLXelE0ivB13JuC4bDy19q4y1MsH+1uUhmUYJNNgongIKQlkke9YMndkIz8kkTkQSMdvvbG3aLwgRI6VHWhTLdsztPc33FgTUTEvxw/cDUP/Udz4TSeH5IaU6SwLL7H31k9i+Do/dWlPQcUCLHHa1BnsSdMtWM3lSTv6RVBy25hrv72zhrpbGJDElPmJjI68/gECsvUwGQ== 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: List-Subscribe: List-Unsubscribe: We want to make use of pte_next_pfn() outside of set_ptes(). Let's simply define PFN_PTE_SHIFT, required by pte_next_pfn(). Reviewed-by: Christophe Leroy Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- arch/powerpc/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 9224f23065ff..7a1ba8889aea 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -41,6 +41,8 @@ struct mm_struct; #ifndef __ASSEMBLY__ +#define PFN_PTE_SHIFT PTE_RPN_SHIFT + void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte, unsigned int nr); #define set_ptes set_ptes From patchwork Mon Jan 29 12:46:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535519 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 C8157C47DA9 for ; Mon, 29 Jan 2024 12:47:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 597206B009A; Mon, 29 Jan 2024 07:47:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 544F56B009B; Mon, 29 Jan 2024 07:47:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 413216B009C; Mon, 29 Jan 2024 07:47:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2C5906B009A for ; Mon, 29 Jan 2024 07:47:33 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0E131409C8 for ; Mon, 29 Jan 2024 12:47:33 +0000 (UTC) X-FDA: 81732324786.06.9F8DA13 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 4492DC0015 for ; Mon, 29 Jan 2024 12:47:31 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZKpuNvsc; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532451; 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=TR23YVq6t+vxDxzPS6q2xEOscQxVIS4+3klgCmYFiGs=; b=qTJ7WA82/IrPtwskHmZsfWpLZZ672z1Ea/+3Knbx7HQlNjW8XwQnsVR347r6q3dMremFvn 0i6yUmtlCIM1FG+5QY2SB08Lpzj74n+S7SygYz+bzMHn5P+rAx7KAvJgx6UAjYRm8yI/ys QlAeLowti9tn8tyBzzV5KyB1VPTKB/A= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZKpuNvsc; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532451; a=rsa-sha256; cv=none; b=waAOO3ilMEW+pNCMY9b7/LSqkoGhnmYGcja+VGrnBwBXSr/FWE9256QNbUCPVXUlEOXHE5 Shk+oB1k1FFaiTkEq7hwig8kG3lu2z8gxF82XG7h817VDa/O9+Mlfr7PQjoHUhcGu4ZWQU 6LSgr1hEqPtb9mqbGB7c+73otWzA7JI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TR23YVq6t+vxDxzPS6q2xEOscQxVIS4+3klgCmYFiGs=; b=ZKpuNvscCmsVgMzIojyBiOb+7GwvB14O3cScK0bVz+xJgi4OeahsAqazWHCPX6+Wp9Szxo uZ8VIe/9B+H8Ou0pp9oqrQX9c7Xzj9Www7iBnT0OnyHfSAhMAefojU/8kLO1uRC6xNPmw8 LLQ8RpkA0LZBK/l15jYmMxBEcZNZNXQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-317-aMm9C5FkN5Gfoo5yJn1Edw-1; Mon, 29 Jan 2024 07:47:28 -0500 X-MC-Unique: aMm9C5FkN5Gfoo5yJn1Edw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB8C329AC02A; Mon, 29 Jan 2024 12:47:26 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D62B107BD; Mon, 29 Jan 2024 12:47:21 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, Alexandre Ghiti Subject: [PATCH v3 05/15] riscv/pgtable: define PFN_PTE_SHIFT Date: Mon, 29 Jan 2024 13:46:39 +0100 Message-ID: <20240129124649.189745-6-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: 4492DC0015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: iziogiux4ypg7apx8d7ajhw1jw5xkw6g X-HE-Tag: 1706532451-919643 X-HE-Meta: U2FsdGVkX1+LJvFn128Q9FHjal38J1Pc8lVvw0I+NF+O7kPjuvz/fS9jYDE4Zgbu1hcPM+6kew/kzvLn8PzNo0eFQKncltQxeUamMsZDAjr1+r/DqHXZ25YFxpgKHD1HNZlqDkJj07eM+4NgHLQWn/3sg3krPmau9FjpSyi3mMSVEWeMY3XX8dbk2LJMFcRTZ1FrEjydb/Ej/+ECSbL9r89DAnIccWqsNEULaRauAOoPjJvJNI7nHt/r7q28FvymOUTG387xM/nw6HLlbDKY6TlxAAfrDhj6sqjjiX2OUH8q7aa041JXfpHXk+CJ46ToI1L1+6dkppD2xj92ZhEFQyQjWrOAxdMV2hyZO6qkAlR7uPAKbGB7W0UU9s2WnmeADH1TBdpOTuwRM0kqDKFbhajNBGC2F8aT8GTK6eLngopCTg48lttrrtwydkAcVamVeUcF88ALFhpT7MmnqbEV/Gh3oajHfWr5QpYVr/reSdRJfO7ftYA7wY+1WlVwHOUfZY49Z9gBQqX2c9gHQwSIUsFCdw/w2UtBVxJeFA0Tfgar8erYxyYRVVKtTaSUN2VTONlJkq0HKkHrzjdce6JpUkkNtqFTw1o4FzL80wQGnkI7JELRUJZUQrjws19+GChnsO7dL+RqvHc3pfq4z+RjWVKIMg2SSYkGWjIYUEAk7T1lHwWcCBmVWDS7G4lxLwHqk1u+rPBjLXbD8bWcaUD10/ECGZ5ulm1Vg1JG852tsDHQY95XdGZVsmNFbdyP/ItBIkHoNi2Fxwf7ToEBJW82zpilyNqoNy33B/TzHMAjxuY/Vbro3fZyAEqkI9KwZZs2xBsep23K/kxD/QNh3T518fZRcFbsY7e6VHzHyNNkOyKzSncck08sKZ4qClq4JnRj9WhEVON4OGLZAYRGRLY9+LaVuGDFYhmOJ+Wz8ddJ5SdRGuQlUr14eAdt3uga+TJGH7IU4eHHPU3dNGB0QsT IeAABsOx 9WP5nbWmrH4V9uzmcnqhxfSbgo45DwqRPsrSftT+VYf+2LhwJAJNHqQcAd6e5EypIPjroAvE3hzYfYsPD1VMRFhOefQjY6m5nMsbcVeP3azGds/TXaA+gEE8iryuZYY2MKJM2sOo3U3tQCt2mdzQbrCVbIOlhAjacX3D++0aomlU0ENE6J7TuebOyxFVNLBX9XUgUz121Bu6MaPTbJCKtsbJj6Gbvf6YT1+gfrFGfTSJNHOcGHMBG/n1fhzGTl6SkVuVReiecuNmU9gw2Tg/TSdMAvg== 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: List-Subscribe: List-Unsubscribe: We want to make use of pte_next_pfn() outside of set_ptes(). Let's simply define PFN_PTE_SHIFT, required by pte_next_pfn(). Reviewed-by: Alexandre Ghiti Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- arch/riscv/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 0c94260b5d0c..add5cd30ab34 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -523,6 +523,8 @@ static inline void __set_pte_at(pte_t *ptep, pte_t pteval) set_pte(ptep, pteval); } +#define PFN_PTE_SHIFT _PAGE_PFN_SHIFT + static inline void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval, unsigned int nr) { From patchwork Mon Jan 29 12:46:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535520 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 A48F1C47422 for ; Mon, 29 Jan 2024 12:47:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 129756B0072; Mon, 29 Jan 2024 07:47:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D9CD6B009C; Mon, 29 Jan 2024 07:47:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E96806B009D; Mon, 29 Jan 2024 07:47:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CEB8E6B0072 for ; Mon, 29 Jan 2024 07:47:41 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id ACD5EA09BC for ; Mon, 29 Jan 2024 12:47:41 +0000 (UTC) X-FDA: 81732325122.27.1E9F656 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id DC45840007 for ; Mon, 29 Jan 2024 12:47:39 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X2FXTD8H; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532459; 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=Q4tnrwU9nMLq/XRgt5SnLvg5SSqAxaQfTq+KC4Tr5Rw=; b=ql1zQPvZMg98f7EErNMBjC1V2Z0j7ZIwEi7cqo0ZhxG7wUFSrInfHrbdD41crb2W445wxM dHSUdXtVEN8/IonMJjdJ4NqSJeRvnDoJlFML0HWvv1iYIyQ6ivtAmtZtfStD7Jqpv1lRzH kRCH084AGfZ6cYOf7nWr7YY6UI+vCA0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532459; a=rsa-sha256; cv=none; b=jKE1m9Er+P7FawWmPmL/oBE2ILGe47U46vOe9T7Ol0/VpR3PHFxyjENLurwcCA7LsfeF/b tH7170CnSncBhe1gHXQ31RScJ762DB/Bd9P+9zZIK91nMBgXSTni+D1piqoTAhypnCNUif Ifkm7mdtKgMufTWIiEarZzsDq+4zdd0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X2FXTD8H; spf=pass (imf17.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q4tnrwU9nMLq/XRgt5SnLvg5SSqAxaQfTq+KC4Tr5Rw=; b=X2FXTD8HH8ZKMDuJMuKdltbyqq5OVKXZUreB3T2nXH7etdyio6V2FaOebSW9qf2bTeQP1V /9De/JpuUYnVdwkbzDMLOjEz8EJqMul1qep1xYz7U2uFd+xOQ6PGRTZF0I95huOX59RmCV 0IUuSClYlH1xvaYbMtw2Fx+S9DzddP4= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-0qzEMwiFPS-I-NbcZuBhSg-1; Mon, 29 Jan 2024 07:47:34 -0500 X-MC-Unique: 0qzEMwiFPS-I-NbcZuBhSg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 208913814E8C; Mon, 29 Jan 2024 12:47:33 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C9928B; Mon, 29 Jan 2024 12:47:26 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 06/15] s390/pgtable: define PFN_PTE_SHIFT Date: Mon, 29 Jan 2024 13:46:40 +0100 Message-ID: <20240129124649.189745-7-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: DC45840007 X-Rspam-User: X-Stat-Signature: 6enougn9sewym74tnjaofh4yo9imu5qk X-Rspamd-Server: rspam03 X-HE-Tag: 1706532459-523989 X-HE-Meta: U2FsdGVkX19BBzkCB8GKlOP3AVaBe087rSqRlRRJTNcoHwwHlDOnCFGOep2Ohp+jyqavAsIDpccJPUkZYW0p6eqiq9nsnuib+oL6xqdeotPZbMk041tDseyFWcghJWSwb6VDlMZBmMefODK321QBFoSM16/1VQm0KAIGOG32UaLUbT5CTokK1av+IYUdqpDf+Uhwo2lf2dk/FAnRhiHBIfHADz5jNnd4WmyyuHphkAVWtrnf3oyJABo2o3Wbcci8S957SQXJn6eIyGhoJ3HDa/0MQUYWSHkahqzFpzOg1Qh2gfe0euSjkMBrDEHFUOXnj6YQKRbYK5NW4odmJlgESXCcW6enArc3aXKhpnJ4GgWeScRevIF7U1T1fHa/INwYjXwj42jsCmZ6VE042gkmIllC632P37in2NhAvxPz2cAsvPjhn5mbCZ3KvlF29JpgrnW1WkstCrqjqQl9BXnZ3p0yNYaslApnLRSYoi/fh8ZqembLa8wuk4aI1rC8qVQeOEbOF8M7rBRH5HqcvITM0h+FzHQ57sGHD/j+BUqMk3qOB5bJrorgO+z+ntlAFay9GTeUaM9TKXxWc9Gh3tp4/6CcI1U6Pn2TmTM5oqpE9lv663F4cQlE0Z3WnB4xyM7pLduhU79/ygpmFyad94JjlwULAaEFZFXwl8VTmkA0KU6QvPIFro95lczyY7M7wLdQxsujeX9TRfegH/iPM3klHatFiuwEi4IF4c2SQwILyNe863cK9/LE7vEgeA3y//GiGJhrGU8LdLMF/Bq9lcLvz8BwBSGFIbaTBakw4iXzufWHnwzpl0M3q4uw7CKF5bXPfH4GqVcAlWB8ol+pEOkKf69C/t3xrJUvxEXxMsi+vKkWWH3fVIIpO29rR2DRNxSiiEFvDYyb+DGtIgT//M2USWVoFWVDK+45zTzkRmC+4Hg45C0X2EYpZafvVTjiRcKGvuf3Hw3HNHcVPi1QDPQ 7rjTRFdS VfiCUy1P/Nt2pKwVe5HMWcdk2MWRz5JE4+DQFAHWk8F0SwwzBU9qclp+aZhBQpGKFT73FiibYIKtcII/jK0nFOOkL8bEaBT/SYmpfLHMg5jVcQojPlP+q9Tw0AET/jr5SEQq/QHhT+lgdM92hRVIKKq0ZWKSD43h+EoHfi7GBTbsTikhK9i6/v2SbFv9/3HSn6DXWWf77ihSGS05A7c1SNwifmyfr7VNgzrR7 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: List-Subscribe: List-Unsubscribe: We want to make use of pte_next_pfn() outside of set_ptes(). Let's simply define PFN_PTE_SHIFT, required by pte_next_pfn(). Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- arch/s390/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 1299b56e43f6..4b91e65c85d9 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1316,6 +1316,8 @@ pgprot_t pgprot_writecombine(pgprot_t prot); #define pgprot_writethrough pgprot_writethrough pgprot_t pgprot_writethrough(pgprot_t prot); +#define PFN_PTE_SHIFT PAGE_SHIFT + /* * Set multiple PTEs to consecutive pages with a single call. All PTEs * are within the same folio, PMD and VMA. From patchwork Mon Jan 29 12:46:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535521 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 33355C4828A for ; Mon, 29 Jan 2024 12:47:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA0B76B009E; Mon, 29 Jan 2024 07:47:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A50956B009F; Mon, 29 Jan 2024 07:47:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C9576B00A0; Mon, 29 Jan 2024 07:47:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 79B1B6B009E for ; Mon, 29 Jan 2024 07:47:47 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4FC9CA09BC for ; Mon, 29 Jan 2024 12:47:47 +0000 (UTC) X-FDA: 81732325374.28.01ABD72 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id A22284000F for ; Mon, 29 Jan 2024 12:47:45 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D1zlh2nE; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532465; 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=8viUIwfAqrpZYGrKXKN1ylfsdDoFL9veEN2EDkxcPF4=; b=yOrjGjpGWCgyRaLG0VAZBiu6RNwuKbLTOSJC2fAZJlHqwDkcx0blrtEns0GGGbB39QuUXl VwxqJjHarErxjfBWDn7Ec42uYhlu4UUn12S+HfAkEaNfmOvUin6Vg0TMQxfjTNDBYdHVjy SA9QBIMLWEHF0EvRX74/egxSqjCwXvw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D1zlh2nE; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532465; a=rsa-sha256; cv=none; b=vblRnQSKoNJqnus1n3+dKAbAM6uZLPJhFnqNEx86+XdRadgzcEbi51UiqgjNOLXKNoaMJS 7EoJ67P4m31ddJbSQllbLe2GFhnL9iEH3hZv8HisBzR0EstW84C+ErLwZ6ES+eUqU2Or7T rFlkdDzAExFj476FRuB2EWpOKJQYRJs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8viUIwfAqrpZYGrKXKN1ylfsdDoFL9veEN2EDkxcPF4=; b=D1zlh2nEoXs7D3xjehNL0cpPtqu3sKuVnym5mzS/H9dFoDXRqjtlGeW6mS60VfyPJj9q2N 0oeehHft3wdNjAjYByDXa9iV6oSbDWu+KWlgSUM28RvrSG9oo88YsxQ/11EAvnXX3bbjoq CbBn+X2IaNSdnjoXgxEPOrEbdJPbe6Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-513-FOOOGCS9Nq6C0wiBz3AC0A-1; Mon, 29 Jan 2024 07:47:40 -0500 X-MC-Unique: FOOOGCS9Nq6C0wiBz3AC0A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED2DB86F122; Mon, 29 Jan 2024 12:47:38 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 802EB8B; Mon, 29 Jan 2024 12:47:33 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 07/15] sparc/pgtable: define PFN_PTE_SHIFT Date: Mon, 29 Jan 2024 13:46:41 +0100 Message-ID: <20240129124649.189745-8-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspam-User: X-Stat-Signature: 8aen1csb6jfp9zgbz53kzatj49txo38i X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A22284000F X-HE-Tag: 1706532465-617581 X-HE-Meta: U2FsdGVkX1/IksZo/Ucf9CzdJSQ2+d6oe8nRo7Rco6FDg5xH0f5wGbKjdWC2cVRUuaAX7uLpnjiv+NxGUEkdAzCZWemICp2Mb+AelLJ8vmTG81IdDZWj81eUfmTlWN4l6bMEiTNzt+Hlt+7SQrj1EejRIODVbMh78uC4m/hFtsemYfsNhjY3i76ihTxmM12ZE9WlK+XsCQ2CsO7tv2zEUkYVbxFZvUSKPYT0+UHqPeL14iwscLUZXHVZZfXupPMmeaFhHd2ynH15QYIXM28k1/iAtJzK7wss9A0ZyCnyaP4v7jGyPzvlGm+0QSYVSiIz4uPI35YblAQ0nARORdzVQpOZRzVdTaAGYwpbGaWDGxfkde4blilv0Jo0HsbOEAE9dl+Nhdah8wO+AyAf33mP/wevnY6p1SRRyfSInbX4y9sa8FvGhK+nezpw7BIJFHEiXq3LmtB6ARKugIQ0W0KuVld9m1vlYrggEX9Ctcm0tw9mzYLd1EDb8Bj+S3R0KCt3VAJ0lsfBBxtn0sJP70vscdGZsLom4JUjlcL6qTxoHHe0rEf0ahQBDjGX9PJcuTQtLGMqJfhoFzcXngtWxlZ3WUsDYqZsm2cszU1r/9TJQ/NKnzxSvBOG59eSjhmnFKSOq3yY3F30d4hhbBfa0HrAnYZKZRIWbi+X83QLmZrgOu80vL/gg9uK6zMOF3Qp853uPkwxnstJVgF5no/+Mvxklq2xKbhtSF1Mk58i3wTgFqPwQaLj+pipAlO8o51cAKeLN8PMiIY6hbIrzfVzGWYJXZs5MXt0NXKzQn2/Pc3FEQFUR1r2oTajRSTzuxdwX3w8QJ3svGvbPJ/NtEKJDh4bsAzIRg647y/HQ1GpYz9xd75DpMTKS0eQGZMKIlG5tARZHIal5fMrjhN87zAen/szmy/1mQinCwIO4f/92VXq3EXMFY8lDl9mWNC53Zk1vdTMSfGyfKeMHpJJgckeG+l JqdnrUyM Qe0I3/Y5861ric5bpx6pUKdEkykeYlH4KJwuZ/oOJAhwik/Rq1eouZpy5zpwVmP8QqvUXh6YvHVM94QW7Iw0MjYqily3t3MEorJ+kMCVMfPBS2bbuBnQq6GiTN6awsCnZVoIoAFfS3KxTY4pNZQCbox/e9Tl1FtNZRpDbe7O+ynWq3hSA+kJhp6pzRAO0u9nupXuU5Sjj6w1nhvP4qUM8JWHICqHkc09VaEIK 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: List-Subscribe: List-Unsubscribe: We want to make use of pte_next_pfn() outside of set_ptes(). Let's simply define PFN_PTE_SHIFT, required by pte_next_pfn(). Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- arch/sparc/include/asm/pgtable_64.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index a8c871b7d786..652af9d63fa2 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -929,6 +929,8 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, maybe_tlb_batch_add(mm, addr, ptep, orig, fullmm, PAGE_SHIFT); } +#define PFN_PTE_SHIFT PAGE_SHIFT + static inline void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte, unsigned int nr) { From patchwork Mon Jan 29 12:46:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535522 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 813E1C47DA9 for ; Mon, 29 Jan 2024 12:47:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12C9A6B00A0; Mon, 29 Jan 2024 07:47:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DCDF6B00A1; Mon, 29 Jan 2024 07:47:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E95896B00A2; Mon, 29 Jan 2024 07:47:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D6A8C6B00A0 for ; Mon, 29 Jan 2024 07:47:51 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AEF9CA1E5F for ; Mon, 29 Jan 2024 12:47:51 +0000 (UTC) X-FDA: 81732325542.22.26CCB02 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 073B9140019 for ; Mon, 29 Jan 2024 12:47:49 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wfr0+qJp; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532470; a=rsa-sha256; cv=none; b=zxS5ShAFWXwtdhuCMQx/FTqTJT+g45O6VaQ9fEtHWefhr4uVHcDvTarymj4hNn0O8SFvfK 1VZyBgmeV6Je3Mc50SAnLoPaO8wfLpPvU4E7QGfmlytvbg2YCsHfKFc+IeqanNnOr3Vzd0 vsXAFARYoZzAxfVKy2ROWMIr4EfxUkk= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wfr0+qJp; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532470; 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=dXK02yTQR3iX9+2hOAsyvxeT8orGle3067Vuz1QJ0iE=; b=Db6WqCBZqUVXjHDNLK9D0KOPk/v6dZrJv4ds6nFJfK3MKbHvvPTPN1JGPH/mVCpXCQNAsR ypHWakfcOM6OQJ7GPQ1okVqSIXNqec7zpwfNLF+g7C4y1f1mI91izGfTBO7u8h8hk7B8k8 mreVCVfejH5eQ6YbaymorfefUOLhbf0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dXK02yTQR3iX9+2hOAsyvxeT8orGle3067Vuz1QJ0iE=; b=Wfr0+qJpqRUdmSELBjWCJKOwk4YE3A7vrIhjFoSZjFWhFN1AaFXDGfoFFS0ZAqGyUpfiXj bd754oEVg9YCgGmjORs26Vjh8Zljv5CA3THlXoSn4yvTpOWnW0AgyPqTxVUOsfKj7OGKBr Tkffi8EtKir3aKebCoQlcaw6fBeFynE= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-512-Yd-jPcF4M0WLV77ep4J5DA-1; Mon, 29 Jan 2024 07:47:46 -0500 X-MC-Unique: Yd-jPcF4M0WLV77ep4J5DA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C956E3CBD507; Mon, 29 Jan 2024 12:47:44 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58D62111E8; Mon, 29 Jan 2024 12:47:39 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 08/15] mm/pgtable: make pte_next_pfn() independent of set_ptes() Date: Mon, 29 Jan 2024 13:46:42 +0100 Message-ID: <20240129124649.189745-9-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 073B9140019 X-Stat-Signature: p5sr1do3p1tmke6xg5a4pnq8ykaygchd X-Rspam-User: X-HE-Tag: 1706532469-227408 X-HE-Meta: U2FsdGVkX1/pOw8BJ/wJId39vTHmt6Q1rCeB7/OwcNkJEuuH4sKTSUHVNCfxfDHDNvlL95HZ9qCqtIHK+2gGBqC1bKNd3ULHCRMuchLC+mA3eMrAOLEfJfT/PmjcT0cQOhdT+92dOJW0oORn3gbX4+pb56lSpq2g7DDWhytu+Zk7TXPPVjKTVmGNewcXcKvz6y3hgrvqAvCkNqNq2MmOMiu3hZX2m0gZcWZ24sElBQddU0cNhIq0Vb16evHkJevttVSjBW5PM3QLA93A6/qM+PDCrkpy9VH0cvKHWx7nKAN1pEk0ImcJh6mYgdVW6t7u5PUHCrOlkN0CubxeT7pBKQ1vx39hJDPZD+eceMDePyKiGgc9VI0BhAiUVLNjNJMD2edB51JUI/FvEBRIoYaPQFxrXFEkpSXuaCQHSlFwAC8tOyXpFsz2AR+k8pEqqEnH/i24z0Bj0YwneWmzbgwc4HLM2syp63mLvI//EIvLlqYRCHHjPj/RdyKlAQfxWBKktkiE+yUOspFFz4SHGLTuDE0C18Vjl7LL8CzFUDM1mNqBQT2N7q1nBn7Ld/XQKksZBO/CWddK5UEbPmk5Uaqfx91FzrGuuF1y9clljOABYr191LgtjinAwaJMhaRAb2wVIzNRm/0x57jKXB9wdW8WbChm2/A4xwH7RYmY+JsTTmoxiCC5ipvxQTlM89CE5UHbhomZ0zELoMLeupin9OSw70RO+U79xbaD3OhznRtXhn9Y7/9Q0pr3FHw2LX9UE7z+CT3l002KwZyIiQ8Iwuxpiiwx4ubRV8sdDu9dkMdhDa8zSPMsd/NNB7l9mKRPMgvawO3kB8ZSu880JP9dYPHZtvsRGKFYNXeBuxpXr6JZzKV6cs64rUw4pulm54sAsLy71np+8Z5UQvNooggwOirsJLFVU5ekDT+WCOGFq9oHJvHpJC1cqgwHfcNVJxx7tqs/7SY3ZzL1B3LCy/Cb744 la+Igyh1 G36W0WKtI2/QFb/TeawQujkljA71sezK8tPOvYqYknEOfX90PV/rWHFl4dwBA9YSC9FwnIAIBOpHOTbwzaMop/EPCoLrCq5VN/GhYi721WuLbvNDeBqmjOW0I/6NvDpagDbQdLI3gwizcu7qDyqnrTepdaBtDOdLRaQk+yNykHe2IrnkMafYtammWF6LYsHBUJ1FpcC3WVNrYXFR+ZWuq0HwftDf4U6xxJEng0tueGRpTuniLtBsd+VN78sR32E4tuVh5MzMXiVdU1tNUd14WvssOvA== 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: List-Subscribe: List-Unsubscribe: Let's provide pte_next_pfn(), independently of set_ptes(). This allows for using the generic pte_next_pfn() version in some arch-specific set_ptes() implementations, and prepares for reusing pte_next_pfn() in other context. Reviewed-by: Christophe Leroy Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- include/linux/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index f6d0e3513948..351cd9dc7194 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -212,7 +212,6 @@ static inline int pmd_dirty(pmd_t pmd) #define arch_flush_lazy_mmu_mode() do {} while (0) #endif -#ifndef set_ptes #ifndef pte_next_pfn static inline pte_t pte_next_pfn(pte_t pte) @@ -221,6 +220,7 @@ static inline pte_t pte_next_pfn(pte_t pte) } #endif +#ifndef set_ptes /** * set_ptes - Map consecutive pages to a contiguous range of addresses. * @mm: Address space to map the pages into. From patchwork Mon Jan 29 12:46:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535523 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 67563C47422 for ; Mon, 29 Jan 2024 12:48:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE45F6B0087; Mon, 29 Jan 2024 07:48:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E95106B00A2; Mon, 29 Jan 2024 07:48:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5D796B00A3; Mon, 29 Jan 2024 07:48:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C40F86B0087 for ; Mon, 29 Jan 2024 07:48:02 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9EBD580288 for ; Mon, 29 Jan 2024 12:48:02 +0000 (UTC) X-FDA: 81732326004.17.3D4303E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id E12DBA0014 for ; Mon, 29 Jan 2024 12:48:00 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Dn5nZ6Ln; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532481; 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=fKY0nJ8fYJnC2xkC+wk3vcUZKJJkEzEBPQxWgaxQbuA=; b=vXrldoRvk8dEROpm1+06jo7gVvmJbXwe2HNldOmQFL7d+D53rMmxXw9UZBy7nstQ+ScuDB R7FRO3XLJcmaCINDz9GRVh1V4btD1sWegoQNd7gcP8REMZF7PYxWKrgOZ40LDY5dYeYDz+ TUihwS5R/eqVR/r8f99MAgyUv4K87kc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Dn5nZ6Ln; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532481; a=rsa-sha256; cv=none; b=pwA4ZLklZbssLtRt1Qi62t7b47g5OBI4uxN/8VMwIrfG6uZFS2eqaRBMWYNQ5H0vu+DnXI sT1F5kRi2R/m9NCRdGD/JdMfgMZ9O3r5oMVl3SzeSCinDLST+qK+7PnsfxautuTl2ODK+p 8lbPROrP24KpTGBGtRt0Q0SsMcKsq7U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fKY0nJ8fYJnC2xkC+wk3vcUZKJJkEzEBPQxWgaxQbuA=; b=Dn5nZ6LnINyNQGeKjGzqrL2GZr+737VXMeXctm635cBmDrwisj98AkMVvsC/Yvm6hVDBYW T92MZSU8rJL/q3XtyOqJ9luuryY1m8e+Se91669XwQjzpz8QI5Ocb5OOpBskC5T4ZLCTzy SMn3pjlXzvss0ivAt09juQhKmqNHSd8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-L0LUIbsCOk-VxGFEn38f-A-1; Mon, 29 Jan 2024 07:47:52 -0500 X-MC-Unique: L0LUIbsCOk-VxGFEn38f-A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4AC391C04325; Mon, 29 Jan 2024 12:47:51 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 304AB8B; Mon, 29 Jan 2024 12:47:45 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 09/15] arm/mm: use pte_next_pfn() in set_ptes() Date: Mon, 29 Jan 2024 13:46:43 +0100 Message-ID: <20240129124649.189745-10-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E12DBA0014 X-Stat-Signature: 48mrmdqc8enonxcnnf3q5pxt8xsedfud X-HE-Tag: 1706532480-822149 X-HE-Meta: U2FsdGVkX1+D7g9PV+6hmKZoVRhGgAfVA5E3DfNJOXBNieCyCsBK2n9aM8ck6J5jY09BBNH5vkOqKRgYAImKizaVF6GEKkqhgJNnB/Gojij3vrylAUySKGh18vncp9TzM09R4f2N7SfZF9IDtUqUalnHs5eBajgr2Kb8f7n3DID2m88jiLiT/DKL89VjuPfqc1dJemSIYXf6mjQuZYGuZq75AzsNEk1L33GvqHpo6H71ROWjX2Fx+SKkgsiidMnjsk0kmZUf6KFNmFQP5m5tfKu8g0Tf1ABU6awXZsGKWAfOemJpxXQ6CUM9v1XMz35w16lrDh6MZyXp/SqBN5mSCeDQGWy6I3P1/no5BMZd1APREs1jTaQbP959+vUDbMc8RqOM5bTurN/AbSLaw1yVk6yrqs51CCbddKJnfqOOcyAuvNenTeBSTW0lZcpCGBbcArjKfwFuA8Ep6wtH9KPbfZqCKDUDjqA2e7kbmOXTG5VYs6QYYJ5GDxNoOR4j40gF5M+y3JCf+kb+45lJ3dpc5ijOrcmMP1wSd9ERxnlAO5AuxvBPefojthJ64YYqF0mPD6r0f6GhRsNI85fgMsWJ3KmRSxKuqyNUadSODfPut2Asy39XrwbEtC596XyGqpo0QcV3xKfM8PmCXg8R4QHqU3EGrdjIifZrfw8P+KqNWPBDl3Mi3tTwEubSrYGPvEYr57Sa5ogBi8DjTHtwuFs6F7ioFXZrzmFJ6ZBgS01ekMttWAJsfYt/q0/FgXpZndcd7rfAdMPLR+9DTqpQ2UEPtf9q0O2AgTvXpKaCoDzoQuMQx8NpJZvJ6nfTDiwAv4JPKSe10dxtgrFWTfahYUPicP5iclFhlLl+Cb+8Xh+JT+ZbfA2PXjKRMrx45Z6wA8HKyXLIOcdgN+VLxJqq8GIFdMBaPHm5dlEd6KXZFsZ/3dG8okYrbY94E9Xd0xjsCi7og0HrNoA1ORIfZziAHQd szdcEQOf /e5joVclm1gidR41yH4gUnvh6GRjpK8G6AmMHVIsegUnf5d+bCe2O8h+PagJCfd/owfxrLm2U8TqjTOOKNLXdRjyp7ndq1irgAF6cpTGlQkc6ESlCr3/IXYPckbyssTOngphBXOUPw3HakqgxaKxlyC+eM+1MAjdiGINYUdnZCg+qIu2RzYyQLeK/ye/HFJ6Ol/UdOdGJk7kdVnpRalLj9x4RKTiJZzGtnscp 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: List-Subscribe: List-Unsubscribe: Let's use our handy helper now that it's available on all archs. Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- arch/arm/mm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 674ed71573a8..c24e29c0b9a4 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -1814,6 +1814,6 @@ void set_ptes(struct mm_struct *mm, unsigned long addr, if (--nr == 0) break; ptep++; - pte_val(pteval) += PAGE_SIZE; + pteval = pte_next_pfn(pteval); } } From patchwork Mon Jan 29 12:46:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535524 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 BDF5AC47DA9 for ; Mon, 29 Jan 2024 12:48:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 522636B00A3; Mon, 29 Jan 2024 07:48:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A9FD6B00A4; Mon, 29 Jan 2024 07:48:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D5B66B00A5; Mon, 29 Jan 2024 07:48:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 167476B00A3 for ; Mon, 29 Jan 2024 07:48:05 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E1757C09AD for ; Mon, 29 Jan 2024 12:48:04 +0000 (UTC) X-FDA: 81732326088.02.692D492 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 4267F140020 for ; Mon, 29 Jan 2024 12:48:03 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I7BzKUxB; spf=pass (imf26.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532483; 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=Y3Tbdl4mZ+WM96lxB3iHDtUIqesuPBdfScoz5at5AOg=; b=Qzka7FCRA2ZhoUs1FtkcayUpZKvBgfCe0GQ+QdxMQswYigbLt0+Z8I11lF2XZzxTVGV9in PjtXnQCTdmzJs+OzNAhJ08quXOcGQJkwHdBBiXNdOj9CrTuvvWqfBQYdorPOMjuT1ikEli XwaLW0olRlxLFsEQyXZK1hQjA3NoEKc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532483; a=rsa-sha256; cv=none; b=7r6BoFulpZC2+8rOQmuyLhkfD1Be5jAwlI+cT1T+YLyg/1pZU9F1zXO0xgRQbkp7dOLZG8 xn2yInP/gNKC8855tnmw04mYX9B+wgo2a0ahCTj1KA216UOsUQ/LutZ2pkpA9lJ7Kks+a9 IqOiQlmKj0FlNf7+uEjCV/4+pZpIkAk= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I7BzKUxB; spf=pass (imf26.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y3Tbdl4mZ+WM96lxB3iHDtUIqesuPBdfScoz5at5AOg=; b=I7BzKUxBU8WN3atRwyGtsCKrs5jSSnD/J5pKaFUd52iDo7PtyZdSTmJvnw/Gyla2jdv2hs /z4wXR0jCzgOuDOeu7OUScJtGW4U2ylsU4RwpZ7iq9L13d3JsnfNIjhgGb7HV/gM69m9XS MZCKUytkb28IToVCfprjuHTFPqDNs2g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-380--x5t9X58Pm--BZadaKlp-Q-1; Mon, 29 Jan 2024 07:47:58 -0500 X-MC-Unique: -x5t9X58Pm--BZadaKlp-Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C50FF85A58A; Mon, 29 Jan 2024 12:47:56 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9ED7E8B; Mon, 29 Jan 2024 12:47:51 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 10/15] powerpc/mm: use pte_next_pfn() in set_ptes() Date: Mon, 29 Jan 2024 13:46:44 +0100 Message-ID: <20240129124649.189745-11-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Stat-Signature: 8t59mxawc8ijdkdizuyu78soszbkah1h X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 4267F140020 X-Rspam-User: X-HE-Tag: 1706532483-946515 X-HE-Meta: U2FsdGVkX1/51pRdOLN9o52mD+l5sU4yrtyPs72rKxEbBcSxDlYW4UG8emVL0Uz4Piu4SO1rdGedk6dd+hLo07L3nWR/FDNyWrRaYiYyHOg2cGxdNU68tETkbrz+Ps0UNAQUwOPZMjyQACvLJI+ZASjp1icx7m33FILUcbhBAJTENL52q/Qo8Zm3S6NVaZxQzTDw4/FXCiWLex0TKPUJ5IXfT8L6VwvY8V4zSKCgezHnnwjGMPOiSPHZhZqBI7MXDtgVGhEbRUy8S4bj1imf4wmkHAfOYoQn1lIOrX+IFcG5ZaSd+9YuEQnjkxHBUy8XDq5CICiwnk0gva69AC/7MeF9bEUKpE9N/57NiI61WxlZSMDQEesg2AqD2uAxwMcrT9j/+KBAN0VMXTtx0OM7N9zpB5VlzwUggFKA9cyloPH5v2dY2+r3heT/VfmfKaMNLFLRWUiyBazaUrApDl2gw+zCAIxSftjA0vSdJjQEgGNLvbjMGWXte9xRTMTKOJzUPPYKbVsw1aEcPHIyLIjWaCKucnIJ8xvEKVpoxAsODARvagx+3xE6zbcQHuWIXnoN2ORF06M6n42VbXS1xaGUxlYFsUvIF9Uzcj1SOTODBZdFKgc/+aXIsVwH8E84bw6DEX7J7g75alFMSexDvNN7WpjJT9zQesw+bn/TgJeruGOiSwVSdVftFhqGnif6vQ7RbG7j7z8akmZBXyHVs2O+BEp31UWVtej6wxEx8rV9EYlJXVyP99Xhb+krFT11zaGLYDkYBVoov8thooHwR2mps4HOkten2q9hPRYBQooOwBeHSqlhw5mxikjepikah2RgHfVNm2K193EqRdUze2yyKb+AOlYT2GtovLqgfoAl3Ze/6X+4PImXmyf+NqCug2vJGewVKJ2ItR5H00yyigjqig1rCi2phyt8z/MVmFIITZS3WC1sIDWbqUgGtEMn/0Fn 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: List-Subscribe: List-Unsubscribe: Let's use our handy new helper. Note that the implementation is slightly different, but shouldn't really make a difference in practice. Reviewed-by: Christophe Leroy Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- arch/powerpc/mm/pgtable.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c index a04ae4449a02..549a440ed7f6 100644 --- a/arch/powerpc/mm/pgtable.c +++ b/arch/powerpc/mm/pgtable.c @@ -220,10 +220,7 @@ void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, break; ptep++; addr += PAGE_SIZE; - /* - * increment the pfn. - */ - pte = pfn_pte(pte_pfn(pte) + 1, pte_pgprot((pte))); + pte = pte_next_pfn(pte); } } From patchwork Mon Jan 29 12:46:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535525 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 9A501C47DA9 for ; Mon, 29 Jan 2024 12:48:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2899E6B00A6; Mon, 29 Jan 2024 07:48:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 239C76B00A7; Mon, 29 Jan 2024 07:48:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B4D66B00A8; Mon, 29 Jan 2024 07:48:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EBB0B6B00A6 for ; Mon, 29 Jan 2024 07:48:12 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C240180A33 for ; Mon, 29 Jan 2024 12:48:12 +0000 (UTC) X-FDA: 81732326424.26.63E8B94 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 0D57EC0027 for ; Mon, 29 Jan 2024 12:48:10 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XUxetxEB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532491; 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=d7wzDgEVUWhg5ZER45HLd710ycKB3fz8RPuXE32SMZA=; b=UuwTpksM5D1n4Wz2Xhjx/s3yET1Zhz8jvPI9x9awY19Ii+uyGploBvkVLINPM5Oe28mzJx Ds2/ZbaSNH9KfA6euYFreNkQ4z7IPWMab7NMUBX4Nd5Uo25Nc6BAkq058bUQL6UOdy0Az5 1bhqUrjwjbe9fHHgnDBdFEY/kk0GBUg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XUxetxEB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532491; a=rsa-sha256; cv=none; b=s//Rgh17J7EJa2OOTBRbTDLV9j8YzKZF8eGE2noDJFGnbRk7Jw6AS9XXnaKcCGDUEVGhoE /82BQZHjH7CQ/LKHcOx7uHe5CelcAxbyfuOSuoFKrPXh2JUWqLBWqLpJi17kCXxxiWOOm1 sZgv6dHF4uQAk46pEDUpamI/uw9pm0I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d7wzDgEVUWhg5ZER45HLd710ycKB3fz8RPuXE32SMZA=; b=XUxetxEBhoBXne5mDBIHQ5yIZ+scYzI23fjLUGXliJN2/GYKLbTASZknuW4vj30nsdJ/EG n+EXsl5OfFfRp8hxr9Th7qqn6Di/7jQz8DnWp2mBZJ4cyiUmOMtoWFPiMt3MKOx2FWz24/ fgqUooRq3DMuB8L/hUWUySe/9Ea8Kxw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-140-9ly1pTIPMpeLAWW3OrQO1g-1; Mon, 29 Jan 2024 07:48:04 -0500 X-MC-Unique: 9ly1pTIPMpeLAWW3OrQO1g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3AD4A3CBD50E; Mon, 29 Jan 2024 12:48:03 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C0D28B; Mon, 29 Jan 2024 12:47:56 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 11/15] mm/memory: factor out copying the actual PTE in copy_present_pte() Date: Mon, 29 Jan 2024 13:46:45 +0100 Message-ID: <20240129124649.189745-12-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0D57EC0027 X-Stat-Signature: e3m99au1q3bm9kubzh8dq89io1xnuyym X-HE-Tag: 1706532490-633764 X-HE-Meta: U2FsdGVkX18oY4fpdaauV59XG7c/QZNJXLzg5DG7LoJStBb1pp4YU1VJnZxHnfjQfwFk6DgGTGN1IPTNqlKxYbskfgGh88yAptg4hKlkiGo1pe8u0wDXboTjq2mKQVR9EqN5bnUsD2FkPmYk1fX7QdVTJGm+6rwktJSgks4b4yXK8/VOPuWyUaFqWoGLW0pcufcInx7auQOGaDv4w+2Py9EZXwWT6Dv1t/KHYZGaos8JDZe4h7EXNv5dD8OHeDJil2hOkByvm6M38XIuK+7f7hbTvs/Cr8xbUQiXbwxNvOw9fSYsrcdStEB34lqzWRvI84bLB6XexdlCuz5+0g4Ej4K2ubAufthh7q3j7SHR/3MYDCfaF3SkDm8N+9L444EyLBNi9xar4JIPkeqmQeZXSPYdkUy79k7dB5KA7t7ZEBPb3VGUqCnjmTBtT4wXGJB0eXC6jKUMbSVx1nxYrlvb6hGaPlh0OOSiJuBKq2+2FhpDBYA0jXdkpY/lIPo1dM0CKN+c9WbSgpZ/H3awYq9upyaJqMBCbzIQNUmC2xk5/Ss27lrhWZneYvtfgIUoiDAFQL/j6vB022/l0Hp714yrUhNBb66gwdta1+SL4GCUp/JrsS+WF5yRvsabJKmMAlchvOEwC+YPzQx/1SpGugubrVRgbHrlhNNsBaXQoI+NAM/+tNSk4IVnSP8tWqJ0M4vUWsgdl7jV0LkJJc6LXbyUZr7HDop7zooQrleSMRoc2WTUfrQZBIw3mX1GdX82Z9REM9yHZCqZTlw2y84aui3vrLz7dN0lyoGqNxoGLc7Z0t5iLnyIryDlmONIPh9qhbHPZylfxLDXph44hPBTzXfM+E+14/ObqXQ8Wms1mzS/lrxdxiXj7KILTHVrnO7ISOnamlvM1qxvjYTuxDkcTPJWTfMTAwDPteIOSzoVWRwQeEpNzmU1DjlDHNVeQZqTZVp4cVK653Meyu8U1qzs5fK h/u8pgxs 4mdWXnk3ANVqnUVRSh3GMTXalOLOBFM7tq1wRJdfQn3bIzruB9akejRXokHdTqJ4SLy10dR5entDt6kbn+MxXq/YDvRVNGpIcLz/4A3N8a4Qr0GYLCyxCjQWd6/75tc+SJMS5VvyuUKn1iIWLgwO5gxHOyaTWinMtvd71KlXRH1YPM3YXq/p8rDD4VzD9Y/ajM9ubs0ojkHuyG10xx34GFaHamlpAT60ZBmd3vlVm+bceKczOfvgSWN3Wa9E5nmvuOk8mg+f1/V2yVEFuzud4fJCsGg== 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: List-Subscribe: List-Unsubscribe: Let's prepare for further changes. Reviewed-by: Ryan Roberts Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- mm/memory.c | 63 ++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 8d14ba440929..a3bdb25f4c8d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -930,6 +930,29 @@ copy_present_page(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma return 0; } +static inline void __copy_present_pte(struct vm_area_struct *dst_vma, + struct vm_area_struct *src_vma, pte_t *dst_pte, pte_t *src_pte, + pte_t pte, unsigned long addr) +{ + struct mm_struct *src_mm = src_vma->vm_mm; + + /* If it's a COW mapping, write protect it both processes. */ + if (is_cow_mapping(src_vma->vm_flags) && pte_write(pte)) { + ptep_set_wrprotect(src_mm, addr, src_pte); + pte = pte_wrprotect(pte); + } + + /* If it's a shared mapping, mark it clean in the child. */ + if (src_vma->vm_flags & VM_SHARED) + pte = pte_mkclean(pte); + pte = pte_mkold(pte); + + if (!userfaultfd_wp(dst_vma)) + pte = pte_clear_uffd_wp(pte); + + set_pte_at(dst_vma->vm_mm, addr, dst_pte, pte); +} + /* * Copy one pte. Returns 0 if succeeded, or -EAGAIN if one preallocated page * is required to copy this pte. @@ -939,23 +962,23 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, pte_t *dst_pte, pte_t *src_pte, unsigned long addr, int *rss, struct folio **prealloc) { - struct mm_struct *src_mm = src_vma->vm_mm; - unsigned long vm_flags = src_vma->vm_flags; pte_t pte = ptep_get(src_pte); struct page *page; struct folio *folio; page = vm_normal_page(src_vma, addr, pte); - if (page) - folio = page_folio(page); - if (page && folio_test_anon(folio)) { + if (unlikely(!page)) + goto copy_pte; + + folio = page_folio(page); + folio_get(folio); + if (folio_test_anon(folio)) { /* * If this page may have been pinned by the parent process, * copy the page immediately for the child so that we'll always * guarantee the pinned page won't be randomly replaced in the * future. */ - folio_get(folio); if (unlikely(folio_try_dup_anon_rmap_pte(folio, page, src_vma))) { /* Page may be pinned, we have to copy. */ folio_put(folio); @@ -963,34 +986,14 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, addr, rss, prealloc, page); } rss[MM_ANONPAGES]++; - } else if (page) { - folio_get(folio); + VM_WARN_ON_FOLIO(PageAnonExclusive(page), folio); + } else { folio_dup_file_rmap_pte(folio, page); rss[mm_counter_file(folio)]++; } - /* - * If it's a COW mapping, write protect it both - * in the parent and the child - */ - if (is_cow_mapping(vm_flags) && pte_write(pte)) { - ptep_set_wrprotect(src_mm, addr, src_pte); - pte = pte_wrprotect(pte); - } - VM_BUG_ON(page && folio_test_anon(folio) && PageAnonExclusive(page)); - - /* - * If it's a shared mapping, mark it clean in - * the child - */ - if (vm_flags & VM_SHARED) - pte = pte_mkclean(pte); - pte = pte_mkold(pte); - - if (!userfaultfd_wp(dst_vma)) - pte = pte_clear_uffd_wp(pte); - - set_pte_at(dst_vma->vm_mm, addr, dst_pte, pte); +copy_pte: + __copy_present_pte(dst_vma, src_vma, dst_pte, src_pte, pte, addr); return 0; } From patchwork Mon Jan 29 12:46:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535526 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 4EBA9C47422 for ; Mon, 29 Jan 2024 12:48:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D10838D0002; Mon, 29 Jan 2024 07:48:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC0368D0001; Mon, 29 Jan 2024 07:48:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3AA78D0002; Mon, 29 Jan 2024 07:48:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9FDA58D0001 for ; Mon, 29 Jan 2024 07:48:18 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 408BBA0673 for ; Mon, 29 Jan 2024 12:48:18 +0000 (UTC) X-FDA: 81732326676.27.1FCDE3B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 93731A0019 for ; Mon, 29 Jan 2024 12:48:16 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YD0bDj4V; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532496; 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=cS+fj/Ib0GI5otmzNrt4qLpnZeCkiOZS5Y+GTIa0gvY=; b=JKyCHuHpHGV9rvK/7TrkxlDsvA2bT3wuNJJ5XkcAe6W1OcDw4ARGxHS07PM6lGX+k+D24G I/yR/OfVkUeH/ZrOwesG9FpMQUqQdzzCY5/YODDeJaPQgok4daHotCxQv8GBQaZUCA7zuQ tIIDww+JkM+k0qqjQRmWTme9z9qUPBM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YD0bDj4V; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532496; a=rsa-sha256; cv=none; b=PY4ubrC2k9z1uCKdcR29/VE0alz7Vpa/J0admXQWE8JNpG9e7i4EOAag9tjXZ+CT2zyhVs bzA653ohEfEWP9lXCJ5ihRtEqQq0p5bv7hqQQ+ATPdc9QmKf668eNa7FZStujMrjf2Q0Yh TLwPyxq4EGelJIqwAgW15F/8/PomzVo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cS+fj/Ib0GI5otmzNrt4qLpnZeCkiOZS5Y+GTIa0gvY=; b=YD0bDj4VdI4pur+YYkFRMQLfK+P76yG4GXj0kIiPIGpwIXKFY6tVuFiPbdATVSY7b7S+lC mk1YRJJYuK269tgwrHw5dDxcc/uziuKXGwe9hj9C9lo7fCMIVLuXFxa121rPLDZQf2X9Dg jMNVhJpE5bjc006hHFoYo5bsLTgVFZk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-639-uopDDWlrNyiX6spNRSMRFQ-1; Mon, 29 Jan 2024 07:48:10 -0500 X-MC-Unique: uopDDWlrNyiX6spNRSMRFQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D8CA6867943; Mon, 29 Jan 2024 12:48:08 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99F798B; Mon, 29 Jan 2024 12:48:03 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 12/15] mm/memory: pass PTE to copy_present_pte() Date: Mon, 29 Jan 2024 13:46:46 +0100 Message-ID: <20240129124649.189745-13-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: 93731A0019 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: efq7ujx47ijeraj96ht58ayqanx5ntej X-HE-Tag: 1706532496-475401 X-HE-Meta: U2FsdGVkX1988gSES7XLXZkOktajQdRj6OKhpMHLwE+pVB14S7Uy6fHuChsu+zuMaGW9sO2ahDeyIwtwiOvUMkMA7YvGkv/2N6tyYC/CSFcHsFeIkSvlGJh3H4dZIsRlwS84wdsdvLEZWj8np/6X6bcKe34u+gnsOP1unNGAb1fO5UNZO+dgMp2TKOUEFHWgKBsCfFrxsGbzXxM6wUFF0slX1lCbx4RfidkdjKONcP7vp6TprfVnBCDpct6J+qtVoGvapZa4gjRSED3mElJ++6bw6AwP5dQV/6gQE4t3DtOOibzdpcqnTQ92gsgdpcrahdp3F+zjT7dX8VXMfBPxhADO/Qu6+O7RvrI3bart3mbChB5Rz0H7/i0nxY3GkOMv1U+PBpPd5K4LlMAD+sGsorVMtf8GFdxylAx+tWJDZfEtmsWnET2VtQvXSXH+feFTwvctOtSFIrq0Syb2n5Ix+lAHhs2MgqLIBKO/GXhAgYRA1RrO4zQHlgfOWxppMGkP1gZpNJppzYre3dS41WXyidwXZu0GFGxPrdDkk55R4AH5fQRrXCIySFWDHjIqydGuOry2+k/lY+fSZFicN17qHO9VkF8Zn4hDWJZ+4kC8Orp8UwVn8NFkK5x/DS9/trDmfA9E/W0q68WFn9U+fYYQU0enQybf+hH879hIrPYC3MY9VPrRJZPakIZVEIA/hTI7gF4H7y/IxiLbyjrK/nwu62SPiFoVowRZGZYO1LuRiucXZIe/SJ0lQLZ7Vs35Mu/adykclwY2GEHq08JSAeF0cSLsTCzGRUozfFhbD5k8x7QlqqqXrriHIdRUMKRddpzKOUM5vGmwacMK9I0NvJ53pHmGM7ZfTb2+Y8njdeLFtieryTV1WqMv9N+lRuQmWdyjmee+tWpXjkojZRcIo3GLuvKhJV116BtA53g2n8m+T6QstYzLmfymae6WMdlRzkVmF3pb7j+V2SMYcqOnozw ChiYCj8E abGYxfokz3wJw/DL9MQefL1ItDRu5F731nLGKjJ77nvy4R3dGzgKx4ieVnnoXPqbwXxefDizrpxraogMoAMBGB2qlGgP8bB19MTleT9lr3MsAMbnrWHCO9AaNwoNZzVOaTQl/1gXLbjL0ThhZKPRtuo64LGF0PhgLCtfLDREU8nYK4rCyvR55HFGxPObescWp8pvOIkRGYxbsS9HD/IL+vS7JSy43fRmFrl4nnU7Ympq7GDorJWNqmHoAxtaU+pbPxHRku/0MSilCSjznAcbqEBHpaQ== 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: List-Subscribe: List-Unsubscribe: We already read it, let's just forward it. This patch is based on work by Ryan Roberts. Reviewed-by: Ryan Roberts Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) Signed-off-by: David Hildenbrand --- mm/memory.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index a3bdb25f4c8d..41b24da5be38 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -959,10 +959,9 @@ static inline void __copy_present_pte(struct vm_area_struct *dst_vma, */ static inline int copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, - pte_t *dst_pte, pte_t *src_pte, unsigned long addr, int *rss, - struct folio **prealloc) + pte_t *dst_pte, pte_t *src_pte, pte_t pte, unsigned long addr, + int *rss, struct folio **prealloc) { - pte_t pte = ptep_get(src_pte); struct page *page; struct folio *folio; @@ -1103,7 +1102,7 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, } /* copy_present_pte() will clear `*prealloc' if consumed */ ret = copy_present_pte(dst_vma, src_vma, dst_pte, src_pte, - addr, rss, &prealloc); + ptent, addr, rss, &prealloc); /* * If we need a pre-allocated page for this pte, drop the * locks, allocate, and try again. From patchwork Mon Jan 29 12:46:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535527 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 F3871C47DA9 for ; Mon, 29 Jan 2024 12:48:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 809258D0003; Mon, 29 Jan 2024 07:48:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B7058D0001; Mon, 29 Jan 2024 07:48:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68B3C8D0003; Mon, 29 Jan 2024 07:48:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5A7518D0001 for ; Mon, 29 Jan 2024 07:48:23 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 32C4F1202FB for ; Mon, 29 Jan 2024 12:48:23 +0000 (UTC) X-FDA: 81732326886.14.C71491E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 7E7A940019 for ; Mon, 29 Jan 2024 12:48:21 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Y99v8U4Y; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532501; 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=GLdn+T1R5PiYDW19VyAaeLNlt8B1zt8mn8YsDhIt5B8=; b=xdd3HTvRg7iD99R/3asmD0mo1YVsqwVL+crqMpzU3DPw2njIrmn5TfCPHTBPzyZb/CBT9a ++wCjiz0Zn5r1+VEfgAhxCl9/St8a+dLIzLHGFUko57v9UZxQXaKlUnlLUBd8ushY0+D9n PLBGUiKibbeFqsxdDVB6PHQyb+AzDuM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Y99v8U4Y; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532501; a=rsa-sha256; cv=none; b=bO/6VZ5TfM0yNB5k9Vn84yQtDXy4WbHMPCekNxondz4AOSW4vLY/xKjFt6lsGjW2e5FFW+ UembTFSASzrhIdv7hNvRFxUfvfpFfLif/Eea0o5hv0qbIArGt7otkFUYj81AIwxcnuDi3h MIRaYeL56whks16sKMx0wv5V0Kkxa/4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532500; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GLdn+T1R5PiYDW19VyAaeLNlt8B1zt8mn8YsDhIt5B8=; b=Y99v8U4YZPpbvKWuES96EHWZXZ1P4dvK3jBafQo9guEWcEbvVvcooLtiOaUs2IHuvrXact tIJI1eyNJ0SZroBaOEL0TQc2vw9ApCmxN/tVeBXgrcw+crFrJy/fecbDdKh6+8MHrHKWQt CgMXuhbM77TRYvIfI/RFWcC3aHcRpPY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-602-1IZZ7hGdOwG8M8ciVMufmA-1; Mon, 29 Jan 2024 07:48:16 -0500 X-MC-Unique: 1IZZ7hGdOwG8M8ciVMufmA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B83A29AA3AC; Mon, 29 Jan 2024 12:48:14 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 277D3111E8; Mon, 29 Jan 2024 12:48:09 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 13/15] mm/memory: optimize fork() with PTE-mapped THP Date: Mon, 29 Jan 2024 13:46:47 +0100 Message-ID: <20240129124649.189745-14-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: 7E7A940019 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: hwcr7jwd9mb5i6g8oumf8wb4pxetnq8d X-HE-Tag: 1706532501-924263 X-HE-Meta: U2FsdGVkX19IlzxsGfuFFerGWfjA17PTkEVb4VFMrELb2aYKpajUL0Z1fG+uFHM4EdkOK5Y8Yz2L6Z6eCfQNDndpGidj8/I6AvSA8ps5ejkSDFjN9fXr0U3rleIAPyXXBcmWHNMtPa/OUwdviJZOwv9GxkItngTjR7E4xFrNG7Vy9C9AnUGq4ePJ5h0FgI+63Z573Q+SBuPrZklf6xKlfJdmm2xnf2zOz9Wk5cq9cVfaZ3qCIaT83y9W739sowlAjsGmcnbrF+WG6oi8Kiwvc2w68H/yL+mfbqvDpkK9nq0rhNnTtwHi8wVycDx/X+rhqi8Td24+gf8yWl0p/ezBtBAHUNE+mfZ6FUdKRDffNppxpovLpqrlVD8o5sG+c8/dZxujtX65MVHP4kOfxEP4o88DHTM9X4fJTpmeP20d8i8kVhObNCyzxAMvQM3TlyFlX1ve0jgWTwNLW6Ftc6NcatW3eKvl0D0iYtomfkGjyxI1BF8/Zt7MFD4ex/H8i51JOyIsPIMVFiRORio7jRJLCwjIkhrJJ35TLBJAaMfRnM2UMHIjYQnEiZDvp1XNw9nieYRYsefnJSabjgiLgQRmVKv0WeJ8ZDoV2jNN0NP8KyduxajhfbRBaDWb+l6d2j2qRAJtqt5EgKg40lr5OcAr0UpL+JSdsYa1/oy/qCFkFzxkGFjWMgRkx27fXZgBAgriM3hGL8jovKBKIlRm6EpDBCKXtdvY0IB8ucm5jagGk813rg9D1+3QT+Rh5Xa3h+siIgPGJ3eMdzjSEzTu9V+MpGZmYSdI9/dt7TG1q+RwMUl34h7cBSu2NmbGkBG0jka6i90SXcIWF3J467zJc4q/BN+MnTiSlZ1bgP1JSSn6GsosYjdhHQ9Zl1xW4lqO/at5bAPnh4hsoYGOghbSS9aVDFENq7AouffU305ATNYo+otHY29l432bHvM3NwIKBtuOWzKAoqpxBWvLt1IDN0z S/noaqDl eVL0EKlZ0EN4XKVebFUApNPe/6OEX+0cBke5Iklm79r6JyAomzwSBiKgzu5w5mKelwvCiM1In5rMLoxjm9nlC9u1QGFyU2rBIKXT7iawoC3Fk2prqYeNGqLiopGgWGTNoiuh4uOSucGZ/Yn7Gr2cOFmTuUwaJIysOw7HgE4D/sDh6wN+vAIGTa8/vp6IgDev831l2XCYhOT3rwSDU8xrh6oUm8dAf6n57drHrU0crXtIyzoc= 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: List-Subscribe: List-Unsubscribe: Let's implement PTE batching when consecutive (present) PTEs map consecutive pages of the same large folio, and all other PTE bits besides the PFNs are equal. We will optimize folio_pte_batch() separately, to ignore selected PTE bits. This patch is based on work by Ryan Roberts. Use __always_inline for __copy_present_ptes() and keep the handling for single PTEs completely separate from the multi-PTE case: we really want the compiler to optimize for the single-PTE case with small folios, to not degrade performance. Note that PTE batching will never exceed a single page table and will always stay within VMA boundaries. Further, processing PTE-mapped THP that maybe pinned and have PageAnonExclusive set on at least one subpage should work as expected, but there is room for improvement: We will repeatedly (1) detect a PTE batch (2) detect that we have to copy a page (3) fall back and allocate a single page to copy a single page. For now we won't care as pinned pages are a corner case, and we should rather look into maintaining only a single PageAnonExclusive bit for large folios. Reviewed-by: Ryan Roberts Signed-off-by: David Hildenbrand Reviewed-by: Mike Rapoport (IBM) --- include/linux/pgtable.h | 31 +++++++++++ mm/memory.c | 112 +++++++++++++++++++++++++++++++++------- 2 files changed, 124 insertions(+), 19 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 351cd9dc7194..aab227e12493 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -650,6 +650,37 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres } #endif +#ifndef wrprotect_ptes +/** + * wrprotect_ptes - Write-protect PTEs that map consecutive pages of the same + * folio. + * @mm: Address space the pages are mapped into. + * @addr: Address the first page is mapped at. + * @ptep: Page table pointer for the first entry. + * @nr: Number of entries to write-protect. + * + * May be overridden by the architecture; otherwise, implemented as a simple + * loop over ptep_set_wrprotect(). + * + * Note that PTE bits in the PTE range besides the PFN can differ. For example, + * some PTEs might be write-protected. + * + * Context: The caller holds the page table lock. The PTEs map consecutive + * pages that belong to the same folio. The PTEs are all in the same PMD. + */ +static inline void wrprotect_ptes(struct mm_struct *mm, unsigned long addr, + pte_t *ptep, unsigned int nr) +{ + for (;;) { + ptep_set_wrprotect(mm, addr, ptep); + if (--nr == 0) + break; + ptep++; + addr += PAGE_SIZE; + } +} +#endif + /* * On some architectures hardware does not set page access bit when accessing * memory page, it is responsibility of software setting this bit. It brings diff --git a/mm/memory.c b/mm/memory.c index 41b24da5be38..86f8a0021c8e 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -930,15 +930,15 @@ copy_present_page(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma return 0; } -static inline void __copy_present_pte(struct vm_area_struct *dst_vma, +static __always_inline void __copy_present_ptes(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, pte_t *dst_pte, pte_t *src_pte, - pte_t pte, unsigned long addr) + pte_t pte, unsigned long addr, int nr) { struct mm_struct *src_mm = src_vma->vm_mm; /* If it's a COW mapping, write protect it both processes. */ if (is_cow_mapping(src_vma->vm_flags) && pte_write(pte)) { - ptep_set_wrprotect(src_mm, addr, src_pte); + wrprotect_ptes(src_mm, addr, src_pte, nr); pte = pte_wrprotect(pte); } @@ -950,26 +950,93 @@ static inline void __copy_present_pte(struct vm_area_struct *dst_vma, if (!userfaultfd_wp(dst_vma)) pte = pte_clear_uffd_wp(pte); - set_pte_at(dst_vma->vm_mm, addr, dst_pte, pte); + set_ptes(dst_vma->vm_mm, addr, dst_pte, pte, nr); +} + +/* + * Detect a PTE batch: consecutive (present) PTEs that map consecutive + * pages of the same folio. + * + * All PTEs inside a PTE batch have the same PTE bits set, excluding the PFN. + */ +static inline int folio_pte_batch(struct folio *folio, unsigned long addr, + pte_t *start_ptep, pte_t pte, int max_nr) +{ + unsigned long folio_end_pfn = folio_pfn(folio) + folio_nr_pages(folio); + const pte_t *end_ptep = start_ptep + max_nr; + pte_t expected_pte = pte_next_pfn(pte); + pte_t *ptep = start_ptep + 1; + + VM_WARN_ON_FOLIO(!pte_present(pte), folio); + + while (ptep != end_ptep) { + pte = ptep_get(ptep); + + if (!pte_same(pte, expected_pte)) + break; + + /* + * Stop immediately once we reached the end of the folio. In + * corner cases the next PFN might fall into a different + * folio. + */ + if (pte_pfn(pte) == folio_end_pfn) + break; + + expected_pte = pte_next_pfn(expected_pte); + ptep++; + } + + return ptep - start_ptep; } /* - * Copy one pte. Returns 0 if succeeded, or -EAGAIN if one preallocated page - * is required to copy this pte. + * Copy one present PTE, trying to batch-process subsequent PTEs that map + * consecutive pages of the same folio by copying them as well. + * + * Returns -EAGAIN if one preallocated page is required to copy the next PTE. + * Otherwise, returns the number of copied PTEs (at least 1). */ static inline int -copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, +copy_present_ptes(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, pte_t *dst_pte, pte_t *src_pte, pte_t pte, unsigned long addr, - int *rss, struct folio **prealloc) + int max_nr, int *rss, struct folio **prealloc) { struct page *page; struct folio *folio; + int err, nr; page = vm_normal_page(src_vma, addr, pte); if (unlikely(!page)) goto copy_pte; folio = page_folio(page); + + /* + * If we likely have to copy, just don't bother with batching. Make + * sure that the common "small folio" case is as fast as possible + * by keeping the batching logic separate. + */ + if (unlikely(!*prealloc && folio_test_large(folio) && max_nr != 1)) { + nr = folio_pte_batch(folio, addr, src_pte, pte, max_nr); + folio_ref_add(folio, nr); + if (folio_test_anon(folio)) { + if (unlikely(folio_try_dup_anon_rmap_ptes(folio, page, + nr, src_vma))) { + folio_ref_sub(folio, nr); + return -EAGAIN; + } + rss[MM_ANONPAGES] += nr; + VM_WARN_ON_FOLIO(PageAnonExclusive(page), folio); + } else { + folio_dup_file_rmap_ptes(folio, page, nr); + rss[mm_counter_file(folio)] += nr; + } + __copy_present_ptes(dst_vma, src_vma, dst_pte, src_pte, pte, + addr, nr); + return nr; + } + folio_get(folio); if (folio_test_anon(folio)) { /* @@ -981,8 +1048,9 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, if (unlikely(folio_try_dup_anon_rmap_pte(folio, page, src_vma))) { /* Page may be pinned, we have to copy. */ folio_put(folio); - return copy_present_page(dst_vma, src_vma, dst_pte, src_pte, - addr, rss, prealloc, page); + err = copy_present_page(dst_vma, src_vma, dst_pte, src_pte, + addr, rss, prealloc, page); + return err ? err : 1; } rss[MM_ANONPAGES]++; VM_WARN_ON_FOLIO(PageAnonExclusive(page), folio); @@ -992,8 +1060,8 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, } copy_pte: - __copy_present_pte(dst_vma, src_vma, dst_pte, src_pte, pte, addr); - return 0; + __copy_present_ptes(dst_vma, src_vma, dst_pte, src_pte, pte, addr, 1); + return 1; } static inline struct folio *folio_prealloc(struct mm_struct *src_mm, @@ -1030,10 +1098,11 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, pte_t *src_pte, *dst_pte; pte_t ptent; spinlock_t *src_ptl, *dst_ptl; - int progress, ret = 0; + int progress, max_nr, ret = 0; int rss[NR_MM_COUNTERS]; swp_entry_t entry = (swp_entry_t){0}; struct folio *prealloc = NULL; + int nr; again: progress = 0; @@ -1064,6 +1133,8 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, arch_enter_lazy_mmu_mode(); do { + nr = 1; + /* * We are holding two locks at this point - either of them * could generate latencies in another task on another CPU. @@ -1100,9 +1171,10 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, */ WARN_ON_ONCE(ret != -ENOENT); } - /* copy_present_pte() will clear `*prealloc' if consumed */ - ret = copy_present_pte(dst_vma, src_vma, dst_pte, src_pte, - ptent, addr, rss, &prealloc); + /* copy_present_ptes() will clear `*prealloc' if consumed */ + max_nr = (end - addr) / PAGE_SIZE; + ret = copy_present_ptes(dst_vma, src_vma, dst_pte, src_pte, + ptent, addr, max_nr, rss, &prealloc); /* * If we need a pre-allocated page for this pte, drop the * locks, allocate, and try again. @@ -1119,8 +1191,10 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, folio_put(prealloc); prealloc = NULL; } - progress += 8; - } while (dst_pte++, src_pte++, addr += PAGE_SIZE, addr != end); + nr = ret; + progress += 8 * nr; + } while (dst_pte += nr, src_pte += nr, addr += PAGE_SIZE * nr, + addr != end); arch_leave_lazy_mmu_mode(); pte_unmap_unlock(orig_src_pte, src_ptl); @@ -1141,7 +1215,7 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, prealloc = folio_prealloc(src_mm, src_vma, addr, false); if (!prealloc) return -ENOMEM; - } else if (ret) { + } else if (ret < 0) { VM_WARN_ON_ONCE(1); } From patchwork Mon Jan 29 12:46:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535528 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 DC1B2C47422 for ; Mon, 29 Jan 2024 12:48:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76D098D0005; Mon, 29 Jan 2024 07:48:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 71B018D0001; Mon, 29 Jan 2024 07:48:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 594F88D0005; Mon, 29 Jan 2024 07:48:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4758A8D0001 for ; Mon, 29 Jan 2024 07:48:27 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 17E8E1605F3 for ; Mon, 29 Jan 2024 12:48:27 +0000 (UTC) X-FDA: 81732327054.06.1785E47 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 679A9A0007 for ; Mon, 29 Jan 2024 12:48:25 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UJ2fU9xx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532505; 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=exEdDlpMqX/TLP6WakzBspRTLcII6GNZP9MIcL4XseU=; b=ZhK47t0DLUCdnbOcEabXOeoMFFQiNFIUPDfMwnoiVJDtxFImOfkr5FPRRFlI80iy8wezZd /ZyUVBTLi7F4VGLaSzZZKFuL7fG/zE+wtHqSQpXDQ5m/FC8Vw/c4BTQMlEJ4/86HI+srP9 CMb4d/H4+gD4nfwuuYOx73zwrcle2aQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UJ2fU9xx; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532505; a=rsa-sha256; cv=none; b=8m37qPoCrfzK07Qb0pGMmGQKvA+lFrdAjyDqGn/SxY0wo0d4t1kktHxrXHQuXBqjO9ErD6 GNYhRPIm4eDtPAleS9jMw2fcUAEmELVVzZR2MaHWJGgkc0KoVtji7s9J8ugYnOlGC2Pt/D 4zWx5EQa2EIWJOme3jynLeXJgkT1G1o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=exEdDlpMqX/TLP6WakzBspRTLcII6GNZP9MIcL4XseU=; b=UJ2fU9xx7cQu0se8ICmieeaAeHR5j2bVyeCVGnBVHQf8lBtJ2WiZLlNYAU0QGRGJRL4bdS v4C7nQcoDhqz4Orurfwnd22gc8O0NXI152IecrmfzRfPas9vIQR9SMFPWI8EGk2Qn6T0V3 dXU8GzBqmqcQFitm6E4HDLR0PNfx7QM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-q1tX4gb6M5-rogvUSokYZw-1; Mon, 29 Jan 2024 07:48:21 -0500 X-MC-Unique: q1tX4gb6M5-rogvUSokYZw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A9C628B72E2; Mon, 29 Jan 2024 12:48:20 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9D738B; Mon, 29 Jan 2024 12:48:14 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 14/15] mm/memory: ignore dirty/accessed/soft-dirty bits in folio_pte_batch() Date: Mon, 29 Jan 2024 13:46:48 +0100 Message-ID: <20240129124649.189745-15-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: 679A9A0007 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: smmu6fmfi79opxbx9m1tzjkfdyjh8wtr X-HE-Tag: 1706532505-276487 X-HE-Meta: U2FsdGVkX19y7bsVGg5QCi9vDl2Fv9wBvpOLkexocweHrRDgO3O1OqPAyuFCxCOc3x6glM1qt+YXOW3VtKCb6hECC7I+fzSoG/ArkNcxObICIEXrJC3foVJ6L08ZUYn/qdfnLEQWa/tOMuyKMt5hDK0DSm3/3YXP+cvVKnNd2Q0WMmOlBeMWGPAdIIVnJGVg/BE/WmJwYXJ38GujTa7VjdLeKoWHvgWIXXjepEVeXQwVq8qe67dxWEJl6WV9AqTjK+2OOBtXQVYihoLIZemZpWCsj74zHPm8sGJdqNNc9P0oqWriRYs0WoRIyF6RWpMtc8IsA1JK6s9T8u1kL07+GYcB+sSBQD4EBLeb6JlfapdOxAbnpYouyLo56vYdB3lemT3gL39L/eK4YOAHJADIplQzugHJSuIz3uyblNjAHss07/O08+axqbwwQHkQDmvkgfD1UN9U+vPL4AqeJMUsIjfVRKumPrYW2PNgSH12FNPFwBIvTc7Pc+n2KreVla2bhwSKaCmNF8qE77tlZp4ckqnt8UIOQ6F0usfdxwqI87FKkhUVGy9D1S04vMEpZ/SPazXqOgsKlY6Fe1a4PFDq1qLBMafaTLzvwVvv5mxfXJwbZVYOZGsca8fakAEM2eT1PuUtb8r83+3rwXZFmlgW9tsmhsAQXvZfGGCbX9+LAJpEVpuce6xnTOxR11b2rK2nkgyAk676Wiq/MIP5nUEyenqZiqHaib0yec9k/nm5K0dThKxbU2DM6gviFchqeF387njBqukp8BpgUVHJCJCv+UTS7/adUtMj/yjeO3QfFNGlB11iTQEfrFYMpW4QYD5L38l2lnChzA1SxdpoDBzgGTMSX4ghpvlUm+R7EtyEvkAXoPqN0hYdPlQNnGWlmMp2ouNx7OYpfgCa4Qt96meIwFKI0mm0elMF20OxzRv8oHe9sVPmfQu0TUmCVdQjyTZX99ziJn8NOqw/ldmo8Gg k28rGGw7 /pGBx0bCVDWyBq3+RtjKHyjCWyyKMQmUsCIZJdqTBhl7LwZVBUq7teOWFDIy3Ke4n4ZdpeONCo3IbCY2t/0HhgdyYzs/tJ/xbOBRd+iL03NjsSKThVPMqeIlBd+UEHvgoWiHBJrOW5oZTK1DiF/STZAkHCeKvfa7L9UQLDQBhLw8iqmoQeKkFd9JtsezpXa/olRqfUe2yO3vrLKysBiD6C4udV4VMRCMUhZPSYN+PWe4/ovf07uXiNCjUanYmIQL7aQ1Ag4fPY9VmEV2IMFefc694pg== 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: List-Subscribe: List-Unsubscribe: Let's always ignore the accessed/young bit: we'll always mark the PTE as old in our child process during fork, and upcoming users will similarly not care. Ignore the dirty bit only if we don't want to duplicate the dirty bit into the child process during fork. Maybe, we could just set all PTEs in the child dirty if any PTE is dirty. For now, let's keep the behavior unchanged, this can be optimized later if required. Ignore the soft-dirty bit only if the bit doesn't have any meaning in the src vma, and similarly won't have any in the copied dst vma. For now, we won't bother with the uffd-wp bit. Reviewed-by: Ryan Roberts Signed-off-by: David Hildenbrand --- mm/memory.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 86f8a0021c8e..b2ec2b6b54c7 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -953,24 +953,44 @@ static __always_inline void __copy_present_ptes(struct vm_area_struct *dst_vma, set_ptes(dst_vma->vm_mm, addr, dst_pte, pte, nr); } +/* Flags for folio_pte_batch(). */ +typedef int __bitwise fpb_t; + +/* Compare PTEs after pte_mkclean(), ignoring the dirty bit. */ +#define FPB_IGNORE_DIRTY ((__force fpb_t)BIT(0)) + +/* Compare PTEs after pte_clear_soft_dirty(), ignoring the soft-dirty bit. */ +#define FPB_IGNORE_SOFT_DIRTY ((__force fpb_t)BIT(1)) + +static inline pte_t __pte_batch_clear_ignored(pte_t pte, fpb_t flags) +{ + if (flags & FPB_IGNORE_DIRTY) + pte = pte_mkclean(pte); + if (likely(flags & FPB_IGNORE_SOFT_DIRTY)) + pte = pte_clear_soft_dirty(pte); + return pte_mkold(pte); +} + /* * Detect a PTE batch: consecutive (present) PTEs that map consecutive * pages of the same folio. * - * All PTEs inside a PTE batch have the same PTE bits set, excluding the PFN. + * All PTEs inside a PTE batch have the same PTE bits set, excluding the PFN, + * the accessed bit, dirty bit (with FPB_IGNORE_DIRTY) and soft-dirty bit + * (with FPB_IGNORE_SOFT_DIRTY). */ static inline int folio_pte_batch(struct folio *folio, unsigned long addr, - pte_t *start_ptep, pte_t pte, int max_nr) + pte_t *start_ptep, pte_t pte, int max_nr, fpb_t flags) { unsigned long folio_end_pfn = folio_pfn(folio) + folio_nr_pages(folio); const pte_t *end_ptep = start_ptep + max_nr; - pte_t expected_pte = pte_next_pfn(pte); + pte_t expected_pte = __pte_batch_clear_ignored(pte_next_pfn(pte), flags); pte_t *ptep = start_ptep + 1; VM_WARN_ON_FOLIO(!pte_present(pte), folio); while (ptep != end_ptep) { - pte = ptep_get(ptep); + pte = __pte_batch_clear_ignored(ptep_get(ptep), flags); if (!pte_same(pte, expected_pte)) break; @@ -1004,6 +1024,7 @@ copy_present_ptes(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma { struct page *page; struct folio *folio; + fpb_t flags = 0; int err, nr; page = vm_normal_page(src_vma, addr, pte); @@ -1018,7 +1039,12 @@ copy_present_ptes(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma * by keeping the batching logic separate. */ if (unlikely(!*prealloc && folio_test_large(folio) && max_nr != 1)) { - nr = folio_pte_batch(folio, addr, src_pte, pte, max_nr); + if (src_vma->vm_flags & VM_SHARED) + flags |= FPB_IGNORE_DIRTY; + if (!vma_soft_dirty_enabled(src_vma)) + flags |= FPB_IGNORE_SOFT_DIRTY; + + nr = folio_pte_batch(folio, addr, src_pte, pte, max_nr, flags); folio_ref_add(folio, nr); if (folio_test_anon(folio)) { if (unlikely(folio_try_dup_anon_rmap_ptes(folio, page, From patchwork Mon Jan 29 12:46:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13535529 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 6316BC47DA9 for ; Mon, 29 Jan 2024 12:48:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F33A28D0006; Mon, 29 Jan 2024 07:48:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EE3848D0001; Mon, 29 Jan 2024 07:48:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAB938D0006; Mon, 29 Jan 2024 07:48:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C5ADD8D0001 for ; Mon, 29 Jan 2024 07:48:32 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9D5C9160577 for ; Mon, 29 Jan 2024 12:48:32 +0000 (UTC) X-FDA: 81732327264.19.1AB1E78 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id E06ED12001B for ; Mon, 29 Jan 2024 12:48:30 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KjeRfVvG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706532510; 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=kPofd6LlL0FntZsVxpMLUzci6vAQKc1aG/cPn5S11O0=; b=qaM2KzSCzyhm3hDTXcQXKYWCQ15XG4L12rsRzrskwqUuqBGKXHTZ+vO9cKxWLeD36ze9FB KLeP42SHu/+QUO0+mNfWx8lgEC12wRrh5PK418bbaXOl0dqFz30MyjM0oaW8VlLEkwKhv2 5+ivAuP0mIf0RPV9VCb2wglrnWWUvlw= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KjeRfVvG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706532510; a=rsa-sha256; cv=none; b=uzo6sqoI30A+nZflPokjq2kgozpIp5hQ4egV7uP/07v/7aBl0NPZBXOH2Op8X5ZXEW6Fav 0lmv8Jn6Av0TTLezT/YU61OExzQ+MDHx2DifMYi47ju9lM8njYduPDzWU9IIdhUzy5s+O3 Ge+c/6FH3QVx0VlzqHb2sDTs5IigA9s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706532510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kPofd6LlL0FntZsVxpMLUzci6vAQKc1aG/cPn5S11O0=; b=KjeRfVvG+5QpX2CYiPT2SE6634umI5mDUdNheSMhDv0jw9AOx1JJXHZTWJwuSTQXpFzU+L 8BUmSoVQ8cOop6J49klZIrAlGwqjDZlLKVZbiyoXzrlWP9B7XCUA0JOxmuZ9WWyC2q/Wmf 8Ec0Eb/dlzQUNIwNa/Lic4sRwMRwQk0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-413-PehoyRVrMfeAXOFdLIlxVA-1; Mon, 29 Jan 2024 07:48:26 -0500 X-MC-Unique: PehoyRVrMfeAXOFdLIlxVA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 898A186F129; Mon, 29 Jan 2024 12:48:25 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CC6D8B; Mon, 29 Jan 2024 12:48:20 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Matthew Wilcox , Ryan Roberts , Russell King , Catalin Marinas , Will Deacon , Dinh Nguyen , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , "David S. Miller" , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH v3 15/15] mm/memory: ignore writable bit in folio_pte_batch() Date: Mon, 29 Jan 2024 13:46:49 +0100 Message-ID: <20240129124649.189745-16-david@redhat.com> In-Reply-To: <20240129124649.189745-1-david@redhat.com> References: <20240129124649.189745-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E06ED12001B X-Stat-Signature: p53bpx78g3e9urrkrsuwn3yih5wxzbd8 X-Rspam-User: X-HE-Tag: 1706532510-456813 X-HE-Meta: U2FsdGVkX1+lhIdQtbTOmYHiUmR5rbFhD+XiQk83jM0Vikp4z971vhN4RDHy9G99Ysp55NyNYNFznCtzg0wYUfmv2l+Ls/ZvP78CGWi/cqdj7YB/jpppG+JTMOKQ6kETIYyi4GC4S4Qu8Rq5u0+n7JxBdojRYgMjmo9AXl2N53lo1NMvvImXg/Gp6c/k6AzqKiCebpQWPUh3sYpC1/mRb1B/Tol98g1XqPxidbms8lGVlyLI/rOpnbAF0jXfLjvRY20rj1HK8SM3XxOOFp6RKXIufa9QMlYB3DK/soLXn6An2tMKLJB4537uHVuUM6Xtxxj58sfrEL/tfRLwbSEZWv+mZBi+aw833iT9e6xXhMCvtONwWhqfhxZRTQtCUSBDSFiHJZlvHwUDSEaZDj+/VjwVp0ct98Fkp2dK9fepORUpyQgbxNeWIR4Oqa/Y9AGlBMnfDdGzIA5GW6msWser8LK7sYAgxGgHuhjaBeT4blip7lH9LZVvSJxZKDnH2jnQKnZpH4N9Xp76/TOFEWGdZJ0F8fI967NYN7lLbu+5Dy9nOcUY/dch+AOwNIXwaBpZxhAk07OKrRa2P3TI53f1b0+hWcraN0tPuhTLY7KqgWWwVkPAaZDCtjx0oufuyfEJJ/tkK2rzTstJL24LCjhBP4mTb6L6ZmFNZpmNiUw/YonracsYycbEEmhrXoqdOkDdgynlzMBOY6S5YqgUj9kPK+vgNDd/8zNzsVqqlW4yqPxScEQTrt3M2smMoRF/WBcqeTpe22fmyr/gycFDe5B6jQypEiTZVlpOR2vO/oUfuQynHmk5VIhGKcQU1WVnNcUJgKx8m3hdsXaIi4ccy2YyWzo1Lgjku9KY2+ansHqLHB8POf6svIHOXx9s5rq+iYxVhV8uFqEKNL5oK4MEddCuIw2VeuAEhLSaHoisoOp0AxHhpiCfgmXu845BpJIpkPdnuAaS34QHkw8a4VNUHLm OoiumphK xtickqf+77vRhdwFK8FhAiooPgVwVbYEsSqcO3OALbvTr8ckQOO+m/9vFXHmKNF90F7qc0ejmUQ3VCGl+vlwaXtxTaWF7s6RKy+McyP/3f107Cc3bd7OifE0aHckaTa+UyQUm96jBYFOei3MBI0jtY07N38NgYwqUJQ8iShvGMH5hM4lL+Gx101dG7hcqu2vFQE6NgTpsZCUwc3f5EV7Evk/NARdIj2qEEOwfxpmv5xm24ZV/mq3NfXNxsnEey31ZX41bgOjwbonKxKETnGvST9tgPw== 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: List-Subscribe: List-Unsubscribe: ... and conditionally return to the caller if any PTE except the first one is writable. fork() has to make sure to properly write-protect in case any PTE is writable. Other users (e.g., page unmaping) are expected to not care. Reviewed-by: Ryan Roberts Signed-off-by: David Hildenbrand --- mm/memory.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index b2ec2b6b54c7..b05fd28dbce1 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -968,7 +968,7 @@ static inline pte_t __pte_batch_clear_ignored(pte_t pte, fpb_t flags) pte = pte_mkclean(pte); if (likely(flags & FPB_IGNORE_SOFT_DIRTY)) pte = pte_clear_soft_dirty(pte); - return pte_mkold(pte); + return pte_wrprotect(pte_mkold(pte)); } /* @@ -976,21 +976,32 @@ static inline pte_t __pte_batch_clear_ignored(pte_t pte, fpb_t flags) * pages of the same folio. * * All PTEs inside a PTE batch have the same PTE bits set, excluding the PFN, - * the accessed bit, dirty bit (with FPB_IGNORE_DIRTY) and soft-dirty bit - * (with FPB_IGNORE_SOFT_DIRTY). + * the accessed bit, writable bit, dirty bit (with FPB_IGNORE_DIRTY) and + * soft-dirty bit (with FPB_IGNORE_SOFT_DIRTY). + * + * If "any_writable" is set, it will indicate if any other PTE besides the + * first (given) PTE is writable. */ static inline int folio_pte_batch(struct folio *folio, unsigned long addr, - pte_t *start_ptep, pte_t pte, int max_nr, fpb_t flags) + pte_t *start_ptep, pte_t pte, int max_nr, fpb_t flags, + bool *any_writable) { unsigned long folio_end_pfn = folio_pfn(folio) + folio_nr_pages(folio); const pte_t *end_ptep = start_ptep + max_nr; pte_t expected_pte = __pte_batch_clear_ignored(pte_next_pfn(pte), flags); pte_t *ptep = start_ptep + 1; + bool writable; + + if (any_writable) + *any_writable = false; VM_WARN_ON_FOLIO(!pte_present(pte), folio); while (ptep != end_ptep) { - pte = __pte_batch_clear_ignored(ptep_get(ptep), flags); + pte = ptep_get(ptep); + if (any_writable) + writable = !!pte_write(pte); + pte = __pte_batch_clear_ignored(pte, flags); if (!pte_same(pte, expected_pte)) break; @@ -1003,6 +1014,9 @@ static inline int folio_pte_batch(struct folio *folio, unsigned long addr, if (pte_pfn(pte) == folio_end_pfn) break; + if (any_writable) + *any_writable |= writable; + expected_pte = pte_next_pfn(expected_pte); ptep++; } @@ -1024,6 +1038,7 @@ copy_present_ptes(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma { struct page *page; struct folio *folio; + bool any_writable; fpb_t flags = 0; int err, nr; @@ -1044,7 +1059,8 @@ copy_present_ptes(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma if (!vma_soft_dirty_enabled(src_vma)) flags |= FPB_IGNORE_SOFT_DIRTY; - nr = folio_pte_batch(folio, addr, src_pte, pte, max_nr, flags); + nr = folio_pte_batch(folio, addr, src_pte, pte, max_nr, flags, + &any_writable); folio_ref_add(folio, nr); if (folio_test_anon(folio)) { if (unlikely(folio_try_dup_anon_rmap_ptes(folio, page, @@ -1058,6 +1074,8 @@ copy_present_ptes(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma folio_dup_file_rmap_ptes(folio, page, nr); rss[mm_counter_file(folio)] += nr; } + if (any_writable) + pte = pte_mkwrite(pte, src_vma); __copy_present_ptes(dst_vma, src_vma, dst_pte, src_pte, pte, addr, nr); return nr;