From mboxrd@z Thu Jan 1 00:00:00 1970 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8ED6D2502E for ; Sun, 11 Jan 2026 08:21:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 188456B0088; Sun, 11 Jan 2026 03:21:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 135FD6B0089; Sun, 11 Jan 2026 03:21:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00DA26B008A; Sun, 11 Jan 2026 03:21:27 -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 E1D1D6B0088 for ; Sun, 11 Jan 2026 03:21:27 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 025E1C1B3F for ; Sun, 11 Jan 2026 08:21:26 +0000 (UTC) X-FDA: 84318988614.23.40317E5 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf04.hostedemail.com (Postfix) with ESMTP id 5F00740003 for ; Sun, 11 Jan 2026 08:21:25 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fqKHBj52; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of rppt@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1768119685; a=rsa-sha256; cv=none; b=L889bymz+4J3izSSobknAwxEDQ+AStCRGjUyqREgXh8cBEDifxpzPVwT4TolCdrEgEtfmP T7pi8BSCl6U+SJzkuubk09n/PMhVfhRtP49AYbFBiltdfGtrywD21/0SmQkpIKGNSuKbG4 VVMYqkLEUEHBdyhzrq54t3zT1mhmqUg= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fqKHBj52; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of rppt@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1768119685; 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=sNY1u8U36qiG0h+Ok0Z0ctU2PTuG5/hsQY7jBFGhezQ=; b=Mwvalg4lXW8iRchk1gY6348HFeMJdy6li5GeJ14+pRSPCGYhzHS2pmV0MkTNa6JYEg4tpW sgt0PM/1uC9gKiQ7xUm89mQPVm/PJ1w6ZS9a7nH8XzUUQ9hDKK3oDGz9KDR/OG+rSpZXZj XusbWGTOiCsxEfsS+Gx1l84c/kj2kGM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id E369543F6E; Sun, 11 Jan 2026 08:21:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1837CC4CEF7; Sun, 11 Jan 2026 08:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768119683; bh=15VB+6hE09IpORerfJ9cs3QzayYtdIP5ByWTlGt3qZ0=; h=From:To:Cc:Subject:Date:From; b=fqKHBj520f2MDgk71DmE5pqtB/pBMemGe6ljrad1JZT4TjuKzKTHs3xUpJ0K4Tlv7 kS7/A7Qj7f6FHcIqZOCnTKWbxC4liAYLtpcFU2lTPOu6nAiYlDoYoUkFsbagYk4hjx /oeAeIyD4g/6QlmHRXuiPhGuV0z/TfFiVYiZjEtj2+8KVb2ZpA5QnWSqMsk5vvuf9z 2zZGEX+f1wmTWFlirbnVw4Z57ZhFPuOpza3yBonfV6hLgXOimHNXs2/zTsLzh0SIA+ XoqGttk/l45ZEV1dW3wg6KCyo98ksi4A7G6uUd+LsrXwkQfZV/ycd0xkOa/n8lvRu2 u3qAfKtz7b0cw== From: Mike Rapoport To: Andrew Morton Cc: Alex Shi , Alexander Gordeev , Andreas Larsson , Borislav Petkov , Brian Cain , "Christophe Leroy (CS GROUP)" , Catalin Marinas , "David S. Miller" , Dave Hansen , David Hildenbrand , Dinh Nguyen , Geert Uytterhoeven , Guo Ren , Heiko Carstens , Helge Deller , Huacai Chen , Ingo Molnar , Johannes Berg , John Paul Adrian Glaubitz , Jonathan Corbet , Klara Modin , "Liam R. Howlett" , Lorenzo Stoakes , Magnus Lindholm , Matt Turner , Max Filippov , Michael Ellerman , Michal Hocko , Michal Simek , Mike Rapoport , Muchun Song , Oscar Salvador , Palmer Dabbelt , Pratyush Yadav , Richard Weinberger , Ritesh Harjani , Russell King , Stafford Horne , Suren Baghdasaryan , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Vineet Gupta , Vlastimil Babka , Will Deacon , x86@kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-um@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, sparclinux@vger.kernel.org Subject: [PATCH v3 00/29] arch, mm: consolidate hugetlb early reservation Date: Sun, 11 Jan 2026 10:20:34 +0200 Message-ID: <20260111082105.290734-1-rppt@kernel.org> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Stat-Signature: idpznx6o6h3zpraxfbkc8fmnd51ct4xz X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5F00740003 X-HE-Tag: 1768119685-426852 X-HE-Meta: U2FsdGVkX1/otHWI+QoZvVpOxoEDoRQjBdD3P6IeBWXai1wf27A7Se1+c0LXMqZjHzM01WpdAkR1cMb35dpuc6zijtAOBxfimHOJ8YkL1PfX3Pk/g2BFZi+ZE+XaGy6OzfEV1AXr0zyKolMbfxhPyei7PXfBlkBmjDwJHA1sLVS3zPOqMNIGWiYhZZEZKSKZdpY6FaA94XO+t0AlOvhL9wbl706FyFYNcWRKm94/zLj/YYWq/giej5ozVik2f2VssXH5rQH2Y5aNb8+cyB3fth+UCLcxUqaFucMQRVw4kAHt1P20RyFfx/I8yvgehIt3u6qNfkIzJvMkvFs00KbSkehAj7z+HbDXUD87SNUK3vDLGebuACewV2R+qpAaS8NDvdMJS/4bFd0xpcNMV4J7I7p674GPWtk9kSVP3OsMI2DAq8YdvJ60/5gtf89eVqTkRcxkaMmy7z+US4I5PHTtRaDWRVWLyrQlyz2T//wSk15bzfhuyXLR1EeRHYPcNyng1lSu2CNIsc7N85ciPBN/+GG+ETZ/fj8svC+t52K1cv0yF/Q7RhWqyg1YCJUhyClxatTI3nPunAg1A3/CLN6OOVe6v/zn2IaS+XMMUzecEydhSj9xw34iTgbijppVjH1ejuKeF2Mklsxlfa2kr2KKAE6gXpDdhvQYFrMobDkUkCWmqp+8dqBQavJYoNYKdUJyXRBFISF2Zbm1G07/4NrF1ThWpGQPdcXf1M5I4y9wA9EH8QJReeIZQBL5AnQmyGhAu7GFmRLt6vqmH+u7sfq0qF/T6713h51wKA9k8PJaMSMrBV51kOnuMglg8glVhQ5PVncFu/+KuSaDTK4/om+j554MocDL/ecpq9gzr+QCqQEnkEmYMSEtOFCh+ic8Qlxz9DTHQw5zUjf7P7Llwu/8KR6LN+E1/OtCCDFOOpfNLMX2kBgycjcNKlLvrGIw5m7W2Ccq5pNSvyxzjH5Vbt4 Fa+wzNW3 SYRyi346YMLmNN6lIm5kSdPOOAMmFrrZfJhSoen/B5MafEfE4owfoVrtpWUMT3wwiA/MRk0J0sMvgqNn9bzwwQ9OVpi94bBNbFZamC0j4P3sZ5We4phGP4cqQlm3NM0hxxQ+ESkfNTVyHaKk0/enC08MLNU6EEzEdcfCJzqRawROyGamxwcnTHjmhDunOggX32+N8PIJANthYOksk7A6nAhZj/MVK7iig+9FnA99XUaDJg4rglAbNzJxvA+jdVN+YyBuWD3jH+3YG7t54p7xjQNrpKt77t2WHro9eXnr0PDsHEpCcc0lqCaXLtg== 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: "Mike Rapoport (Microsoft)" Hi, Order in which early memory reservation for hugetlb happens depends on architecture, on configuration options and on command line parameters. Some architectures rely on the core MM to call hugetlb_bootmem_alloc() while others call it very early to allow pre-allocation of HVO-style vmemmap. When hugetlb_cma is supported by an architecture it is initialized during setup_arch() and then later hugetlb_init code needs to understand did it happen or not. To make everything consistent and unified, both reservation of hugetlb memory from bootmem and creation of CMA areas for hugetlb must be called from core MM initialization and it would have been a simple change. However, HVO-style pre-initialization ordering requirements slightly complicate things and for HVO pre-init to work sparse and memory map should be initialized after hugetlb reservations. This required pulling out the call to free_area_init() out of setup_arch() path and moving it MM initialization and this is what the first 23 patches do. These changes are deliberately split into per-arch patches that change how the zone limits are calculated for each architecture and the patches 22 and 23 just remove the calls to free_area_init() and sprase_init() from arch/*. Patch 24 is a simple cleanup for MIPS. Patches 25 and 26 actually consolidate hugetlb reservations and patches 27 and 28 perform some aftermath cleanups. I tried to trim the distribution list and although it's still quite long if you feel that someone was wrongly excluded please add them back. The changes also available in git: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git/log/?h=hugetlb-init/v3 v3 changes: * fix empty_zero_page initialization on arm * fix ZONE_DMA limit calculation on powerpc * add Acks v2: https://lore.kernel.org/all/20260102070005.65328-1-rppt@kernel.org * move the hugetlb and memory map initializaion to mm_core_init_early() * add Acks v1: https://lore.kernel.org/all/20251228124001.3624742-1-rppt@kernel.org Klara Modin (1): arm: make initialization of zero page independent of the memory map Mike Rapoport (Microsoft) (28): alpha: introduce arch_zone_limits_init() arc: introduce arch_zone_limits_init() arm: introduce arch_zone_limits_init() arm64: introduce arch_zone_limits_init() csky: introduce arch_zone_limits_init() hexagon: introduce arch_zone_limits_init() loongarch: introduce arch_zone_limits_init() m68k: introduce arch_zone_limits_init() microblaze: introduce arch_zone_limits_init() mips: introduce arch_zone_limits_init() nios2: introduce arch_zone_limits_init() openrisc: introduce arch_zone_limits_init() parisc: introduce arch_zone_limits_init() powerpc: introduce arch_zone_limits_init() riscv: introduce arch_zone_limits_init() s390: introduce arch_zone_limits_init() sh: introduce arch_zone_limits_init() sparc: introduce arch_zone_limits_init() um: introduce arch_zone_limits_init() x86: introduce arch_zone_limits_init() xtensa: introduce arch_zone_limits_init() arch, mm: consolidate initialization of nodes, zones and memory map arch, mm: consolidate initialization of SPARSE memory model mips: drop paging_init() x86: don't reserve hugetlb memory in setup_arch() mm, arch: consolidate hugetlb CMA reservation mm/hugetlb: drop hugetlb_cma_check() Revert "mm/hugetlb: deal with multiple calls to hugetlb_bootmem_alloc" .../driver-api/cxl/linux/early-boot.rst | 2 +- Documentation/mm/memory-model.rst | 3 -- .../translations/zh_CN/mm/memory-model.rst | 2 - arch/alpha/kernel/setup.c | 1 - arch/alpha/mm/init.c | 16 ++++---- arch/arc/mm/init.c | 37 +++++++++--------- arch/arm/include/asm/pgtable.h | 4 +- arch/arm/mm/init.c | 25 ++---------- arch/arm/mm/mmu.c | 10 +---- arch/arm/mm/nommu.c | 10 +---- arch/arm64/include/asm/hugetlb.h | 2 - arch/arm64/mm/hugetlbpage.c | 10 ++--- arch/arm64/mm/init.c | 39 ++++++++----------- arch/csky/kernel/setup.c | 16 ++++---- arch/hexagon/mm/init.c | 19 +++------ arch/loongarch/include/asm/pgtable.h | 2 - arch/loongarch/kernel/setup.c | 10 ----- arch/loongarch/mm/init.c | 6 +-- arch/m68k/mm/init.c | 8 ++-- arch/m68k/mm/mcfmmu.c | 3 -- arch/m68k/mm/motorola.c | 6 +-- arch/m68k/mm/sun3mmu.c | 9 ----- arch/microblaze/mm/init.c | 22 +++++------ arch/mips/include/asm/pgalloc.h | 2 - arch/mips/include/asm/pgtable.h | 2 +- arch/mips/kernel/setup.c | 15 +------ arch/mips/loongson64/numa.c | 10 ++--- arch/mips/mm/init.c | 8 +--- arch/mips/sgi-ip27/ip27-memory.c | 8 +--- arch/nios2/mm/init.c | 12 +++--- arch/openrisc/mm/init.c | 10 +---- arch/parisc/mm/init.c | 11 +----- arch/powerpc/include/asm/hugetlb.h | 5 --- arch/powerpc/include/asm/setup.h | 4 ++ arch/powerpc/kernel/setup-common.c | 1 - arch/powerpc/mm/hugetlbpage.c | 11 ++---- arch/powerpc/mm/mem.c | 27 +++++-------- arch/powerpc/mm/numa.c | 2 - arch/riscv/mm/hugetlbpage.c | 8 ++++ arch/riscv/mm/init.c | 10 +---- arch/s390/kernel/setup.c | 2 - arch/s390/mm/hugetlbpage.c | 8 ++++ arch/s390/mm/init.c | 13 +++---- arch/sh/mm/init.c | 12 +++--- arch/sparc/mm/init_64.c | 17 +++----- arch/sparc/mm/srmmu.c | 17 ++++---- arch/um/kernel/mem.c | 10 ++--- arch/x86/kernel/setup.c | 5 --- arch/x86/mm/hugetlbpage.c | 8 ++++ arch/x86/mm/init.c | 8 +--- arch/x86/mm/init_32.c | 2 - arch/x86/mm/init_64.c | 4 -- arch/x86/mm/mm_internal.h | 1 - arch/xtensa/mm/init.c | 14 +++---- include/linux/hugetlb.h | 12 ++---- include/linux/mm.h | 5 ++- include/linux/mmzone.h | 2 - init/main.c | 1 + mm/hugetlb.c | 13 ------- mm/hugetlb_cma.c | 33 ++++++++-------- mm/hugetlb_cma.h | 5 --- mm/hugetlb_vmemmap.c | 11 ------ mm/internal.h | 6 +++ mm/mm_init.c | 20 ++++++---- 64 files changed, 223 insertions(+), 414 deletions(-) base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 -- 2.51.0