From patchwork Wed Apr 2 18:16:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036349 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 2F666C28B20 for ; Wed, 2 Apr 2025 18:17:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B11A280003; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 160EB280001; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02620280003; Wed, 2 Apr 2025 14:17:14 -0400 (EDT) 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 D7E97280001 for ; Wed, 2 Apr 2025 14:17:14 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F029757E8E for ; Wed, 2 Apr 2025 18:17:14 +0000 (UTC) X-FDA: 83289910788.14.8D8FDE0 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id 4A3311C000C for ; Wed, 2 Apr 2025 18:17:13 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="eHinc/Ya"; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617833; 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:references:dkim-signature; bh=zG2qmgB6DXXFbFEthdWezekiUiX40srjLv1CpeHkOow=; b=Ozq4hjBny91CQXz2bp5XtAVLs0fCatmEiPHfnRX7TpIeJVuF/8KVn7Ycy22PJ8jF3LmjhZ VmTyzHbX/RWZ3IFVpF2OHLAFv0jPyujUQ+bPhEluxXbbDs3V1sGWsavOA8F1u1HUuCo3jH g9pjRhGqLbZxD6M6S4eSvrPhl1jjvUY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="eHinc/Ya"; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617833; a=rsa-sha256; cv=none; b=mRvYDNbHp/poVC7/JqMfUFKmdFPksrVVCqe6SX2uNfHWdtQMT+imcScWF8Jv9MCvGMqHip bg3bXB98OUea8bIpbzasVe1JUwXVxfZB9l6Kq0/vcujaDXC1v6AI7MTkBx4ZwmGLePkJQf 9WY0Qftu9sg08MEHYEPRyMO6vzFn+yE= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=zG2qmgB6DXXFbFEthdWezekiUiX40srjLv1CpeHkOow=; b=eHinc/YaxLLePph24M06pCnLgJ bE96zoPlL1xm/GGN3DoLBC7F5eOZAK1AyP4TFlhzEs7FjGqp1EnZFAHmN9snpWUrbctRpfk2+EeDT NYV155tbJAXBOvneD0/61fXySPQDdVfz+E1kimvMYRMi70YC0jf/9+sn2sTsssCKGQXCr7DkzV+rF AOLTa+l7bqxsXgFWAv3JZYs+Ta4VtJDowudjyKCzklAYzWPUixc/TommQ185GKTcUbh9UJDDNuMfN LPv13C2v7V5VTwh9TiA15UDaKxXL0bEywUIH9ie3fpeKgdNRcPU3S8d2bTB46/ui9IHBcD+3Ozsom TQk4iQ1Q==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eE-0000000A0iS-3uhT; Wed, 02 Apr 2025 18:17:10 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org Subject: [PATCH v2 00/11] Add folio_mk_pte() Date: Wed, 2 Apr 2025 19:16:54 +0100 Message-ID: <20250402181709.2386022-1-willy@infradead.org> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 4A3311C000C X-Stat-Signature: kwbcaw93h4crrm9zj16jifq4qirwu6n7 X-HE-Tag: 1743617833-727493 X-HE-Meta: U2FsdGVkX18zW7M5jGmdTkiMkL6Z4kwMN56z8ATLjYuFjOarGs8Sm4qZmATozUx1tLF5s/sBe4fRTGe8xbpEAyq4nyTUtq3dJ/DpiCD4uKUgIF+dqnbgm/SXuFRGtEPep3Lbji0oc4gFXU85KYUYjQgTUNllGIyPxN5VRsCHVt7fcuDknhHtt1ix/D0zu46KDx78sV7Ygf8SKSKItGCmxeGHuwF91o9yFhZIvOArY9Cxt5bAfZK+E8EyIjbYAfFP3pDceMIU/v2yhWhRfBSUZaxncjv1pObbzcDl2hBlqLzaKFcoVJwKRbr6I9cCfjwHbJ7QS8cMkvV7ozvgA041o6gzkIsuGc6BfFTzauT2RKypan6AbowHbDYsXcGkKOhMtuXHA0llpK4rklIlN4/jNhEV8jcwRLjyHovGK+MalwtBovx8vjfUzjFSHS2v7hN6cx4kWiwISmFGjfmAOaP98RPztemOGIrqnpaO5yfiHXogcqyMjg13TGkWf/l6Q8DP58X2iKE8v8sgLc2g5ks4kUWNS912UE4IzQFb/aS12BoXU3GUc7KY3L16z20wmPBKMwl6WD5PN2Oq0ZJ7D/brhXVfMcVIdJjpr6az46+yIisvm1RCrfO4IE1sC8GcskqC+1D31nqMdoUhigGcRIGjlRPgiV9ZIuCIEm7APfgI9hblxeqGQJVfLtY232ux8lFipYf8DLg5n68KHftn+dCPAX5oFtuFmN3gw2LhdzdyWTe3tGGQKj8LWIEX1qxMqzRhq8JRFg6SDwiRmkaylIsTCmjxWHCrDpssYKYeRqwpPOIGI8OXSoMSvYM/pQOYOSKIkxrPbEaqQhqr9+g1UXNjJutyAWVYmXHfKKEBgX9N1TcHcHr9CZWp8kK9QP9bRP04cS83gkWDtojK+nkxd1QaNHrvoQZ1vyUhRU1eT++KAsfjo0P1sTABlnrd4hA0XHVzn+X5+PzjAdsP8gtXChb tIArdxTW 7iQK8gDEf0uBg8w2uxUcGST8D+qU1eW7aM/NsogywZBNYHWCpFgw7wQy//DCdh3fEYSMM0r6GAyF1tnfIJ/PoJ7IqBUNDIA0L5NPPMzcqC2lMkGRw6pS+AQBO5QK5BYh92AmOQ5PinQaSYdutVpPcQQYCL6X6ELNi3vtBMsDOhtdS96SuJotzORUSzszuN8dPZEnT0nw++o0JHAm4RpXzp/8yFAeC8qzi690Y 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: Today if you have a folio and want to create a PTE that points to the first page in it, you have to convert from a folio to a page. That's zero-cost today but will be more expensive in the future. I didn't want to add folio_mk_pte() to each architecture, and I didn't want to lose any optimisations that architectures have from their own implementation of mk_pte(). Fortunately, most architectures have by now turned their mk_pte() into a fairly bland variant of pfn_pte(), but s390 has a special optimisation that needs to be moved into generic code in the first patch. At the end of this patch set, we have mk_pte() and folio_mk_pte() in mm.h and each architecture only has to implement pfn_pte(). We've also eliminated mk_huge_pte(), mk_huge_pmd() and mk_pmd(). Matthew Wilcox (Oracle) (11): mm: Set the pte dirty if the folio is already dirty mm: Introduce a common definition of mk_pte() sparc32: Remove custom definition of mk_pte() x86: Remove custom definition of mk_pte() um: Remove custom definition of mk_pte() mm: Make mk_pte() definition unconditional mm: Add folio_mk_pte() hugetlb: Simplify make_huge_pte() mm: Remove mk_huge_pte() mm: Add folio_mk_pmd() arch: Remove mk_pmd() arch/alpha/include/asm/pgtable.h | 7 ---- arch/arc/include/asm/hugepage.h | 2 - arch/arc/include/asm/pgtable-levels.h | 2 - arch/arm/include/asm/pgtable-3level.h | 1 - arch/arm/include/asm/pgtable.h | 1 - arch/arm64/include/asm/pgtable.h | 7 ---- arch/csky/include/asm/pgtable.h | 5 --- arch/hexagon/include/asm/pgtable.h | 3 -- arch/loongarch/include/asm/pgtable.h | 7 ---- arch/loongarch/mm/pgtable.c | 9 ----- arch/m68k/include/asm/mcf_pgtable.h | 6 --- arch/m68k/include/asm/motorola_pgtable.h | 6 --- arch/m68k/include/asm/sun3_pgtable.h | 6 --- arch/microblaze/include/asm/pgtable.h | 8 ---- arch/mips/include/asm/pgtable.h | 9 ----- arch/mips/mm/pgtable-32.c | 10 ----- arch/mips/mm/pgtable-64.c | 9 ----- arch/nios2/include/asm/pgtable.h | 6 --- arch/openrisc/include/asm/pgtable.h | 2 - arch/parisc/include/asm/pgtable.h | 6 --- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 - arch/powerpc/include/asm/pgtable.h | 3 +- arch/powerpc/mm/book3s64/pgtable.c | 5 --- arch/riscv/include/asm/pgtable-64.h | 2 - arch/riscv/include/asm/pgtable.h | 2 - arch/s390/include/asm/pgtable.h | 11 ------ arch/sh/include/asm/pgtable_32.h | 8 ---- arch/sparc/include/asm/pgtable_32.h | 15 +++----- arch/sparc/include/asm/pgtable_64.h | 2 - arch/um/include/asm/pgtable-2level.h | 1 - arch/um/include/asm/pgtable-4level.h | 9 ----- arch/um/include/asm/pgtable.h | 18 ++++----- arch/x86/include/asm/pgtable.h | 21 ++--------- arch/xtensa/include/asm/pgtable.h | 6 --- fs/dax.c | 3 +- include/asm-generic/hugetlb.h | 5 --- include/linux/huge_mm.h | 2 - include/linux/mm.h | 39 ++++++++++++++++++++ mm/debug_vm_pgtable.c | 18 +++------ mm/huge_memory.c | 11 +++--- mm/hugetlb.c | 18 ++++----- mm/khugepaged.c | 2 +- mm/memory.c | 10 +++-- mm/userfaultfd.c | 2 +- 44 files changed, 83 insertions(+), 243 deletions(-)