From patchwork Thu Jan 25 19:32:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531542 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 1294EC47422 for ; Thu, 25 Jan 2024 19:32:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BD27280007; Thu, 25 Jan 2024 14:32:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76DC2280004; Thu, 25 Jan 2024 14:32:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65C65280007; Thu, 25 Jan 2024 14:32:48 -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 57580280004 for ; Thu, 25 Jan 2024 14:32:48 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 34744140D9B for ; Thu, 25 Jan 2024 19:32:48 +0000 (UTC) X-FDA: 81718830816.05.EB5B46D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 76AF6100018 for ; Thu, 25 Jan 2024 19:32:45 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="WYDWu/02"; spf=pass (imf14.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=1706211165; 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=82AmjG/O5udPRimJWVv8/kqN5WdZj3aSPBj/SjaK3u4=; b=m8zRUxcV1D5ABsPiW5BzXAhM4HfSxIJBUtkN8xewh2YVdeihXaSYnFd1jMCoBtlNczrARe p3y2skxdn4+KfKOlaO7EcOaIUNDPsINWcILwpjfogkT73eAV2OZR7ntkt1xwA11cqWG7Wu WvR+WFkNnieABIlYBQJjJQskHLtgEHM= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="WYDWu/02"; spf=pass (imf14.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=1706211165; a=rsa-sha256; cv=none; b=cowlj8+QCMf+KTZPhYrsbMB9NmFgKm8GGMJdQrWWA4wNpyX+c7pWa8UpwysM/KatOj5LOY 5IkciiAFosJ0yykHc138AXuo8DzNmrgUKCzSAalmaWWigcJyAt/asqqD7bH4iWwBImBdbA UJBTYFSkuvse5nato/W+vrxtAY4is+0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211164; 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=82AmjG/O5udPRimJWVv8/kqN5WdZj3aSPBj/SjaK3u4=; b=WYDWu/02TD2ILhX4757Wal76HqJSKpOk2/A5kSi6jYrLyt9z7KpbIxsSwBOldV8rP2RbGI Dj1/nz6nBlYfBVaZ6/R5cyG8lxD/ME4NAsOfrcIJb9tghAueaHZ1A6vYvCuxdFShS19eTu F61DN9RubXCBGCRkL2/ASgwnhJys+qs= 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-581-J0yUPAt0OCGNPncPGz6sEA-1; Thu, 25 Jan 2024 14:32:42 -0500 X-MC-Unique: J0yUPAt0OCGNPncPGz6sEA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 EFA1F8432A6; Thu, 25 Jan 2024 19:32:40 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81D45492BC6; Thu, 25 Jan 2024 19:32:35 +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 v2 01/15] arm64/mm: Make set_ptes() robust when OAs cross 48-bit boundary Date: Thu, 25 Jan 2024 20:32:13 +0100 Message-ID: <20240125193227.444072-2-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspamd-Queue-Id: 76AF6100018 X-Rspam-User: X-Stat-Signature: dq8gebcdu6cpsi4184ttr1e9m4iwkqx1 X-Rspamd-Server: rspam01 X-HE-Tag: 1706211165-970915 X-HE-Meta: U2FsdGVkX18d4e9Q+2mMQG6NW9/LZbgC+JifXJAIxDyyxscVwErsqcNj239vCthUjx9U4hScshMb+2sbgDUYbSHryI5kLyi1w0UNtGyhPQj9IQGz5BGqsLtm4XibdYNAfI+ar6L4gzmG3vQ+d2KahlcZJUDL76N3ge02E5dLEIc95pl4Dr6Owa++QJyy+swNt0cxWC1czh5T4ftj/yU7UPnO+K5JY26OXNtJDiYQdrJPqk/YZlDGOff/ienUOPc3EZEra/rdeGgJ9M6ovd7p294dL83U5oHD+0cFuqlj3NyiV7S4xsXqwIr9sTdXWoHJrM080tbGza66HjvlIYTc8MC6+6UVgVagu/qtk0gBYCjyLdOSyX79H4uxjiucwErJ5Mwl12zHi3u0DqReMW6URdZiIpqc45H+ZoYHbTmTF53gux4X+aleWPSg2zaI9BhBR9TTBIf3LF7YLmyYsVeW4YmpjQGIjtP8d41zTsRFCcGECbLR85ms5c6MpNS3tRwBOQ5lMhmNgIW1MKdDaD3XUyRg6hBL2HLlrHvcb2/1t/nkKURnnHvgt7MNWgfx6m01+98zn1p5GZtbGlQOWX1aoW6Phdjj8VYIxq15pSFjeohlbaYRAeD598FxAxoV/9Z6gZCrA3iCwjPHFXZYxzuywlyEMdaU2MUdl0i4BQRqxaepHmn8YfOgZezZvVRHqpWqrI+8128hSt32328+N2ADZbwiDZg7M9tiHr+H2iDR9iBSo1svGezUKZzPJbXkw/AVmSV0AD5bLktkiyFNlx3OfJZka/x5IkoFjb9dABVPKo8BAvv4TY4MMj8jsGnsQXryDVcNZ54PxNccItt/q+l5zgBdTG1twaKn/wmScAlskOFppOMwxvTTl0D4raTWetIfeWvtzmVxCSUaJhYZvRxOOPrq4kZgevnGbSYeEgCD5vYKyEIAQe0YLL6FfTTLlf/zhxWCTeMfez+HlTw+jDu OI8CGZuG T0peKOPzRRb2TY77hNovka3W4wByGunNLmiD+KJoiypdmjEZkGzH78Xo/i5erEgYFebjnWQWIjLvQuHEeSV1iNKNxv4Un+2LU0Vc9RhuV5jqslRKjHRiynX9wFEaBK9NHz/cNAgedfbk7lJ8mOihzN2nGQ8XzgUklZmTzeA5PItSRgm8Tuuubjidumy4Ub/F+1HwFeTESzC+xZNfffZXhwxj+H9CxjeL61xCWMVxec7f1gYu+JnrJQnBzDt/HtYwlyf3BYDztk9G4dyhNbSNAFSAl/6tmGpfMiljg8Lpia+smphcY+ypGdKcM0CLXjucrQhRkcIQmV7Vfl6L7GpWOw954NQ== 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 --- 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 79ce70fbb751c..52d0b0a763f16 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 Thu Jan 25 19:32:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531543 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 E8073C47258 for ; Thu, 25 Jan 2024 19:32:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C25B280008; Thu, 25 Jan 2024 14:32:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5725E280004; Thu, 25 Jan 2024 14:32:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41345280008; Thu, 25 Jan 2024 14:32:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3011B280004 for ; Thu, 25 Jan 2024 14:32:55 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 046A91403C9 for ; Thu, 25 Jan 2024 19:32:54 +0000 (UTC) X-FDA: 81718831110.20.4F2A710 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 420E040011 for ; Thu, 25 Jan 2024 19:32:53 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EiqCx66K; spf=pass (imf01.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=1706211173; 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=PQouyLY2O+uNJNW8rltya8+XjvAPXlL2xnyiW/c3KZ4=; b=OpmszxzX2bxS4BTWpnU5GVZinDEoUuca4bApU1IjimORQAKNFFeySLpfwgusA652XzO9J2 fiC2OeUXu3dw9PtvN7xbyJivMAOLzCGQJ5UWV44f4KZ76Mn19xU3shn8I3HjgSYAWQdB12 E46ApzdRWtiyqXVeZHf1zIk1cDC/w8A= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EiqCx66K; spf=pass (imf01.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=1706211173; a=rsa-sha256; cv=none; b=MOZIseJPkfBuc1A6MYfIu5M1C7uaIbj97kdvXOoNstNv5l3wr51FZ4BX6XhOPw2K6GdIP9 IburgmQY1mXFmaTPzUWvTmUyGVqONmzvH6H+oo3qwVveggoatF5FUPaAxFE9sPKzLhxPIZ P/Pkhw3lAbVs0D36shG2DzamVt+S5aU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211172; 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=PQouyLY2O+uNJNW8rltya8+XjvAPXlL2xnyiW/c3KZ4=; b=EiqCx66KLewv6UHctfjS1nW6UG7qTcWdoc6Z0OLp2hfJ5j3CqAWUOeELKK3SB5JNe2wKQ4 1xljly0JQ7WXWfzIcZn78tX4hY+WZtgjEerPw88L6/rYorHtWDdD/anz3zKt1UsH1QeqmT CWymlNnIXHVbjL2orVCBTDGXQ/B4gmU= 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-606--28HdBjrN0mHVjdOaKldYA-1; Thu, 25 Jan 2024 14:32:48 -0500 X-MC-Unique: -28HdBjrN0mHVjdOaKldYA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 AF58485A589; Thu, 25 Jan 2024 19:32:46 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37002492BC6; Thu, 25 Jan 2024 19:32:41 +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 v2 02/15] arm/pgtable: define PFN_PTE_SHIFT Date: Thu, 25 Jan 2024 20:32:14 +0100 Message-ID: <20240125193227.444072-3-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspamd-Queue-Id: 420E040011 X-Rspam-User: X-Stat-Signature: m7p3trfx1mcxuyomhhdg1j9gxpqo95a4 X-Rspamd-Server: rspam01 X-HE-Tag: 1706211173-961077 X-HE-Meta: U2FsdGVkX19q6YMB2Pl0A9bxkgfoMBpgvCfSzzNdZAgqFFEJTd86qW6Ce6WCXBOHd3Ry9yV7jGt8lTTA5uUULXF+M8x0wwYJmOmNCUZd4h0hQcoXEKPOrb/mcqOvjghJgBYk1Hy1RzlWTPpPyyLsk2I/U3Y8u686/Lrk4Oo5im4dsiM7uYl0z01zFlOPzUlD2fNOLS1bSpfNzUWnCEONAboa45EKVxBl+/l4UqUT7DLFjQdLvLtQbJdMPbodeHLzjajbFiNggwXC7riE+FuHj7Wa5Z19uU21kcnrYqvs/5q/hMaOX9xn2ZHsPLf4oMcq7JfngRFsE652L3YJx9ZANkPbOWxtE8XWLiPz8974p8DNVdWrH1Fy1+TX4F/DQ04FWpLKb6ywz6aLJbI+njRbGujoNr7ze06q2fbGPqQakWQVGStRkROm+oVJ9XF1bioZdgWTvjxh8QweRkwbhiOUlF3ljIA7I1zXvNxMsdXkytmioYKWotWPFes3lnDTF0tNz3DRQOlhXIJ+9h8ui+OXHxjYXuEYmOUArSURjy7yV5K43qksDjN7rCwlRMdnvtfo+tCHOxQEbjGAUg2PjWWBkFrgTuBQaO0/WmWOeuYo8BDdEccXv5AQaAXdpH5GZ4FEIStAb2C4R+KdBlRjEcWsct8kZQPmW+PkQiFA/cual6+3Hi+t3K1ebA46cQJOqqz5b3mza4ZdLjlyXoOs8+JZb9onhv3w2wjO/XqN7l6D7G8cSYJ7hooyQ72E57dHPYiOTz7rIa05Nwh8d+9jaDf8RzK/O7uappIqUlrsG6baDBs2eYNQLn2aO5HNBSD2WYLVAY1pRBEEzM4+/11xYX1J58DTyAwTe7EtJf1kKD/cmk4L8VLjvDTpsOXt5QyCPV3Tw3JnjU3AWK+bbO/vlOAWipZBACXg1ev6mqZARQZeNcHHWhE3HDD96bxqIOspcFWH8Qb5d/rjy4sd0IBbC4Y ouhKpbMS kipUHrU7hzxk+o1oTgaQ0eir0Qq8u1a4HyR6l5cRIrBDeKO2l25Kunclq+o/jsHklE6zj9YA9jhI7NF7yPkBXdPRoXEmJh8kRzr0DEAznsZY/mwOoYU76mCSJayvrUo9ZJUU2Q/7ovM3SM/OJvz9N8NfbHLKZ8+miYD0xa1bVq6rU1VjKPuJqRhy5WfNCAig9st7bWSF5nERJJxupsIBZNijpjcVGYVro6a2r 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 --- 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 d657b84b6bf70..be91e376df79e 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 Thu Jan 25 19:32:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531544 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 2A7FEC47258 for ; Thu, 25 Jan 2024 19:33:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9937B280009; Thu, 25 Jan 2024 14:33:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 943A4280004; Thu, 25 Jan 2024 14:33:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7BC73280009; Thu, 25 Jan 2024 14:33:01 -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 6A9AE280004 for ; Thu, 25 Jan 2024 14:33:01 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4764E404CD for ; Thu, 25 Jan 2024 19:33:01 +0000 (UTC) X-FDA: 81718831362.16.13716F2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 95F5718000F for ; Thu, 25 Jan 2024 19:32:59 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Jun5ephJ; spf=pass (imf24.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=1706211179; 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=yJs+mcURKSPmR1cOyRG5Auy6AFvJQWxP76HaETvMI0g=; b=7MJZcA4DDgsboMqpjdzDkbQ/XCgpf0qxR5f3eRmlhtYnBWcfzfHa8qxk1SKU5NUcVMBG+Q CZcPOXxZhmwXHl4mQXyaNrQfxrM97ApuCdMpMBea3MTInWSbk/Edu8U8ur3VrH6cq6QyNp F1Uuyl/hAqav+rsKlS9x8+BC6GER4pQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Jun5ephJ; spf=pass (imf24.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=1706211179; a=rsa-sha256; cv=none; b=sfF1a/3mx3Sa6oDCJz+mX2v26OxSu+OvFaCBWruIdpnAGaIYwpmxrydbtMfcIreKQ0NEdP FNUFtS0AjRu608+a2YCQiIaavJ9HN+EnP0zY6ozMGfaLmGCa4eM41lheTcU/riZgQT3QlA 8N+1h/3/P82uKrFOZpjhiBl58bG/vOk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211178; 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=yJs+mcURKSPmR1cOyRG5Auy6AFvJQWxP76HaETvMI0g=; b=Jun5ephJIUUfTvzQvGMGjJfc+19qoVhRGTInnwC+l/WkDyC3+9IV8qC+HlhhJum7AAf3jo 0IQVm8vIGrnJQHnOBM5490sjWfyPeWQF0IaMVvAsgwNXVpisO3+ndHh6puPN7+pBZKQ3ar bwP4CX9oSTMVjofRkTXiyRmzNzWaKaQ= 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-439-7NVfgMTTPOWOAzUG4yyD5g-1; Thu, 25 Jan 2024 14:32:57 -0500 X-MC-Unique: 7NVfgMTTPOWOAzUG4yyD5g-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 111D93C025C9; Thu, 25 Jan 2024 19:32:53 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 359AB492BC6; Thu, 25 Jan 2024 19:32:46 +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 v2 03/15] nios2/pgtable: define PFN_PTE_SHIFT Date: Thu, 25 Jan 2024 20:32:15 +0100 Message-ID: <20240125193227.444072-4-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspamd-Queue-Id: 95F5718000F X-Rspam-User: X-Stat-Signature: cgqpxhmn1k4d8iy5w6jaqsbborcnx9d3 X-Rspamd-Server: rspam01 X-HE-Tag: 1706211179-783950 X-HE-Meta: U2FsdGVkX19H++G1S6FM7cFWZ6WA3BzacfoA6azjqQmmQkJterzsB8/xFN/huIyjAfx8vezCYtMAIuEfxdTl+8yhcMGiXc+047QLNgSEO5SMTrKqCmDwHVIh6hpu9O0qvzhr8+Hi3eKzTrXZ11NFlQtFF/Ych8dK4+jf8sqT5LVocAWQa3Gt5KjswfTsFRsBgx7pqC40z43OnH2Sq4VgIbYHnnbsNO/nISwTjV11SQTav4Dk6ZAlFTyoc3bE/F5EUDW9uGtRr/Tmz9DPbeGZhrtLXK8iXRQv2Ped1ovJJSE6wt8trvJyTUshXUeNmkZpv1b74pVOtLgvXNVLyQXKpMKlH7rTxsfetoj8bqyeEF4zIoemwpQMZfdB7OtHutdyGFkHpGhIiW7LqITimFNtPPJcNgPoEG5A2De00+IhaWrIXSPc6JsFYYxDHvsOTHIwMik8YexZHkeosMIiQkc4EBKp8xbi0YWWwHdmDZlBpPpSTh2nvoJJIKOLSmSnrxFdQzIF8h5BnyLE79vk2LCWIFcb48z/fHWAy00hOjHN3ss9uJ0PRaQ7f0oFNMlpLD0leK1+NMtaVlYSMy01U8mLa1T3nGV4o0oY7b14X3dmxW+h/1Hh27lNsLMffQTyJMIan4xFgGBGQbHhoMEokxn2mnIG0NReEHzOB6PWHDZsxqFiuKMtbDlGdPSVHAuwAOTlIU+N9OHe0q7j5Hh7OxdOmqbv3YSCOzr2nhlnNkr2CNHLzdg6asSOfARIQSugVMk0SOBPsDRa+M5aQQiml+A0YV+ggG92sHGItag0n5KGXShoXIOGOdVFJc7UT1fUg3lwNQK+zs10PsMV0HXlKE9SDFZ1yAINAffAo+CxAjPElgZ/JEOWvX3ot5FfkbQ3E6n3QspGG0MCDODlNzFM+sdn+gAUM80RjAV7fjrq9kLoVXP4Golg6UD3XIzIMgPLv4F4kxnBseMBHHnaQsS1HLF tzvnuYq9 y8rrXYVmdVahDTp9NJHVVqA5/MdwNar6LRyEuNMBPwWmnNCSQw9hxmwP1G8NpO7x9T9e9rY4Gy59eBFdRYGGgRIduuQxdXtuG11AxfNVhoTSLp0cgN15UWqtiq94iwuAtTCjD5Hz1WrhVj3ht80Vi8fedwz6M1etBgbxK4lk1w540OCPUyzBkxi8GLgDCTzDVFHIJSagnJLb4IQoFNNOusk/n8UKehxsCpXfd 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 --- 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 5144506dfa693..d052dfcbe8d3a 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 Thu Jan 25 19:32:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531545 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 05F69C48260 for ; Thu, 25 Jan 2024 19:33:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43CB628000A; Thu, 25 Jan 2024 14:33:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EBB6280004; Thu, 25 Jan 2024 14:33:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28D0628000A; Thu, 25 Jan 2024 14:33:07 -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 14409280004 for ; Thu, 25 Jan 2024 14:33:07 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D6D001C0ABC for ; Thu, 25 Jan 2024 19:33:06 +0000 (UTC) X-FDA: 81718831572.11.2D3B178 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 11394140023 for ; Thu, 25 Jan 2024 19:33:04 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WCxt2AfQ; spf=pass (imf23.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=1706211185; 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=xoDgk/IJJhN86dQmOE0uMNXm/1RQ9pxzapPsVBDs3+w=; b=LhWsMV4DRpU9CF8RKbJF7cc4ZmitSwZNqQSe9XwBKs2lmxTaTa2pBeKhD0rsfjmD/vvtHK bqzrkatbE3LoJryown1AKaAnQMMROmwspV9U8D9FIeVPOHvR2DeAKh+eF/5NTItA1eUYiR w51XdUqIn0fi2rl4alFLhhW08RCLBIA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706211185; a=rsa-sha256; cv=none; b=KuprJGSUj145Odd979ddy4rQnl7Itc31Zxi+Tf6GrMWI9PkUzJqJVE0QBnWOZAVQGb8T59 r0HgWWF/OT6EvJtNfEwL9vaGlJE6AU3EO92W+t0/NfaW27dmHS2/UGPcOI4+8i1ARila+U nIZwVxZJLuCEIuLTJtDsonwEV6zhI/g= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WCxt2AfQ; spf=pass (imf23.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211184; 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=xoDgk/IJJhN86dQmOE0uMNXm/1RQ9pxzapPsVBDs3+w=; b=WCxt2AfQPYkkwLOWTzppqMMw1wQbSi2PZKw4pGPjJcRIPV0THavFgcjVbNE/vxiSnzYuwr jGzuytrE6rWmMAxDcjZADjVgdFNl+8X0NrdVVmXGxjBmQXIZaHFtJnXh4+3LpGkUksE+8m +vajkG37F6X6pTPZGUKEFjJiISIUbbI= 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-587-Hc8ijM1AMhqR5PNxi6OGOw-1; Thu, 25 Jan 2024 14:32:59 -0500 X-MC-Unique: Hc8ijM1AMhqR5PNxi6OGOw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 F19BD383CCE3; Thu, 25 Jan 2024 19:32:57 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BC6B492BC6; Thu, 25 Jan 2024 19:32:53 +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 v2 04/15] powerpc/pgtable: define PFN_PTE_SHIFT Date: Thu, 25 Jan 2024 20:32:16 +0100 Message-ID: <20240125193227.444072-5-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Stat-Signature: 1fdxbygu63dpkjiiribjksj78g9mo6ad X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 11394140023 X-Rspam-User: X-HE-Tag: 1706211184-416193 X-HE-Meta: U2FsdGVkX19wtBzucYk7tdG+0WXdq7cYqyH1MSTW1xO5P/iPcYmE/48HsdQPCgZnc9FdHvQs1tnG0eb5YvWplHgzabtglV7xEGylWjFYNAYgJbLDltpw5OoAuqcOQGhM1Bl6+0ZO13N4fey452R1jhE3CGo6Xc82jq1k/m30i4yaPbvAGVU2iVCVZmzyr8SXm9HAcPZysYlihbcbmNNWWMKp/b9CbRu4qbt67MhmiQSGlrFk9aTyhYBJY3X/EUt4S0elXggfC55lF8s112muOUoi6f0/f+2fMuQHEUTAnE5rilJ3MBan5hRT4GNcM8ZSrZezvHIAUlfH7NyHK41AzhZiuy9WgY4Pe5k5CZe7zy27XR6JjmbEvQA/t28pUGtMcc7MblST8QYB+QM22sMxAFjB8PO7t6BknTYIVemIRnQsqk330yKL34b+XKVSvX7BiVHi2k96LHyXuQJssp7SIoE9ZNcjPZ40wViPhBCspJFXkwcgi2hgy2fBI9YjAacLxOInAmz+ma9onkxy8sAPCMbhF2qxhXiPgUo8y1TMeiqeifgg6l+RrwIfTVaj7q+FZxsjsl8Y2FC02kzGBI1UFd13/5iVSt/295ccIA/LVL8u8ps0T9y2wvV5/bCj4Oti+90RapaSh6tfwKadS19zAYe03pB77vNcD1dPgfIoVHB2v91Ye7Xu+YAhnegUCycNph1qcWzjaTw2LeRuiosAhE6QdYhBteHTVnj3rrPXwAoqHnxWc9k2GB/OHZTDxR5FuowvZM9Pl/7DIJVL/nRGKq7xCS5bf1aaXCZZ25EBgjE+0tS55swNZ/lqHEUd2XTvpJmc9NytofFBYjgLxBVIjYEY7C6lIIlNn7wbkCgzdk/BKhTqVoxqDIrG3PZp+1NoqRUf0zfS5Is8LT95KXJHb07kcq+92w0QNXtD/qi/zt+uvAnCzKfj0Sh2YKzbxKI9cwcV6HW9r/22aNiNrO5 bhk30PJ2 S73yZFNjm4Clq91Mq2p696rXm+7mvDD7Xus+gECMS5GzYJvUy/Dx9i6c1Ozn69LQuQcNmeueSUqfr/3abDWhsuhCp6LkEM2TR4sdVFKTDnsdSlnY6xzBKjtiMf1BUuah89taUlkkk+kkLd98SS1yhu79UppVRAdxnQa4C/y2FLTsMSJd5EiVswm7CDFe9nPpgX7vN/t/kDaja8SlfXmAG1fFoOUQd8HAeDwsY 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: Christophe Leroy --- 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 9224f23065fff..7a1ba8889aeae 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 Thu Jan 25 19:32:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531546 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 A0C5BC47422 for ; Thu, 25 Jan 2024 19:33:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 303B528000B; Thu, 25 Jan 2024 14:33:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B451280004; Thu, 25 Jan 2024 14:33:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1548928000B; Thu, 25 Jan 2024 14:33:14 -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 0191A280004 for ; Thu, 25 Jan 2024 14:33:13 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CD56F140B98 for ; Thu, 25 Jan 2024 19:33:13 +0000 (UTC) X-FDA: 81718831866.21.8D84B52 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 05A90C0017 for ; Thu, 25 Jan 2024 19:33:11 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NojYa8rs; spf=pass (imf10.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=1706211192; 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=JLkdB3aR8b5AzZf8mrQLfb2UlnHWewFM+noupjKQsYY=; b=A6KqBDBWQD4u+cnfalkV0uspbGI1fetq5plapbalVM2+ldoTWtq6nV5i0SrvvBO1NtYhzX RKLZquPwAh0k3nnlTnxXeybqLsxPy5rd8cL7QgyJOWEeij2QF3WEPUk6me/2gLeTZgg5Nk xufQLGw9QKunlerjW/0q4jwz7WvHlw0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706211192; a=rsa-sha256; cv=none; b=3iTsxfroPszPay1aJloj3uWK88dIo8RNskoHx6ygIleHMi7FaWXz+PRLsvP4AZp3Qm3gSl SFA8ztcoTEQO1mOnpxzNuveBRD4TbG3xhxsme4abKiHBEtTHKSeV4SG09yaH5lvKd5Mudq jN6QEOCN4s/SwGbCnRKUoE7wpalQm+E= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NojYa8rs; spf=pass (imf10.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=1706211191; 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=JLkdB3aR8b5AzZf8mrQLfb2UlnHWewFM+noupjKQsYY=; b=NojYa8rsnlGQpAElfyYOesIjD5LETWGFcNKsiEpQUCyBzlkNEhTJsHVooaEw9ssbekUV5C nKj5qPmaEhenzPm5vXRLouSXwt5k8CEiJ+vzKkkc90iI3DdcwGxlKPgfuGCldfdrIgPtTw B+8iqA+xu/b220WkynRoazHYLoQxLcU= 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-140-gRvtxHOMNz2NEaPqxmRHPw-1; Thu, 25 Jan 2024 14:33:06 -0500 X-MC-Unique: gRvtxHOMNz2NEaPqxmRHPw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 045F81013673; Thu, 25 Jan 2024 19:33:04 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59F4E492BC6; Thu, 25 Jan 2024 19:32:58 +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 v2 05/15] riscv/pgtable: define PFN_PTE_SHIFT Date: Thu, 25 Jan 2024 20:32:17 +0100 Message-ID: <20240125193227.444072-6-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Stat-Signature: 8316kkwojsww4rq686138c9d44oz46kz X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 05A90C0017 X-Rspam-User: X-HE-Tag: 1706211191-323848 X-HE-Meta: U2FsdGVkX19QVRACp9wyIbLQfiQE5sKMZP8Dv2je9ohvp6FqxOZVCTU+qW7/Xh7n2mq3gBrTepUWHApRiN6+5VPeHLOEqQnWvJabZYEaXcFB464Kezd6sZBTMluOZ05QTxGosPyRFp75xGxD/c8nP95rTFYT6NA4EWNpwdi1YtzZNIhhzCk5wRXuRB8aTZdJW8iW507x7rBknTybFCIkPAe8v3HNRuTG/CDVMD9eAVvf4uHX7/IED0s3DpW2ZqFCJl5ms9ZOhsSn76xXXmJNFVXThkuWRfi8Sywij+Z+fEsu4Q9k2o7MsWpTMNx1Wn7Kc9ZeubUWUHLuzLVoJA5J50QVujgV+kcc0jL8Cq7xMUGEY7hXzYPf811sqEXKiRcP5uyl7RIuix7Id8Tfq4Ev6Qdm+TRz2LX0jCOfkabb51kQyTodtP38UwTza43H/ax9SnuG2nqjzwIyPM2Z70cHyxcULIGOO08MOD0bMVt81BAlydLFuPXqtnRJ8YT9006Zq3dcHuv2ETYwqn9m/VaoO3oneuJ/V4g7ZdPoxq3r4iLtQZ/8CjL5jc62vJGBbOIKCXgvgMBj0F+YmoizH+FWeTaEy0WTNpcrAapC9k7sQ0lssDLLrjdA5jiJ7Rs1lWDHEfCeRsak8UydzSCS6SvcAWC1/NPi0ATkgUip5odhSiVwAUxAFAy8QEgfBHuw9d0hqC9xSxbIRccm+lkmOJbEL6u9xONiGRUEjlxr0rpXolPXZYRuzyiA5pcg8pw5YG+HskjOb6psuH6rroLaazqfXi5UNsdopltuuR+Lyh2op+yCHlHdWTkKfv9AcpdQwljv2QH82uneSRfjT7lEytN8NKCRqvhGlzLNzrtPuSftvpeHLDC7wjeQuA7RNXQRYHcfS6PRB71SFKJpoZq2Gpvhgm274nItCMRNTiK2BrdOFrZAan6S0+xbcCEiW8NhKq7Ie383NjIWWxQB/IURVDm ea74/SPw NIW8POtuLFMo9Vep5Z3Gt0pQLBdHRgUR8ZUR6GwD6GIufrzt79DZXgtn0KNhfEuQUEflYsqbvlRduiaz1iOSBCU7r50QIIb5RQ19WZTayyHHdHlJ3+fyRr3fFXsdhqhKg9wTk6ZiCWMRSK8+3zZLG5yrCp7EtIQmowiF9BgNhEJpNsEnwEK4JlmnED1xBElfeL+MpJGKRXcEZgz/ZKAPld3ywjVUM411wrYX9kgjZZj35k+YkzEOm0dhe6rHg2Pa+5lVMdBzT/Z0lDussPzjRnhit7w== 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 --- 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 0c94260b5d0c1..add5cd30ab34d 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 Thu Jan 25 19:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531547 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 7D1DDC47422 for ; Thu, 25 Jan 2024 19:33:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 109236B0071; Thu, 25 Jan 2024 14:33:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B8E728000C; Thu, 25 Jan 2024 14:33:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E73A1280004; Thu, 25 Jan 2024 14:33:17 -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 D369B6B006E for ; Thu, 25 Jan 2024 14:33:17 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AA9311C0C50 for ; Thu, 25 Jan 2024 19:33:17 +0000 (UTC) X-FDA: 81718832034.12.EF0D6A2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id EEEB61C0010 for ; Thu, 25 Jan 2024 19:33:15 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E74NMjr0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1706211196; a=rsa-sha256; cv=none; b=Ra6AJf+lBU72iBx1AN4g7GTSSYvVYnlIY3xoDpYEEE5KN6O0NdUrad2mPlPUl7G4QJgFFY CDzvGvYkNXyL3bwRWavETMeu/qKcucC1IOAz86bT08olMr7KHwHJQ+5vABk5sAicGNBCTY e37K5P44IvJBuA4gAj+Tvdj2rRqAdHo= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E74NMjr0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1706211196; 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=HOFElmHyy38IK1/HVpenWSDjKK2a/ajysR8u0SxNo40=; b=8QXtRUBxsDlyUV6XIKMplCVaUpMmhfO0FL3G2aQEk69dtoH6RnlWI9UlSRQu5oOFPpDvOg YZJKWiale7EY5umUIAZwGy0EjMj16mUDzg0L2ZEeUpVP3ItoNMw+HKRKJV9/VNYYXruGRM Tx753oBuz2ysawCdSQYn1fmCvRds4oU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211195; 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=HOFElmHyy38IK1/HVpenWSDjKK2a/ajysR8u0SxNo40=; b=E74NMjr0bMiZtzwo03lC+5koX1sAFA/zjL3NoWlDftAMwKlaOXQZT/Fl/HkttiIWm6JbBy HjxxDDf1KwneBAhVJf4Z3GG7bKfJYALiWm+2AMzvxeFHCmRD7QUwPhgkeBa1OFE7BKBvKW AyqRYXQknsj54Nc3jhG10dTY1K+TCrw= 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-213-Hevm4ONKNRujmourt_4mew-1; Thu, 25 Jan 2024 14:33:10 -0500 X-MC-Unique: Hevm4ONKNRujmourt_4mew-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 708AB8350EB; Thu, 25 Jan 2024 19:33:09 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 644EE492BC6; Thu, 25 Jan 2024 19:33:04 +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 v2 06/15] s390/pgtable: define PFN_PTE_SHIFT Date: Thu, 25 Jan 2024 20:32:18 +0100 Message-ID: <20240125193227.444072-7-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EEEB61C0010 X-Stat-Signature: jf4a36a38t6341yht3a8wgpy65rq3ju7 X-HE-Tag: 1706211195-329988 X-HE-Meta: U2FsdGVkX19pfPlUs8CMnri4rAh27MVJWgZs6U0icqezzBhp2IQf+neASJG3yMYZ2kM2dXjbj0dz+wDEhvXTYUlyrTwjXxskJ52ub3gMWaBTKMoIlAyVYaWIfSkWi6z29Xoq5n2HXnhU1R0MTHooXt/vd1u+eRnGU0rE/u5j95PK3ciuQn4mEKWcPO0T7YoB4lwQsA4xRP/XEBS5RtFF8AYXDSad60sfw7sqWwjD6ZQ+bhoVHUMeEFC5GhRx505M9UexTCM/XW6gm9MtsbqQTF55NRnoIvytZiMAvcn02mHA4CymUzIRo+1RTkMLqkGTJUlQOlX7cSsAdKifrUg6LY4079tg91RN5b2+ey+ytnzUxisrFcTfhqUlC03IiRON86RGW2R0NoRWUhExyJUiQ4svP2kxDmIaV3DIplFKxuJzlydJiXIOmAyA3wSzd9k5dsk21Y7OyQlFIcx6WPfg52JSbh9nbtVGreMyJb1D2WlqGeCVXyr7zID8lDQ8qB4KX+nWs9cp1hTFOGqlvOVlizQnWNAZerY99F2wqV2LkeOheywOgosO+aWhVOHMNydSMJX/KtWmfm+7hpJlgCwoaQaIGAAG8o9BfyuYNnRjF1nVk8PMRbK1etMnkl3xMIJtNCeC3cYmbAm+oIVbP6RFR4+rNqak4kBN9OgEqKKwVqy3Wk++wCklMQ0drR9xTdbyBi6tmG+ab7Mc0wLov5mahOdA6QWVTdnfi4NQPsFN+Slqu/8yxZpamaqI060kHPWat+NMXyFIKDa79r022tCmWx0ac+uFA/jjmeszwvnHmPsq3izCP3k31yV6pVbD1n/OW6HOt4WrQWfsvYbPie+CryPEs+7WZOSbLvAoHFbuPXUyQlHy3vCymHVHEENpli6wB8s+RgkCn1bN18yFJuu/why/ByZ+9t7Owm506n20PUFnARX2G7gHY0lL/QRTP7IsRjl9Blall2ehW5o1YWd 7F2k2a9F Mf7wDlxKLLQIr3Ds/cLu4BvPrn+tCbKxKfSUG6NtaPHe5riF3fLHfNrAWfwzzuHZPfqSCanDNXS/6QmtUWEDZAnNhK9frIvcTico05XdOtMEzHu1KhkUoSgg0nN955LUKvH8YK/40eeHKYBkq069gtEcQMhpIeiH0Eh+skyZgI9UNYNed6K7GMJDIHYMPEfzha/wcryDyu85cN/LS2wZaMmy3TAyo8Efn6vsm 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 --- 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 1299b56e43f6f..4b91e65c85d97 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 Thu Jan 25 19:32:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531548 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 33123C47258 for ; Thu, 25 Jan 2024 19:33:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8F1A28000C; Thu, 25 Jan 2024 14:33:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B3E96280004; Thu, 25 Jan 2024 14:33:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A06F328000C; Thu, 25 Jan 2024 14:33:24 -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 904CE280004 for ; Thu, 25 Jan 2024 14:33:24 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6FC6580E67 for ; Thu, 25 Jan 2024 19:33:24 +0000 (UTC) X-FDA: 81718832328.22.0536DB8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id BA4F380025 for ; Thu, 25 Jan 2024 19:33:22 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GkikgdEX; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.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=1706211202; 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=AR2hQWewzUwvICKUVjlsr+tzr4A8u7nsZckmD3jQawo=; b=Np861Qqa400iNNnh8GPS9Ge+4l8ijHw6ldJJv13b7FVmsE+3//VbLX56WpWkB1J7elUTVC pT0RvDKGqD6qVuR/HZiIsXYlg/BhUgl7+UhNeds73usnQzY0Xa80SCi8lpVC5Naa492rMu U9WX6i1CLL5G+ECI5LKWjezLe9NNIXo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GkikgdEX; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.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=1706211202; a=rsa-sha256; cv=none; b=mUZ7OmTo4YUe2w8I4mdR+xI7cdC5mmjNwyO2d5Jh1+F6aoGIvTXs8quHpu7ZC8kHHTSBzA Ej6TFBPgQD4J22bNDSyLhv8ifSJG2pqNXID5JTjP9Uo7u7ccIXgny/kWYvhQ8RF5lpy+AP 0KG301I1s+B1nDIPEvxnxNan+10uVQI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211202; 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=AR2hQWewzUwvICKUVjlsr+tzr4A8u7nsZckmD3jQawo=; b=GkikgdEXW4sBM2Ma/ZADY9nwo7Ku4DjN++53HaKq5ZNwertCDT/yC6JdmwN1FZExd5geJY 1gbhVZcWNAC7PRZ2qE4lQ6vxWneBPBmosdbAYx0cw6oIcomaP90sQIla3SA1+kguXe1lrz YpsnKyt7Ob4yOrWKjdjNhF2+PO82POo= 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-353-WrT9vdwqP36DK-6PPc3Ylg-1; Thu, 25 Jan 2024 14:33:17 -0500 X-MC-Unique: WrT9vdwqP36DK-6PPc3Ylg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 459E7383CCE8; Thu, 25 Jan 2024 19:33:15 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2F94492BC6; Thu, 25 Jan 2024 19:33: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 v2 07/15] sparc/pgtable: define PFN_PTE_SHIFT Date: Thu, 25 Jan 2024 20:32:19 +0100 Message-ID: <20240125193227.444072-8-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: BA4F380025 X-Stat-Signature: 3uohhc1o7346uxs64ky3bg41r66qzszm X-Rspam-User: X-HE-Tag: 1706211202-262960 X-HE-Meta: U2FsdGVkX1/OkuS8QIkdlECmI6i9AapevAz3n2fpXjpgcsxxMe7d1jMauBRE8UzYfyjvHE3FzYvebldUetORW4lgJoj3Vdq8AjJNbQtFXqsNh726UZhZuSiZdhSDvRpD0JU/zvaHsbQzQyUB/s/cUnSJbiKAdqcrQC6WjmTKHtAsVHW5DkSvbvEcwNiXBuvL21Mwjkq0gffbsQBX7baQsQz76+9yOJL/BXCwh4qKT/IW9k6msfL3nvrwYr1rMDd0G3A5gnUYE2J6MD0U0dPCKjQd4Hlg3ze9BQ3F5pGjhmLOSXnomZHMfzfaOb4AnrhbjSYLRoDh/pI5qiCLWtwyfkxaqnaa98t9Hn1h+d8f56+1l4IEyYfonuAUJ7j4NWXuczfaqus2977kHDCPEjn6qIx1w41UPfTE+hXwM6ESdRk2UgxXNNnSR3gtFyMHBw1leaS0J8LwsRcu7VxXUjyOnzZQciRwE67LJkqcnSR/VyA5LJ7/hY4tnyWphKxA51OCpl9yVffUJrWkt4DvYNVgS3Js+WSFsZN4A+aKTbLxdMNkP0KTcOJUvzn3AAXnbnlRvQWfpsxv/UgbEbBDeDvzS1RXbhQnE7DFXLAYLuRr+FIC0LWrvmxVAmB7diS+1ZtXUFBrKou4fzFhfpbiDBFMUrfpxyhcNMUCwWKW9ZJVDqWWYcJZgJ5GGJDy1knOPGPqjpGLNw+kG/3HV1fXc11/JiHcKjb9HlhcvC85aVcVmDdwzfHEWOhYXgWb9h8eCuHcQtEYOp/VPDscEzbkaAEWNKZcCDKfoaIZf9yUBTYaAN25AO08w/3A17lW6l8aw9sw/lMMp6Wfk0XB7/X0YRFRnt5Iyw5c2b9HG8ZazlHWyHxOxiGu+0PZvaIjImzu6WKGZFU6GIZVQAYjwNpPHsDkAa7otMr07CIRZa+jegOj2pywcLRI8Wg9LFR/NhUFHdnu7iPJBhqBYl7XJLPhClS w95cUykM 2H+5weqJ9KSLyp0GvCdAz51VXT4218Rq/j+6tObJtLNEBp/r1K8JQgnvKemdovxPhI+Q7gEjrreRLJde2dXJ79WJBir9TmstHh0wFFXJ/5sI+SO3HzSvoHQYruiCxGxAJpSojDahVH1E2pdsA1OEG7eub1KM1b1C1BVRWqaNRbxM4NSpakjA8Zwdzq5B1+r3IlcM8cIFlA1KgDE/NqQkLboIpVL53Fo/QzNT9 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 --- 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 a8c871b7d7860..652af9d63fa29 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 Thu Jan 25 19:32:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531549 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 6FE2FC47258 for ; Thu, 25 Jan 2024 19:33:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F38E228000D; Thu, 25 Jan 2024 14:33:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EEA84280004; Thu, 25 Jan 2024 14:33:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D637C28000D; Thu, 25 Jan 2024 14:33:32 -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 C429F280004 for ; Thu, 25 Jan 2024 14:33:32 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 67891A0585 for ; Thu, 25 Jan 2024 19:33:32 +0000 (UTC) X-FDA: 81718832664.27.6232204 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 D7BE1A000C for ; Thu, 25 Jan 2024 19:33:30 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ACiCevU1; 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=1706211210; 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=+md2pmrHp48BftcWE7oPMr3+y6qzWNOJ1IOyjx24C4k=; b=L6L+V4slys3Tp+Qn1IwPkGOWqadjTugSqA/O1DGlnbr7TCDJPcXQJ0I94zs2m2iJjTWwKh 2WNVB3V2FbLfTxFXguC7MEmIt0Sb+wvetT1GYZbTomwrhtWKy0FFoEeqWG7a5KrCIw2ors Q9iL1xQuAMkJHEYxvM8CB02fcIrBXJs= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ACiCevU1; 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=1706211210; a=rsa-sha256; cv=none; b=zLc/8F+d5yxVNm+69NuMf4AqF7Oth2VTE+gMFbajBSMyvjYRhSGn8uiKkktA1MAT+posI2 93w9Gv7AqAhZms8izTsjpKaaGtR0fTIpM5Ftc+18MNQJzG5eC+PtsIal2ibCxfid4ej+B5 rmLL7tALB4KBx/yeeK9bC8gqiAbyEDY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211210; 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=+md2pmrHp48BftcWE7oPMr3+y6qzWNOJ1IOyjx24C4k=; b=ACiCevU10qLLFCYhxz3v6IfzhOBp2SJgoOAS/ilBzcNxvvGtR9ApJwyufffr+oasMykA+m /1eCgxZEZnRZDyQuH0VX/6aEcWJTtv4QcS0NFtmAD7gmSxjAfSwUgLw5pE3ALaGbnVpw+S ONecy4tpuxa3xiEO4dXd0lU9At9McMs= 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-52-07MQqOk2OR24s5b8tCmCuA-1; Thu, 25 Jan 2024 14:33:24 -0500 X-MC-Unique: 07MQqOk2OR24s5b8tCmCuA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 658038432A2; Thu, 25 Jan 2024 19:33:22 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4DC1492BC6; Thu, 25 Jan 2024 19:33: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 v2 08/15] mm/pgtable: make pte_next_pfn() independent of set_ptes() Date: Thu, 25 Jan 2024 20:32:20 +0100 Message-ID: <20240125193227.444072-9-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D7BE1A000C X-Stat-Signature: w8374i5x5tmw3izeears4d56pgwpecme X-HE-Tag: 1706211210-826559 X-HE-Meta: U2FsdGVkX1/qXl/CoIiHo+Dtkeg4iM/3BpzkB++qjkmpPJ9+vQRVWJoCDbFTREe/rKU6EYeyi7hGZrYc92ybY7wtcBHPL2VN3fvasLOyVcRW5pLgbHnwFc+k4A5kUCgwP14GUrNXzjSm0s9E8ReKdMTVH8Y41YAms5f1ROK+yLL1cN1OjJKWso8ii43tPhLNmxSo/toqn/flTwrpcnMvP43H7hoSbTp3715V3J75MIIe9WCPAGnNu5j1yqsaHm9eQBVNWoMqYxGM7p4tsWM3QrXI7rjsZy+h6NMBn1rKhJZwwmvRNvj53o7eMkoKZgI0NXpvl2E4CDvegieLLdYxXoztRZSf7q3cdT4R3inPXCzG7eJmMU/MZCeU6IjXFuRDv6HPLPzxbdHR5xGsKHnBDkr2vck3NfVAxVyudDkwaRTG6FJb4ei/L28n4+6t+PcZvpVfPv8dn1iKqRwakZ7ZfmcmxcnZ0YwsRpoyUKgAtZbiZxQshgQ2R3N+q4AEVEUQK/AeC2cz1jN/x2uQx54+3Q4X0bmNKyOfRuISn8B2NA37Qs4mJSzr4oSWb/86QOXP+P7cyvqcx8UtOQm6rYwo8y0Zzaz4uUOSZPafEP4uPqBbUwc6M4yqSr35meOkdnd5M4qJhG8EoVg0PSQRdPvTwnO5yl/l6msEJecGvQcTteT63uLxxVh6FUUvGeJHI56B1YX1GEzwtpy9m65WAXTZq2N0nqErnSJFlAOxXHa3RHLt1kNbnqvUIZNR9Ke4CsOuXr9if2yB35nc9wfoYL1PS2gUkAzHF1YLbI6/Jt2Iij0hy7lEoe5X+eZLGl7S4ilo6+zmvDnqVeZ1rpjYL65pWDwN0PO7TZG067VccgABCHOcpIavL2oBMSplms6jl6jgWVhjDaZDzoT/y9nSDcENGS2DqINu2Os4JqntrLfsjDEk9CBNsUQlNbqgzhDRZftb 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. Signed-off-by: David Hildenbrand Reviewed-by: Christophe Leroy --- 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 f6d0e3513948a..351cd9dc7194f 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 Thu Jan 25 19:32:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531557 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 E0562C48260 for ; Thu, 25 Jan 2024 19:33:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FCAA28000E; Thu, 25 Jan 2024 14:33:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AC59280004; Thu, 25 Jan 2024 14:33:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5257528000E; Thu, 25 Jan 2024 14:33:36 -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 3DD2E280004 for ; Thu, 25 Jan 2024 14:33:36 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 153A4408B0 for ; Thu, 25 Jan 2024 19:33:36 +0000 (UTC) X-FDA: 81718832832.25.DF2AF4E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 63388160017 for ; Thu, 25 Jan 2024 19:33:34 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=F5ajIXvr; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.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=1706211214; 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=+R5tuq6xMxmvP6/rbWFzIFy6OdxpTZA+S6ihf7eXs9I=; b=fCsQwmJVVidY2Sn/SuYnhmb+6Apbb1J0wkrIjCsydSVfz2waKgAEKG7fd3q1NwJJVzpXXR MGbZ0eYlDz8I30uVAPc75hl6tuh2259ZKWsDHse/U405uM1aQ7EhMiEtkT3XuAWOjaAJC7 Gd31Z/Az8cup0fdC9/ybWgimfJxAK4A= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=F5ajIXvr; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.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=1706211214; a=rsa-sha256; cv=none; b=G+TFURBuRo62/yx0ST5hAO+yhCoFW+qXxyoBKjejw94kmwReLgxcLBvgt+HAo4QKWBMii1 CCyNsaYcHH16KfMowlihApcqty9aYOVPdNBoC9CkAa1abBzDwT5KdyIjom373aDNQPNOEg 6U1lPdW1tZ766funALcHBg8v14+Glag= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211213; 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=+R5tuq6xMxmvP6/rbWFzIFy6OdxpTZA+S6ihf7eXs9I=; b=F5ajIXvrImLGZpaSKh1xyv6HzToBkn+ZRTzqG7pvpZPgPUiQcOeqxtF+DUV7oMWKHCN30n lG6c34aLt32LkJSixshhPvKcq0ycnT/RJNJvrLdoMDqQOafB+LArN5GWvwXgbXr5n9gpGZ ONo1dPBpTnf00mUKjY/PKJDfb9aZL6Y= 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-494-md0mE8fJNzqSFV1VkGdeGg-1; Thu, 25 Jan 2024 14:33:30 -0500 X-MC-Unique: md0mE8fJNzqSFV1VkGdeGg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 61303383CCEE; Thu, 25 Jan 2024 19:33:28 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4C5C492BC6; Thu, 25 Jan 2024 19:33:22 +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 v2 09/15] arm/mm: use pte_next_pfn() in set_ptes() Date: Thu, 25 Jan 2024 20:32:21 +0100 Message-ID: <20240125193227.444072-10-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 63388160017 X-Stat-Signature: 3zchq78jknzhdgsmbhnmhfpnaj5htjbr X-HE-Tag: 1706211214-518309 X-HE-Meta: U2FsdGVkX1+fWEl2zRkTpKZh7bOWyfII6HYUR1H7PaYLck5L5hh3M79MOp7gaVap9rT7sU4LVJI/3PQW0DUhqp9JyepuKTkP3Sj2a5fze3VSjCK+oNlXvm4wDl/YyphnsvIk1Y/VDz85ET9AoaJBCu6jMgL9HgznpfN6CTZqnOpQrOJzCTZVkgq/5Iz7jYsLTcYQ1Q/HEf7rlO25K1MJatTPV7Td6i47SHuKd/pRxl2Ewoh6QdoSOj/RZ6ELDjdyHqxx2Vxj5iMUbc89rEBZx7g9QhiSPWaLU+vjvptXArpWyWHM+ipuAYtRBmfQ1J8YbeOCcnuTbSRalgWwiPSSaNFyZ0zZmMqoo26CygAS49WtA97OK43dP42ZXokPhimix1iACVqB+9O7vh6nVGvfp07LD+6q7wOThsopJ+ui5rBVXWjVHCIiXVgZ9XN7SaSjtvhs9QbvyonKxly68XCfyzg4N6MkUNmIrEwMoJi/5tphCYbWdu30UJnAkW44uUQb/LsPmxmhUvXjh5mpHrARc/clwftAjKrLwHKFq+HS/16Bn7IEJN2tupA2pAPuWffEDNcHq9WqMMu/jrFz5fd6ETTtRLmJgeHIxkY9/o9goOZZqfAnauujd8wASUagKRQIuoPDaj+eWK5NhuM6EWTvXCwGs2y3/WZqWaZ6grLuqQqr4+XbT6NeK+l6zpflyv/lpOtiGGlvDV8f9zo3yoaP+ooTN2CeH1ojTbvsNf27S/YGut/ZKo/A3pcn10ixwP+aZiqLn3Pl/i64HjMCInEM3mm5NyE+5/w1qunHjSIEWrSZf1xfGALgY2E/GluNcZGR3VS3xgeEA0zKj81u4SwlEw8y8zL3Z26wnAc1lTGO0n8Br+hG+AYarAMN0JqPZy+4Gk7dkmj097ZQjUc8vgw1ZJpgJuyHAwIN65p5VS80nRpwWmnkf1PMBl1JCmnqL2+yG8y8b6RmItdaAnGcPpn Tgj1Fp+8 unEN5yf5ziuTazeLkEGwEARkugOLsZ5pBEdEtO7G1mW8Ea5N8B2c55mBoLGAdkm0S4VFeLjwJzf9uQFqnX1LRz12vOZvTPIgFjEU9He2itOUUio9VG51Dq5k8za4cyTuXoZjCcCSAuY0FxUPXu5ej5p0rOaVVRuWCk8MgAICfnb7wF7JXemcTBGFv4yYp+HevDhyoTMOX0Y+Xczy6jSBfAOtLMLDglNBL+5oI 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 --- 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 674ed71573a84..c24e29c0b9a48 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 Thu Jan 25 19:32:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531558 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 E992CC47422 for ; Thu, 25 Jan 2024 19:33:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C20D6B007D; Thu, 25 Jan 2024 14:33:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 76EB06B007E; Thu, 25 Jan 2024 14:33:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 636A76B0080; Thu, 25 Jan 2024 14:33:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4F9A16B007D for ; Thu, 25 Jan 2024 14:33:42 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 286568090D for ; Thu, 25 Jan 2024 19:33:42 +0000 (UTC) X-FDA: 81718833084.28.8B7667D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 6B6684000B for ; Thu, 25 Jan 2024 19:33:40 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tw1R1xkW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.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=1706211220; 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=cWsEpSrdwYXBoeIhNs8GBnzc96pxJH9YBnNESaF0zxU=; b=ZUbUI9Br7fmD2bOiBY2bNrMz5IebEUYl8pzM5/jc0UbFitL9grgFpdNSpGMSxSmFvMj077 XBp4d4ikqbrk/ibJrMS4AzF8SY/qKod99nzEOBrmN9rWAeqVsjviz01yyhu27Hiny4eKAC 2piPZANDMo30hwM4wPV99nFXIuOgt0A= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tw1R1xkW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.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=1706211220; a=rsa-sha256; cv=none; b=TvbdjN9mcISaIhPCdv/bockZ09abIdIy34wTO2m3LzBxVi+jEFU1C8CLa8f0HBypJXOloA Mv4zeW7IJ2qvKNZSKJMV5/UgwGO/l0SVhwgi9PaW7lei3h9xrQ3KE4tal3eMcab1yxsuVW egXHhic+HZ+ryCIeWZDKFRegrhD7zJI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211219; 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=cWsEpSrdwYXBoeIhNs8GBnzc96pxJH9YBnNESaF0zxU=; b=Tw1R1xkWoXU7GWD9YIigILiQqsyjQpsjyt7H2bAQmTSVXWY8tmdbu5en6tBc8y5NeWDl+z JN52R1ndzhNz05r6idPJn4tFU0Mp04QfBicB35iyhVfVMFCzxjmRUxW9iwxB+5U3DlxyFv 4ptjWDow1flLDTQJWZsPEVbIpxK1Jvo= 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-644-z2AXiQwENJ2OgR2MM0KiwQ-1; Thu, 25 Jan 2024 14:33:36 -0500 X-MC-Unique: z2AXiQwENJ2OgR2MM0KiwQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 9E036870822; Thu, 25 Jan 2024 19:33:34 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6302492BC6; Thu, 25 Jan 2024 19:33:28 +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 v2 10/15] powerpc/mm: use pte_next_pfn() in set_ptes() Date: Thu, 25 Jan 2024 20:32:22 +0100 Message-ID: <20240125193227.444072-11-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 6B6684000B X-Stat-Signature: yefopaab19wsznczjbgbz7xmpjq9143j X-Rspam-User: X-HE-Tag: 1706211220-686049 X-HE-Meta: U2FsdGVkX1/V/stdbyXfuWaSgGE4q5qCmTBjCgixgX26l7yfvK+JHTe+bHth1IIPStOH2L/Sv5NNrZv3pt/b4YsljnfXwT7ao7lfiCZ9bAqRpVO510giP5J4Uvh9f6IzT7v19w0IF4D5B7bY+6FmlJ6lpsf3P0wGtf59SbvoT4D9ntXtSug8TK6QPjTG5c29yj8HKx//i/SDYgxdMzT0U23B5qg+Lddb0urRnWMt+OOe3wraUEhUdYO/eFFFLZcP0tkgdZByLXfPkKJUxHU/UC8rynQ5XPA3cPXwwORCMjFyfidjQZKJH8uxRG4qsMk50eQ+PlTM5b5gt7FPbOHBawRQ9tZvkhvL1UwonUkKOD6EGQgclaJEfzrXmY4J8x+ATr06zbn07T9yuNpXOmlvmy+olvS2skIrHYHx31AUc7LCX5QQB3pQ/FYTeWgU1bNzmxDyOQMDNgPRAAdQqLpfRtL0H8l/Nxf4lEbB9xzw6uIUl1A10hQi7BTpcecY1U2NKuhN6hytChPSKB1kmjWFzrK2Bb6F7+36YVSrkVCL0kMN0Td6v/tUHCAF1DQIj+BL2i8CuFViphSz4xD+0JhTT6kBdbBaMjWZf13Ht6ssgvhHuPgiCsdBZKF2ID+yyPn5ax5l0R3BCtMA+DmYDSdE181LGHPjcrA9vNPD+681CDNWs9svYoOagz0QlVIVgwXEe9FQt7j5Wq4aRI+qK1Hd/ckFRck8wqv6HU2IuEzndVM4urj83rSK0vJMO2eID7bhHdt4cGB0dFszdpUH9b/igwyHq/wTotRkx23beHJ9t+CbqYArTf+oFL9bj1waVU509V0m9dNJqSc2b1LXgj0LGVrDB2yYjgUJC83ga9JgwNCTqn7HgS0axP71k4xYkaQRoyFkdwS5wkX56zbqFgQKhrru5+iacaAnSSZovGuR8QANCGmDY8hm26vqJyyW1Z+iIleovGLdEIzDee5+fac iVkkkzl+ vYCHumjz2+YJir9HrE6YtlvLx7BcHGdL1P+a0yZxe778q9GqHeNNXL5x5E5OVdQ919oTsTCbnKjcOmTxUczgJJlQm6eqx4afYoBrmb0ZxeYQGDKNqddirrwyNj7f6oQj51bG9B518zOVVwRc8Zn0w179zsVa9lrsufWLF9ywtHwXocMC/9a3l/EAD74/OEJe48EJYI5LWSPJn8BOtieUFMpxcSUqr/7iZYoMR 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. Signed-off-by: David Hildenbrand Reviewed-by: Christophe Leroy --- 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 a04ae4449a025..549a440ed7f65 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 Thu Jan 25 19:32:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531559 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 BF8C7C47422 for ; Thu, 25 Jan 2024 19:33:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5282A6B0081; Thu, 25 Jan 2024 14:33:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D82D6B0082; Thu, 25 Jan 2024 14:33:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 378B16B0087; Thu, 25 Jan 2024 14:33:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 23D786B0081 for ; Thu, 25 Jan 2024 14:33:49 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id ECC001C18CC for ; Thu, 25 Jan 2024 19:33:48 +0000 (UTC) X-FDA: 81718833336.23.B7E9FD7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 4DA121A0013 for ; Thu, 25 Jan 2024 19:33:47 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cmwXi7+u; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.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=1706211227; a=rsa-sha256; cv=none; b=Zolls5wncnOA4hI1EcdlNr0J7uBcPY4cS4o12SqGVuOcJARoy8QWle5mru0n8ivPfTKvM2 VtgN8bvajXiEPoAV3a/v1SxIikATjY9Eo2yFYCyPknHZmI/vURXm4ayKQyFVHEWrHciwD1 jkVMEOtMJZRlofPaUTvPG9ARjc4be4c= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cmwXi7+u; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.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=1706211227; 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=3s1Jv/6P5yjhblLF2udczJAUFVvnCKFeQLjRuwj24+c=; b=GIXRBViPVmk8m9maYglhqK6q/lD/nXwmvnKuA0CaXVRASETrpfMSaWPi5bkC0uKIraJOK4 JlJZbUlE1Ulw1QUrMA43Ag6TZJVqG+26Zg1jshSlhkNOKVP1wRV7h84EFr9N4iZJCai1v/ dt12igxYLgZ8PDVDcRwkWn+8e9KtgJo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211226; 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=3s1Jv/6P5yjhblLF2udczJAUFVvnCKFeQLjRuwj24+c=; b=cmwXi7+ucx0JaGuGm1FvBL5hHGaPU1IOUxt0b2w8YWWRcf2T9Yk1CsDtR5nph4dhqYaUgR MmcoAZvZz9EDORTYWv5tp5mtOocpGUKhv8OaSB1NnjFRtTabts+srYjyMtydbO5Tfmkm2Z w+3FtRMD3CoQhkPlALAdqgx09vOwN8s= 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-499-493L1nvTPrqpYIPc57u-fA-1; Thu, 25 Jan 2024 14:33:42 -0500 X-MC-Unique: 493L1nvTPrqpYIPc57u-fA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 34A868432A1; Thu, 25 Jan 2024 19:33:41 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 074EA492BC9; Thu, 25 Jan 2024 19:33:34 +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 v2 11/15] mm/memory: factor out copying the actual PTE in copy_present_pte() Date: Thu, 25 Jan 2024 20:32:23 +0100 Message-ID: <20240125193227.444072-12-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4DA121A0013 X-Stat-Signature: hncaajgmt84mesfgdahs894bfxhj4byd X-HE-Tag: 1706211227-601073 X-HE-Meta: U2FsdGVkX1+11Vf8UL519v4j91HdPGYn15A8REN6fcvt6SguCxrqlc8g1h48dvgizTsZrHvAcuHQlpW2kjvLRShlvjYI7L8Ewl2MRAlqiUS/oPH679JlBt+PswEOSFSXmqAQdhz33CslJDCeJdKqIZ7+wfP6Yf6p0XJmiT5bAlZn7StxRVn3Tzo891GWINoo6RRLDvrKehJDVNADxDdfH9STHhWpQjD1qMuL/uvcQWQqb+HrKqTf6k+Tvh4CR9vjmu4FWF2sreyg5Scl3LCBOsAbDnBr4NRnyiKExhyMW2HVyWGR51q/WgVljuBIMqTjfYDAHTo+BgtZtLtYVWMJQQjMjs8l9N5vl2gEHZTSkIvgA2+05QcdMplaFSX8wXfucfF1wgL9vEsgWtb70F4iu6xiUvkNgHNZx5miFelNpPsU+7QCAM603plvLBX6Wg2fZm6fBpUWzuv0i6HorWWgK3iNXfSBgeQaCMcnzh3IShl3CwHIEohrIvqPSzOPU4x8/MFR1kEF4IedP6wXkPUpCGlefYVFja2Fq5MRJfdydtYuxiTyQoMuDR9knjsCnHEMD9GXD6T2LIAfdFN0MmqYkskk07+2dOErk5zw88SoGoV3abrf2y+TSFrCZKDr+HlRm06cRsSGriwdMBc2WERR2kzz2wee4UAJei35/Gpa11iwqxnWpTolzAlXXc3y8EqCMyTk7+oFJzbHR9MMCN7maPQA6hQF3Z2qi8JuS5toNtkas/0PrYyd0Szi/zxYk6Nt2zruVRThe0rNIj42cenT8VVV2+Hm0jpy+iizOfwJWFu8ebj2pHaGrKLrEaWEsP/bAKTPi7rSFwWfxefQyhr5F/YKb+hScTD46iSmTbW1ZbKLvV6jJPs4iR8lGDhwf1404KQuVGLRrssBiN/MeFGigPPcgY36SW6x6QWkn1UVHqa6iehOnjPmY3XnneqE6NaYvEB0gq4vekmrg7TjZSB 2TJx0Ak5 57mS0yx56A2X8fCYU9ZGDzNAq3+RYxltijOUkfus4lfUv6i9uct3LrszLy/KuOa2o7mzYxX204uadjgpHcNJJmGIzP2MjRB352vHUiG8bkoX+/gz8ItlbglaFXg1IFhiOJZZKLbLvYcXbZJ/rU/oOYo3l2NXOVLwDEP5b4XE/KbqcFhG2Y1mRRkrSuIeJEurysmoJJ3kZmyIMZj7sI0vBEIIorNBie8H6zX7KTiAr7IzzPAmFQ9kpPIPuTZbsUWRtKW0zgdERYQCoopYF2Ou6akGJ/Q== 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 --- mm/memory.c | 63 ++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 7e1f4849463aa..10fc14ff8e49b 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(page)]++; } - /* - * 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 Thu Jan 25 19:32:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531560 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 B2CBCC47258 for ; Thu, 25 Jan 2024 19:33:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48B4628000F; Thu, 25 Jan 2024 14:33:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 43A41280004; Thu, 25 Jan 2024 14:33:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DB3D28000F; Thu, 25 Jan 2024 14:33:57 -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 1B3AC280004 for ; Thu, 25 Jan 2024 14:33:57 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F0FA5A0CD6 for ; Thu, 25 Jan 2024 19:33:56 +0000 (UTC) X-FDA: 81718833672.06.60008A9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 34B1540020 for ; Thu, 25 Jan 2024 19:33:55 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DZPakjd1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.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=1706211235; 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=Pt2Rr75nOP6cG/V8puv594TsEnpKODS5vdDUk5CMfho=; b=FUK6V2hFNEco+JCDypCRQs52bKZ3Mlqx6BmDf9phISu/k0g1BRopz8Q4QUga9dfTB7eezO GL6JBon/ipSG+4NqoEWX6Jr9Kz0nMlUdjhC6pRN4emEP8Afo7bmXUe39djSt5TEn4/D2td FV77R/cK+NQhdd5xdDO82N+1iMNRx1Q= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DZPakjd1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.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=1706211235; a=rsa-sha256; cv=none; b=5odxiEKgrN3uH/v582qhDT9/Yj05OU5gfX2vJdK+fArG887UuOq7CeJQYnWyYr5H2h+0w7 iES1uIVU1AzOgblccjF8r+d+Vckt+3zK9hYnVju9Zq+gH40dFa3Y37E5U3vH6U3dVdFu/s 4TdUMFveVwAMGHOe05mj1PkcAmSg0xo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211234; 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=Pt2Rr75nOP6cG/V8puv594TsEnpKODS5vdDUk5CMfho=; b=DZPakjd1WPS9+Sb1nZqyLfZNwEi16YUTTBvuAkln5OS5BKe0Zgj55HiL99yztLS04O7oFU PczKdJVbzq36SVy4WeuVQwHV5mkVnNybR3pNDAElzaSAF6ZbVhPJ/Yz1fyUChCBbVjv4Dl LmDdMBvVJfeAFSKwWixYyqGVj0QOfAo= 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-358-Q-6aRX_IMaSNm0LLjZ787w-1; Thu, 25 Jan 2024 14:33:47 -0500 X-MC-Unique: Q-6aRX_IMaSNm0LLjZ787w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 5A3E18432A4; Thu, 25 Jan 2024 19:33:46 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74AA1492BC6; Thu, 25 Jan 2024 19:33:41 +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 v2 12/15] mm/memory: pass PTE to copy_present_pte() Date: Thu, 25 Jan 2024 20:32:24 +0100 Message-ID: <20240125193227.444072-13-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspamd-Queue-Id: 34B1540020 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: tzbqr53qg1jsx19mce1keo8fuyygs8ad X-HE-Tag: 1706211235-44297 X-HE-Meta: U2FsdGVkX18C9XPZfWq9jN8AftuAHZWOYG1MO/JMXPpjkfbOHUm0Kn1oYoyortysxg7dsSaCVGJgqf0maQFOB6mkYkUDYMz4hiSJEQp72xSWPXFEIUYjBybZ7s6ClzIWvp1l+aA0VDKtImA63lYlSWDwKtMYN5EpLcwMDYi33S1yt55GoKfEfPUZDO5tRHjFvihyEHgq9YPaHTFD/wutay1nO9Ar+ZLK9kfMr0BqEQRgljonSRkPUyewDLKHPQ0o0Oau0L26dmnvyj6lIaHm0x7gltJLAc5IX+47am+pRCLp7J+LdQEGkIKgXHO5NHSQOjgDdvsTGIdTNMHNlHWVWTv5XDtm+SeZ610jI1SQVe1O9p+cr7i+XjkYESjQI1ENFnBurI+PCt7Uxr5SZdPAmyPsNKMQQu+w13V6Ci1wOUHogW9UGJFmvtN8akkWwUgIT2NLOKy4xloJtMjdx0TcHhJcJCDdCwiKqwawAMFf1l3sh2VrhgJ/YO+taZMATiTKycVUPFgoLnRvUyt1tZgGYvmGjRSm60BsheGayMigyxBFfjPun0Qd0e6W6pXPPvTOdRuK0RfqHYrcDWsliqzXwvpfl8Ha0lfJiIhnLNocU30qj2UwuYZ+cQpTWTmTGP7g+2DMQDIAlJoM7O4xBIioPO4hYEvT6igkdyNTXZ5i139kDnOQTU1vFziVlV5VNpU03l2So38vAz2Gm4VK45CmxERU+n1yvjs0afUTLxFNwQqV2rVWcDJG/cZ5KM48w+iYA0I6lGmXK3VF4pGlVF8W5RoqTmI0m/bG799AiYHaLl6ABPtiIeNvotjli20KF4cyWF/C+tZb1IwlOJVK+Nmt41Vk8uglkn0FW5D70O91RMKl8Ph6KTB4+XzEzaWdRGhwc62d5pDNLYIjgIPCbA0b4aYKRfviEoA0bA9WUpF5cPV35TDU3mclIfdjMpdnogRAjhRmrVDBq0z9XgLUQOd vfZN4Pl/ K5QGMVU0CjlIuqRbsh+MExsWJzfJpufhDSXCLfU01VECulzOsBYNZDIrgPZ7OfnZhaMofsOeLVx6oz38iofqfnA/oRCinQga/3+8uuXtzksP+XFSNRkSM/rZHE8JqA903TU7RzuLESLO5p65Bm6cRr+XwkL9a/StKEVq08rD8UQZtb14zMWgtOHW7HqqjZu4eXzKxAYMaqairhnOUbGaT8p4sB9BVGfPw9alZRUkQJGQtS/+btpiVGyGBv9yFGMeZR/s3ZNHDRjOBFmzvW2dWdiMe3Q== 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 --- mm/memory.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 10fc14ff8e49b..729ca4d6a820c 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 Thu Jan 25 19:32:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531561 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 BF315C47422 for ; Thu, 25 Jan 2024 19:34:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 463E46B0083; Thu, 25 Jan 2024 14:34:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 413C56B008A; Thu, 25 Jan 2024 14:34:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B47E6B0089; Thu, 25 Jan 2024 14:34:05 -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 1C886280004 for ; Thu, 25 Jan 2024 14:34:05 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DC051A1C32 for ; Thu, 25 Jan 2024 19:34:04 +0000 (UTC) X-FDA: 81718834008.12.A6068B2 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 1B4EE180017 for ; Thu, 25 Jan 2024 19:34:02 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iWNYcVJt; 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=1706211243; 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=fXWjdZLipOfshgFI8W07OFbQ7KRQi8Xx3as2M14iVzc=; b=TGsmQrl2IE9FVbSw/+i+f5bKjKHqW0ZYUQZHKr5L+ccmaS0T8ejRgtbmKQ+83llH5JyEjB +vt4ruEjLUNn9EXj2FT3pR29o2fqyQ2GFdtpHIRJq/TAvCNDGEKBS/RO9shDd8AECkvDGg 4iYQ8OqiYjs8VAiNaRZ4V2/WAtWfEO4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iWNYcVJt; 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=1706211243; a=rsa-sha256; cv=none; b=J2iiZUZs72Mr8Ja9JbKVYsZ1Io5+dHfWrrbtAk1lW/P7A1NlAhOWCY4f1X1X7TqdhE0cMp NmALu/SfTJ3pTT6y75IcFWuUcJp9s4C8NzH6a8Q/yWIYJj9cF9u/AANeeYdi6Gy3vjAvXX DliZP5QGunqr1Rysss0pICVIoxz/19Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211242; 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=fXWjdZLipOfshgFI8W07OFbQ7KRQi8Xx3as2M14iVzc=; b=iWNYcVJtTfP6BN1pb5lDqd9+p033Su2ceLfV2kNtsEG12WREkLfwSiU0aKjLUOxakBgkBg xaaZxDwh6qDqnc52Ii9ORW+cAcPrD4kQf1mz+Pp7l8FbxoUn+R3RHyFFHNiyJr6cl4VQ6A 4DI/UyzIZjyyOb6LQOnUgZZqikx+cvM= 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-36-qgFrcn9EOOKukZuZZZlfTA-1; Thu, 25 Jan 2024 14:33:54 -0500 X-MC-Unique: qgFrcn9EOOKukZuZZZlfTA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 50C83185A782; Thu, 25 Jan 2024 19:33:53 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94E83492BC6; Thu, 25 Jan 2024 19:33:46 +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 v2 13/15] mm/memory: optimize fork() with PTE-mapped THP Date: Thu, 25 Jan 2024 20:32:25 +0100 Message-ID: <20240125193227.444072-14-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1B4EE180017 X-Stat-Signature: f1pger5fnuiym8k4xmx3axzo8r7g8xnj X-HE-Tag: 1706211242-208851 X-HE-Meta: U2FsdGVkX1/y1z/XRXLGA1Gf6aQ8F7I4oTyYu43OBJHJsHzcCkk81+cY5GEE+Sfc0jY3lQ1x5myGw5ubdsqICjY4BtVuUJznh6YHxIiS8HAfS+sr0xT1C+v6p1pHRME/FIaLLy7hU41DjG1smZySHLVKmgBGzgdtZcxHfaRqrjW01DsfvDfsVjEyP/K7U9mx60kPS0LdYDuuCiEjCel1d7+cFXZp6qKvjulVU80noRAIVM2wZ1clr1Wyu5noQpxjrQuczb04z8+s+2Bi0f9TArH/ACxY7I4tDLLehq1sjHSKAmnLnQXIha8bWCkj5DQaK1sFdUOhokcWAFrTEwI2ZAm/n1ommCwrxDHAweiIGyTfTYcYXfKJZTqTTuTRJ0AdFV0e4cAWgZqPQJVBl3KxiiU/VDfkhu5Yt8GMlH/jkdI/k1LDHmxlOFPwpDXlE7/XYDExF/aVh5PH9CKHxC/kJ7t1whpyZTTp7YbLSiNnRHSHKtKH4IvOqLKnX3Ya+iYQR3MBomPwDFjsRZ+PHgVxdyv5E0YeCnyFY3x4wBAulwFGqoQEr5EpyJwU+VRt0yGN2msqwS49yiWBePMabngfkiKw86+XprDgo/K85d9Gr4IhRgUZVej8WHO+yCDBNJELcCoElcX+5TAocbGRj8dCtyZq4bDZLaLs+GPTain3Qp6A1QQPwRMEitgjKPut0ke25oT/U6CNrQH2/a/20v/H3FkERJaRbwaM33iFckjKrnIf1DtDtxHE7JHuPKHMpRdG4TZHCkEYj1hfy2TwgSEAJ9X5ghhpwg2lxKB47hpU8oEVcB7WRGSkM8309//rM5antkBrGAPHCSiIOhE1DcH2NmrFWyNg+P8f3HobWCkkqtGXcsKaS+MHNScG5AiKuq6c8TDqfdAljkianNaaxdRmxx1xALw1qSY2rRh9foKP2YFwN2GxWPSDNDOc0/m1pgZ6mBU93oSqy8PlVist7mw 4MMsJi2S rxYeaWJmrfH4r00gVgDQCjXAJjvwwYejmGerOXPPBwcaK6K2NWBtnpolbdtXs4Qe0YGS0eDKwc77C1bfT2QH5Z2cVXQTxn3tk3hwnX4mQp9JZ+enJBnCm2yMSHp4svIzguxHSPN3BrJGZB0cLfdWBw8Y+18Cbs7o6L2aDebhlDoUHxxY= 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. Signed-off-by: David Hildenbrand Reviewed-by: Ryan Roberts --- 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 351cd9dc7194f..891ed246978a4 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 consecutive pages that are mapped to a + * contiguous range of addresses. + * @mm: Address space to map the pages into. + * @addr: Address the first page is mapped at. + * @ptep: Page table pointer for the first entry. + * @nr: Number of pages 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 already be write-protected. + * + * Context: The caller holds the page table lock. The pages all 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 729ca4d6a820c..4d1be89a01ee0 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(page)] += 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 Thu Jan 25 19:32:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531562 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 CD0CDC48260 for ; Thu, 25 Jan 2024 19:34:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61338280010; Thu, 25 Jan 2024 14:34:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59B3F280004; Thu, 25 Jan 2024 14:34:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41455280010; Thu, 25 Jan 2024 14:34:08 -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 328EE280004 for ; Thu, 25 Jan 2024 14:34:08 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0DD74120D78 for ; Thu, 25 Jan 2024 19:34:08 +0000 (UTC) X-FDA: 81718834176.06.A9FDBD1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 506074000E for ; Thu, 25 Jan 2024 19:34:06 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RySZ1uEH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.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=1706211246; 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=t50qmPGMpYBEYaKXQ+yO8QVLOuyugBz/n/H7V6E+Pmw=; b=ib9YmhIC74lgSzIPI7j1mpxoksjH4H8UHMe+o956/XdTHXMcGJ6XKyZDW7awopQQU5Fuvr 4N1J9stb90fywCLgU7SRYcRd67R+peP1qxJpUskimhUyVzqX64GsFooMlGB3RZwqMh8YZg 5DGrIAfMFRqakaalJZUUSNwWxUT8AXY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RySZ1uEH; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.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=1706211246; a=rsa-sha256; cv=none; b=UdYnv0EZEmNKTXOmh/fJkSG94guk/T3t0r1LsO18HOJUSRZYRffjbbjxcrhmURSOHLKdBF vS0UV1hNjHZzf2N3aLulbq4Trq7lw0tAlsjpaiSZjmlfRTI/Cn6SE0dc5NykMmaO/kq+NQ 2Yus5ahC3z6SiE7LrwJfFfAw9pDfMUk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211245; 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=t50qmPGMpYBEYaKXQ+yO8QVLOuyugBz/n/H7V6E+Pmw=; b=RySZ1uEHTlySiBn/5GIHErv1YCYKiLCckoxy7YKub7ty2jsFs13vqUvcClYiXPVM0n5WBV 9K/88z6XvVMaeisTA2TzYJIHzlSLJ0PLzRZZfxHUvXh6TIWV0yjNiLpnFNxgr4yfaKBDAJ 7yUlIgS916BoqpZ7w0o15tpNAm/bYNo= 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-255-d5Q_-Ra7Nw6rcBDvoDTvqQ-1; Thu, 25 Jan 2024 14:34:01 -0500 X-MC-Unique: d5Q_-Ra7Nw6rcBDvoDTvqQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 E2A0C1013665; Thu, 25 Jan 2024 19:33:59 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9077F492BC6; Thu, 25 Jan 2024 19:33:53 +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 v2 14/15] mm/memory: ignore dirty/accessed/soft-dirty bits in folio_pte_batch() Date: Thu, 25 Jan 2024 20:32:26 +0100 Message-ID: <20240125193227.444072-15-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspamd-Queue-Id: 506074000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: q6b3eduryi6nnami41fc6oez9dgsj7t6 X-HE-Tag: 1706211246-600241 X-HE-Meta: U2FsdGVkX1+7XaeRd2jnquusuMSP0ClklcYI98CX+vSdVP2cT0YhoXtyxViH3cY+w7yj/xbF6fELQf7+xrv+vygYQc+6vu8zWpIjXTmS0IgUStweloav+BJR2KBimCeHdqO5T3g/UluGPOJIwlzRKQeQsV/QQ6RaTbrJ7TbfsPGYYkd8IsZmT2mV7Dh6jxIshJSzGyFv1ANx8hegq46uGS4ftlJLufP+k6kc3dbq/xW55SB2GLuIBTtNC7Az49v1IGrgv9gGLyDRMfDsBs4fwZQ/7tR9zeoaKkFVXp8XRsIhksOPKSl4C06sjQm3nGD/Wch4PxVVPeixYgxXKG9TYryenRFGBYv/fDwFvA25PmNJs55EzU0+zpDYeAvUjcENuU5lJa7H7hrNZicquDst2aPPRb6YQkVn3uhfxAoG6eGNr9XKvBk7WD/NXL791qMoDjmEDey3sxOhCwdGXqfuGiMp1uf2yq/haT5bqiT/ry5ITjZU5HjWmJU1sodRr3OuX0I6V3XnzfudhHR3ZKLTsGW9MpXQbJ5X5F2eqb3nzVsLs+aHCHBxtzqUlYdS9Pp7GWP2HKJe2fWS9Co9SN9sHUAv1Mgq2lWoetvnzi1p7dy2aDmTnA7ctHx4SxFSwdCxh2/u27sapF3DwVoVs85qmlpK0XeLhLEuqhOQEf4qCp1/Awdi+MQMsyeSTRQSDyKz9Pugf3unanRRl5yD8Bw3nqh3NZp7nJ3Ki1MhI0eN0an7dzNbR05YZyQ1uJ32bSkeA4S8ErmW916m5DZK9heRm5anekQLamz8LKk91qLhk7x208LyA8QpziR0UE/+1x4jwfmtAVDdGjQx7zXVz31RnLD66oS7pEHQ9VZh9AnRW5B6JAjNDldCF+HIBNFNEdhpZKxTD/1gXaxtauM+84tA52TPg5Z3iI04EaNhziu2zrzEjXK+wdj40jj/uwRwHzCSTcWjkQ5/bgp1gTwDvuM RPYTCqdK Afu0u1BdjLNjspGk47yqCo6sQOW2o/g4INc8gyv7oqwT/yYWJC/+eVnL1YwYVQQjwHXWYzjpPz93Om2IVgdJyphGAIxWt2JkJi5EC1QuQD2AWTco0JZX8MI8zS6aDhJppLW1SpPRSuUdVlvtUrnKCKKdCyuE8aJi+pE1+BkUBaKlQ5bu5W9jOL3bnbV7dZp6QuY+t3spHaJ6o4IApoc9AhOZmNtceQIOTaBQs 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. Signed-off-by: David Hildenbrand Reviewed-by: Ryan Roberts --- mm/memory.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 4d1be89a01ee0..b3f035fe54c8d 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 Thu Jan 25 19:32:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13531563 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 32E04C48260 for ; Thu, 25 Jan 2024 19:34:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8F53280011; Thu, 25 Jan 2024 14:34:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B4010280004; Thu, 25 Jan 2024 14:34:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B995280011; Thu, 25 Jan 2024 14:34:13 -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 84F0F280004 for ; Thu, 25 Jan 2024 14:34:13 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 66BA1C0415 for ; Thu, 25 Jan 2024 19:34:13 +0000 (UTC) X-FDA: 81718834386.11.1A1E491 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id A5DE518000B for ; Thu, 25 Jan 2024 19:34:11 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AqkIzT97; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.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=1706211251; 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=KHoljgu5TCYuagRFnizBrkwj14eAAX8FKS7MlgFMZ5g=; b=o/tGksI3DnQak2lJPntgHICVT4Mc9JU+WwgCsrCr8kSbzMd2pTcADDVkEk0s5+2EtNabtE Idix5073QDiQL8OC2Qnq/S+7j3dVFMZlgRLiMyY+GiWAZd6R+OumD93c8H2a3wawPxjq8Y kpoU4+ig7ws6UnhmiahAT54o1R24yR8= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AqkIzT97; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.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=1706211251; a=rsa-sha256; cv=none; b=tOvOT05lK5YEfluiH6GQ2IRWicYbCdxSbUzDRBMSFt1yoVm+rJxM6Ce/umPpbbzZHREiQ9 qoyF+XXchZBzG0+2O0emdo515w/GWrVXmMZ7v//gLf/nc+7bQAayZsrfVqcPqc8sOeUNKH BPu1OPfFnS2d+bbYkYG5oyaccFHi7bs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706211251; 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=KHoljgu5TCYuagRFnizBrkwj14eAAX8FKS7MlgFMZ5g=; b=AqkIzT972mtUmvqxJwonY52hBQkn/bk5vgs7W+QppGFUUtxYWkPIkeRVzV7YqTyZUwl6Ur zu7FsCPsYalq+7+7mnn1btjT7mE5heol8nA7bM5M1pwYGm1Gu0cBMYmNv8GBIZCljViD0e repUviIOdiZA8+K4nm8R8eFhfR+KcNg= 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-403-CrPk6FszOsesuz_bqE2sxg-1; Thu, 25 Jan 2024 14:34:06 -0500 X-MC-Unique: CrPk6FszOsesuz_bqE2sxg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 88F408432A2; Thu, 25 Jan 2024 19:34:05 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.193.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B6DA492BC6; Thu, 25 Jan 2024 19:34:00 +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 v2 15/15] mm/memory: ignore writable bit in folio_pte_batch() Date: Thu, 25 Jan 2024 20:32:27 +0100 Message-ID: <20240125193227.444072-16-david@redhat.com> In-Reply-To: <20240125193227.444072-1-david@redhat.com> References: <20240125193227.444072-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Rspamd-Queue-Id: A5DE518000B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: gxz7y73p7g9asbbq65z14ak5i1nncfop X-HE-Tag: 1706211251-835054 X-HE-Meta: U2FsdGVkX19giSVQqFKACf53yTQmljKfEpZr+JL4eW8fxpV7ap08qxF7ne7uMctaUba06HpL6+pMzb6IXyeZxkeiJpalwui2NgmYsEDKnQz/tDjygI8dVdFbd2JDnjIpwIRtJ1/4XHrqqJe0AFEfetMtfs7CJlcjWFk4BfLorNo7y1s3uIzY0jj+Bly+QwhbzdksluJBpd6CrKmM1pEr60FbUBB2GqlK8FyAAD3I9FDMsNUp3LRDMEI+kJlmmTI7v87zyIdAJ5iHf5J9z75OZ/83GGA9UnDnAelduBB4W/jMVKJDjY3MuCD0Y/vfvTSIT4cBuGsczC8+mLq/nEBd0n4cPWA6Vi1xMo8NNk45ciktym/mjkPE/dHjEOtPO2jrP2YuNJwmzLeS88CxZyji3RJST7+0KdoO/uX3wsoiX/GwgS11OnDo+SsSwjBossdruelplNWSwc8rgM/YtVKqDbLkocRDv6KZMmpiI3B9rsevzPnBWHqabRZoOinbXXY9Udt8iIcl0KvE8wuwJDhyFMuOLKUt6n7LvdMhEZakSi9foyhD5GbNGGgagLvmqUfRnrDrL9VOilVQsKElez3rY7Si4aeqSBYbfx8/5CMhcCAqUFZUbNIojeo2NVUG3IntGfGxWYwgt8d2LqWduhrRa4dmQ227JxAp5ortmg190VORjj7EN8sVB08Tk1j5TgEeTFT3xv4YhCvY22vFCnFPG9iEBEXWzHte1d55aKA/ppRsN5WTSnwN3ikFuzglFW5U6yfyjgeGX/d0SSNONJk/aTYlcSDh/eRw4EG9hxPOXvLJZX3g9Ko2ZwGioV7FFdKFnyxNX9fSItb7UjAeghvBNrTJSfpZO73GR8gSDicUpWzoG+wuSIJSF+S6xcXv+XGSRWweAJFQrEw/cBtWkE1tDK+sP1b7nvU1zxOFmxS8uArVsWzP0ljW7SmsVBa2Hwmymrf3OfqWAfbl6AYKij1 /rtk0YEc MeYAqKsKMh4QUjKfJLhUrjARABFJ2Zi/SmfDjTyMM+VnHgz0aSUlD0AybEjWmfNZk4s1eTfpCjctAoCGoS2UhZqHUrefdstJw1jJ9YAHtbudOK72Qayy9+xgg4V/1LSlJq5nkGBq4euDYeyU8SX+3pDRAYeTq5h/ca4+gS8zIZVf/dAztE9kOmMqLJr0GHhpSlQUb5PAvTuE2/R85ay+j/uGxR9lV9Eq5zZ0dXiFhCz1uIDFIyY3MiiHUzPnIdJGK/7+/V5Ph1liO2Zy0RkR3vIdkQA== 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 b3f035fe54c8d..64442da3df6d4 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(page)] += 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;