From patchwork Fri May 17 18:59:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13667308 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 E7C87C04FFE for ; Fri, 17 May 2024 19:00:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78CBF6B0083; Fri, 17 May 2024 15:00:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 73C496B0088; Fri, 17 May 2024 15:00:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 604046B0089; Fri, 17 May 2024 15:00:08 -0400 (EDT) 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 3EF7A6B0083 for ; Fri, 17 May 2024 15:00:08 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DF8F51A0479 for ; Fri, 17 May 2024 19:00:07 +0000 (UTC) X-FDA: 82128802854.18.5F03D39 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf01.hostedemail.com (Postfix) with ESMTP id 7E27140026 for ; Fri, 17 May 2024 19:00:05 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715972405; 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; bh=EiQjs46Rd03ftPBk9RhmOsFl3QfDTDsU6wwGPPw4WWo=; b=ACD3a2CE3co4JBcf869GZIAk15WdJx6HtC7jPPa4Ma2V0jjiTeuVc6dRkoV3dz+jCDJ8pS sgE1y/Nshr44PFKPfn80+A4H5Zo54YUD4T4tX/G5coHm7KZFS4GNRFBYMXTja+KGsvEwT1 /5qhqwcy1ZtWV2pMPQWGJYz6mFLbcb0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715972405; a=rsa-sha256; cv=none; b=KfjKGmThcO+mBG7erCbqhBvkrFQ7WO81YmiHdw7rlrVJbk14dnqiQFElndx6ML0xF33p2t f8H1apiKWPG4QtuI8g3+BQXAggkVxf2YXOmFQjplbZKEwpmJTNV9OlbJQ8k6ldtJkDcFR5 WM7nEsPxm74cS/n9iT7y3DdU/qGXsog= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu; dmarc=pass (policy=quarantine) header.from=csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4Vgx9H3Jflz9st4; Fri, 17 May 2024 21:00:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h8Eu0JPkjFau; Fri, 17 May 2024 21:00:03 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4Vgx9H2DPjz9st0; Fri, 17 May 2024 21:00:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 42E4B8B783; Fri, 17 May 2024 21:00:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id kTwwTQayvkPH; Fri, 17 May 2024 21:00:03 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.232.121]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A6FB58B766; Fri, 17 May 2024 21:00:02 +0200 (CEST) From: Christophe Leroy To: Andrew Morton , Jason Gunthorpe , Peter Xu , Oscar Salvador , Michael Ellerman , Nicholas Piggin Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH v2 00/20] Reimplement huge pages without hugepd on powerpc (8xx, e500, book3s/64) Date: Fri, 17 May 2024 20:59:54 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1715972395; l=6993; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=nXgiWCnTh81NG+HIgJTsNmlUbBq2v6oarBwpgv/bUOk=; b=JJc9xjsdS8vG4cTo/Ay4rt3hpTzOoF+49PWU37xMh+OtrrREx7xjwaJB5Mb+tWOmexAHZkx0S g8PFoT08NPSBoJdlf5dx+XAf+WUko8IAO1YC5ivO0qgat4VyLrQHX6W X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7E27140026 X-Rspam-User: X-Stat-Signature: 5bbd53rmbqc17wopmyqicu9r7u7agpia X-HE-Tag: 1715972405-245103 X-HE-Meta: U2FsdGVkX1+tBKjnDZUIBnL9ir/Lp17KlPlLEtEOKIJBU2/GQcrTZ0UAdhiPoms/Y+uogbRnwXnZdhO8VfSLKwAvd0eEFxl2MnO3GLbyyqRPvFo1bfstwMZOYVudBiH+9Emr3K+pFxcIzRAVVVE4n9nG8FsvbTtCh/UeLa1nhnLcRVbW/giKIz7wYpOGC5DQBnpeyxrcT7hRBOXwJn6xYohBQan+Cc2nqCHmy1MbooT8dcIxvbgIPLFJ8BElFeiBuDMEgBDs50qMg7lm3FrqeaWKC07m6ZMnZ3Ebjq8hkSwTL0O/fPMrWNV/Oi6Jo340B5j8PGpeRy3xv+530OEOmBeVwEQTqWV9apuhNAGLmvW9GHDT0pKzKtYxMSqfyr3cRhNMsHMDQz/Zt2evTydFPiApMV/g1YcxJ1OkEGDjcQhFnrUR/fHLy86SYp3kUYNjwZEn8kcNAS8Kypww8jqGLUmOBet9GtKlx1/fAf1h8qnlNoA7wiu4lRwmqgEKR90kx+fksDop5g+2Kohw2PAemC10QDsCECQz5W045KzhsMKd1G9RvhpyO8UckV+FS/FD7e0cYNv9065TJ/wpA/xx/PxaDi69rSL8bdG0SVKhE7BaNENVHfYaBh58mi6qtZYB+6NCnrYpymliENDRveb9o9I+5Ut/YIB81+5CqG7EUL9LRtdln5F3+4b1VJmcFGOgRYLHViRVi/5KNZbblBOB5+cAObji7z6kuVaSFeYPk5i7iRU8cLgxxGG+FlLhELyCa/6Eduui+peFt4hbSaqzqt/WqHF2tnnBeqgU4drCluDnkSMTYK6XgvaU4PZ16h9kQQlekVJBedk2HQdjdZsTtxhBYb/eeXTlUfeDxIihzDuXSIs39WQGTkvzlm2rCS2zH75/RvUS/6wm94hXz2JXzvuDoUzSXztixgTR8imxAELOMlU4jmVuY182Bdr091+WpWNwN6Y6WtU7uX5okG/ POMJYuI1 2fuxwT9vSvWUB8DmeUKPOIjLGHZJT56bVavMSuDDcF/5CygfMQ55VKFyKsuoEL2s/vcyj 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: This is the continuation of the RFC v1 series "Reimplement huge pages without hugepd on powerpc 8xx". It now get rid of hugepd completely after handling also e500 and book3s/64 Unlike most architectures, powerpc 8xx HW requires a two-level pagetable topology for all page sizes. So a leaf PMD-contig approach is not feasible as such. Possible sizes are 4k, 16k, 512k and 8M. First level (PGD/PMD) covers 4M per entry. For 8M pages, two PMD entries must point to a single entry level-2 page table. Until now that was done using hugepd. This series changes it to use standard page tables where the entry is replicated 1024 times on each of the two pagetables refered by the two associated PMD entries for that 8M page. At the moment it has to look into each helper to know if the hugepage ptep is a PTE or a PMD in order to know it is a 8M page or a lower size. I hope this can me handled by core-mm in the future. For e500 and book3s/64 there are less constraints because it is not tied to the HW assisted tablewalk like on 8xx, so it is easier to use leaf PMDs (and PUDs). On e500 the supported page sizes are 4M, 16M, 64M, 256M and 1G. All at PMD level on e500/32 and mix of PMD and PUD for e500/64. We encode page size with 4 available bits in PTE entries. On e300/32 PGD entries size is increases to 64 bits in order to allow leaf-PMD entries because PTE are 64 bits on e500. On book3s/64 only the hash-4k mode is concerned. It supports 16M pages as cont-PMD and 16G pages as cont-PUD. In other modes (radix-4k, radix-6k and hash-64k) the sizes match with PMD and PUD sizes so that's just leaf entries. Christophe Leroy (20): mm: Provide pagesize to pmd_populate() mm: Provide page size to pte_alloc_huge() mm: Provide pmd to pte_leaf_size() mm: Provide mm_struct and address to huge_ptep_get() powerpc/mm: Allow hugepages without hugepd powerpc/8xx: Fix size given to set_huge_pte_at() powerpc/8xx: Rework support for 8M pages using contiguous PTE entries powerpc/8xx: Simplify struct mmu_psize_def powerpc/mm: Remove _PAGE_PSIZE powerpc/mm: Fix __find_linux_pte() on 32 bits with PMD leaf entries powerpc/mm: Complement huge_pte_alloc() for all non HUGEPD setups powerpc/64e: Remove unneeded #ifdef CONFIG_PPC_E500 powerpc/64e: Clean up impossible setups powerpc/e500: Remove enc field from struct mmu_psize_def powerpc/85xx: Switch to 64 bits PGD powerpc/e500: Encode hugepage size in PTE bits powerpc/e500: Use contiguous PMD instead of hugepd powerpc/64s: Use contiguous PMD/PUD instead of HUGEPD powerpc/mm: Remove hugepd leftovers mm: Remove CONFIG_ARCH_HAS_HUGEPD arch/arm/include/asm/hugetlb-3level.h | 2 +- arch/arm64/include/asm/hugetlb.h | 2 +- arch/arm64/include/asm/pgtable.h | 2 +- arch/arm64/mm/hugetlbpage.c | 4 +- arch/parisc/mm/hugetlbpage.c | 2 +- arch/powerpc/Kconfig | 1 - arch/powerpc/include/asm/book3s/32/pgalloc.h | 2 - arch/powerpc/include/asm/book3s/64/hash-4k.h | 15 - arch/powerpc/include/asm/book3s/64/hash.h | 38 +- arch/powerpc/include/asm/book3s/64/hugetlb.h | 38 -- .../include/asm/book3s/64/pgtable-4k.h | 34 -- .../include/asm/book3s/64/pgtable-64k.h | 20 - arch/powerpc/include/asm/hugetlb.h | 26 +- .../include/asm/nohash/32/hugetlb-8xx.h | 58 +-- arch/powerpc/include/asm/nohash/32/mmu-8xx.h | 9 +- arch/powerpc/include/asm/nohash/32/pgalloc.h | 2 + arch/powerpc/include/asm/nohash/32/pte-40x.h | 3 - arch/powerpc/include/asm/nohash/32/pte-44x.h | 3 - arch/powerpc/include/asm/nohash/32/pte-85xx.h | 3 - arch/powerpc/include/asm/nohash/32/pte-8xx.h | 64 ++- .../powerpc/include/asm/nohash/hugetlb-e500.h | 36 +- arch/powerpc/include/asm/nohash/mmu-e500.h | 4 - arch/powerpc/include/asm/nohash/pgalloc.h | 2 - arch/powerpc/include/asm/nohash/pgtable.h | 45 +- arch/powerpc/include/asm/nohash/pte-e500.h | 22 +- arch/powerpc/include/asm/page.h | 32 -- arch/powerpc/include/asm/pgtable-be-types.h | 10 - arch/powerpc/include/asm/pgtable-types.h | 13 +- arch/powerpc/include/asm/pgtable.h | 3 + arch/powerpc/kernel/head_85xx.S | 33 +- arch/powerpc/kernel/head_8xx.S | 10 +- arch/powerpc/mm/book3s64/hash_utils.c | 11 +- arch/powerpc/mm/book3s64/pgtable.c | 12 - arch/powerpc/mm/hugetlbpage.c | 450 ++---------------- arch/powerpc/mm/init-common.c | 8 +- arch/powerpc/mm/kasan/8xx.c | 15 +- arch/powerpc/mm/nohash/8xx.c | 46 +- arch/powerpc/mm/nohash/book3e_pgtable.c | 4 +- arch/powerpc/mm/nohash/tlb.c | 172 ++----- arch/powerpc/mm/nohash/tlb_low_64e.S | 257 ++-------- arch/powerpc/mm/pgtable.c | 94 ++-- arch/powerpc/mm/pgtable_32.c | 2 +- arch/riscv/include/asm/hugetlb.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- arch/riscv/mm/hugetlbpage.c | 4 +- arch/s390/include/asm/hugetlb.h | 2 +- arch/s390/mm/hugetlbpage.c | 2 +- arch/sh/mm/hugetlbpage.c | 2 +- arch/sparc/include/asm/pgtable_64.h | 2 +- arch/sparc/mm/hugetlbpage.c | 4 +- fs/hugetlbfs/inode.c | 2 +- fs/proc/task_mmu.c | 8 +- fs/userfaultfd.c | 2 +- include/asm-generic/hugetlb.h | 2 +- include/linux/hugetlb.h | 10 +- include/linux/mm.h | 12 +- include/linux/pgtable.h | 2 +- include/linux/swapops.h | 2 +- kernel/events/core.c | 2 +- mm/Kconfig | 10 - mm/damon/vaddr.c | 6 +- mm/filemap.c | 2 +- mm/gup.c | 105 +--- mm/hmm.c | 2 +- mm/hugetlb.c | 46 +- mm/internal.h | 2 +- mm/memory-failure.c | 2 +- mm/memory.c | 19 +- mm/mempolicy.c | 2 +- mm/migrate.c | 4 +- mm/mincore.c | 2 +- mm/pagewalk.c | 57 +-- mm/pgalloc-track.h | 2 +- mm/userfaultfd.c | 6 +- 74 files changed, 494 insertions(+), 1444 deletions(-)