From patchwork Mon Mar 25 14:55:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 13602366 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 F25EBCD11BF for ; Mon, 25 Mar 2024 14:56:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A1136B007B; Mon, 25 Mar 2024 10:56:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 478986B0082; Mon, 25 Mar 2024 10:56:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33F7F6B0083; Mon, 25 Mar 2024 10:56:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 20B146B007B for ; Mon, 25 Mar 2024 10:56:16 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B0DE9A07AB for ; Mon, 25 Mar 2024 14:56:15 +0000 (UTC) X-FDA: 81935861910.21.50ABBFE Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf10.hostedemail.com (Postfix) with ESMTP id 650CCC0004 for ; Mon, 25 Mar 2024 14:56:13 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf10.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711378573; 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=eMc2UJynNUHr4A2DQbB5cpDB7srdGQ9QrRzhAGgcgAE=; b=RBPrRLlWEBLv+4TeWTTHCxqnnPguLN4UXn5FDv1wAAiMtf+NjcYivvA8OrZmTCQKT1AsGc EcZMH6ZghKuwu3KKTujk12w8iiWpURU+Sox86nYItkDiMLbhTmcQ7KzZ5BI/1tPNih6a2k WrymRpYmkqOY1Zfa2M8mb3KZ1gfcinc= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=csgroup.eu; spf=pass (imf10.hostedemail.com: domain of christophe.leroy@csgroup.eu designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@csgroup.eu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711378573; a=rsa-sha256; cv=none; b=r/bE55XaTuJzpSKjwoWQn4ZNqjd3Kb1MV5vrlv4DWo/0YD/h4LaA+hE2VVsDwr/9I9Mm2q SeIM0YLCQYytCdn3tqHxn1q8ypgudYau38R/49cJuBGjrHqoddfnTRRGlYYLbK4yuijBoV fSVkKDrrmIvXU2AUqWl+84DU7JBNWpQ= Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4V3GGL3yshz9sq1; Mon, 25 Mar 2024 15:56:10 +0100 (CET) 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 D0GLhUgBDpEJ; Mon, 25 Mar 2024 15:56:10 +0100 (CET) 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 4V3GGK1NtXz9sTD; Mon, 25 Mar 2024 15:56:09 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2BF598B770; Mon, 25 Mar 2024 15:56:09 +0100 (CET) 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 ILrl3yQG2tup; Mon, 25 Mar 2024 15:56:09 +0100 (CET) Received: from PO20335.idsi0.si.c-s.fr (unknown [172.25.230.108]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 0882E8B765; Mon, 25 Mar 2024 15:56:09 +0100 (CET) From: Christophe Leroy To: Andrew Morton , Jason Gunthorpe , Peter Xu Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org Subject: [RFC PATCH 0/8] Reimplement huge pages without hugepd on powerpc 8xx Date: Mon, 25 Mar 2024 15:55:53 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1711378567; l=4005; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=1QUfp3pSHGOWHPlUD77voOXNtRwi/Hp1Mh0eHpyYI3M=; b=C2sC3KyJ+kZ+6wF7ahqvDmuEGRLy5haI+SS54JsNZwoPEOE39owJkJ0ambGrjV6GLYJixynOt hLZawct1NZMDswMbTvR/oOyV7gzS1FnN6AeaEeEOZQL1j80Ng/rUHOW X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 650CCC0004 X-Stat-Signature: ru53t4wa84ccc9qsq7ury19j8mpbwso1 X-Rspam-User: X-HE-Tag: 1711378573-515863 X-HE-Meta: U2FsdGVkX1+68ikAXkhb7nO+d9u6xbOudG9L2SsEWIY+MYBNB9wJ8LgGNCYvgUQb9GlUxfknNUFqKhqx6zQDVjTw02Nj+fgvuSweD5DoWF9hCHteC9ICrhdr+2DZtsyNCOjmsQr58WRWl8I7Hp6vR6oZZUZW/CkDnoTRGMP45tKMzj4j+Djy/kbhZPN6mtMoaOb5O6RV4nYChpicHAvv5Du2i3QTtynulE/j7Wkbjd+z3CtNwj372+rR2qQQ9kkqq4suwwj9T9dsGeYULMV54z+YwYR7qvYHKvj3k8GbNWeQ/joHtxMnakZXlNiINeHHe9zFUbMzFmi7spCpHVkWlJJn56B28AsX6c6lH4iehU5jB+qO5qvXfqpxp0K8KfRjt4vIw7az8w6JYrrEDdpvZb/nBvsgLbo+y0YF5bEbxKdHXoqwcapHJgbT2ctCbczB90+LsDmKpegn7CIQldLgVJPG71ydds+FBS9nZpqidWZmD1Z8UtNMqcQzmIVRZxmBLIw1FLF5MvrfxFWrx4uGIXYwvAp42H4NKv7UwOrHuO/JLdINDlHIFGr22bvU3axEkPI7in4ms0wXrRz6SMhGUfDT/sSd3hlMF+P4+I8b/7R39XRlAbvGBMJayIFdCKpMH64qbVRXSEMWxIUywlCkIpLBY8tM3mVFRPPo4jIMYEM3sVv2zlVGUvDVCQngiUb6jsVWZgoX4zPml8MjPcd0MT251lydV0m9dsdputaIXM9bYUN+pYK0xeyztCPzZEaj/++fPt4Rt9QsDeXZnW7xL2yGEifmFelyABQc6Ignkvz7vqu8w1uNx+nRnV9Ceaabngtw78K+S+MCU0XyXOledEDs4cJEEGCUaWCfNrtSIQSCFdA+EgE3cWIC/zN2kMtgHX4R5RyZizkVIAD++oqR3/JqrA6jFwf90sWrvVvbZ1bUVRm3zN9feOQn8Gx+kc5GBnwHcnO4T0KjHt9S3Pv CkUcSxWN OiMNRtoplICSZ+NZlHpMQqVwgbOnxtjpEsUhGzLOlIcs0dPTVhTrjSegRXOHPi/rJRHOx 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 series reimplements hugepages with hugepd on powerpc 8xx. 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. There are probably several ways to implement stuff, so feedback is very welcome. Christophe Leroy (8): 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: Remove support for 8M pages powerpc/8xx: Add back support for 8M pages using contiguous PTE entries arch/arm64/include/asm/hugetlb.h | 2 +- arch/arm64/include/asm/pgtable.h | 2 +- arch/arm64/mm/hugetlbpage.c | 2 +- arch/parisc/mm/hugetlbpage.c | 2 +- arch/powerpc/Kconfig | 1 - arch/powerpc/include/asm/hugetlb.h | 13 +++- .../include/asm/nohash/32/hugetlb-8xx.h | 54 ++++++++--------- arch/powerpc/include/asm/nohash/32/pgalloc.h | 2 + arch/powerpc/include/asm/nohash/32/pte-8xx.h | 59 +++++++++++++------ arch/powerpc/include/asm/nohash/pgtable.h | 12 ++-- arch/powerpc/include/asm/page.h | 5 -- arch/powerpc/include/asm/pgtable.h | 1 + arch/powerpc/kernel/head_8xx.S | 10 +--- arch/powerpc/mm/hugetlbpage.c | 23 +++++++- arch/powerpc/mm/nohash/8xx.c | 46 +++++++-------- arch/powerpc/mm/pgtable.c | 26 +++++--- arch/powerpc/mm/pgtable_32.c | 2 +- arch/powerpc/platforms/Kconfig.cputype | 2 + arch/riscv/include/asm/pgtable.h | 2 +- arch/riscv/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 | 4 +- include/linux/mm.h | 12 ++-- include/linux/pgtable.h | 2 +- include/linux/swapops.h | 2 +- kernel/events/core.c | 2 +- mm/damon/vaddr.c | 6 +- mm/filemap.c | 2 +- mm/gup.c | 2 +- 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/pgalloc-track.h | 2 +- mm/userfaultfd.c | 6 +- 45 files changed, 229 insertions(+), 180 deletions(-)