From patchwork Thu Mar 6 18:51:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 14005232 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C2BBC282D1 for ; Thu, 6 Mar 2025 18:51:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=WaaEEWK7o32ZFj2ujQVvXEBNWPRXati5x5ekVTslT+M=; b=rfX3tKrhLqeem9 jaPuJ2Vrojjt3HN8j6solNF/THS2fGnU3nJ84+dp9PEC/CJoKE/OSC0HDbKXOJCzr/sa69rDYW1Dk fHDLl7MmH8aap/IZJCp5j4JgSIrP4gPzT9XJd0aibJBzhUeRj9X6q7n9RjroniLEMkGSOhp8096bq UK4881Nm3QNNl1RzLtEeXK7j6nubcPJ/h8Kjd0hdtCsljDxfihRC9FscFc5YfAUua5foDNHiwGhoo sTtDz+CVoD52/bj1gjiknny64cNlS0NBWLCVqxtCpgx/JJwz4gou9bAzeZQwy3YZfEh+Fu5iXAhtO 6VR8tI+9GhUEQrO7AIow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tqGJy-0000000BuTz-2Vxs; Thu, 06 Mar 2025 18:51:50 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tqGJv-0000000BuSc-0SCT; Thu, 06 Mar 2025 18:51:48 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id D37E4A45015; Thu, 6 Mar 2025 18:46:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73E1BC4CEE0; Thu, 6 Mar 2025 18:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741287105; bh=/wpX+rodiPgNkc2E/+2EOJ8vtAUtpxXz9ICTWI7pMKs=; h=From:To:Cc:Subject:Date:From; b=P80r7Rsa2pkCu11363Fa/SyYTsTL5K11aoIfGVkUhXZXMZF9ghtejyVAEAn/9gYin 1wjIQSDGLefP2aOn0lF4nfOFQWYeL481ld2xteJKdOm4N0DyD3FCaFsp8v0/3LF+Zj A1q//tTu1zIkAikd8Mvn+6NSXoOT1YkxG40QhglljaBoNvOzWHiF8i1U7IHFop/QuY 5qG0votPJ3w9ptEMTqOjG9ejudqVaGGqjAr6pLD9gnSTU97J4z2wTm+bpnENlPeeCa JlGFrkz4pFB5qBl+yf6kzfEB+qI0NhdVqEy7aOxbZiiRw30qg1qYZpVJ1ch4THxRCE TD35zfcbQZ4wA== From: Mike Rapoport To: Andrew Morton Cc: Alexander Gordeev , Andreas Larsson , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Brian Cain , Catalin Marinas , Dave Hansen , "David S. Miller" , Dinh Nguyen , Geert Uytterhoeven , Gerald Schaefer , Guo Ren , Heiko Carstens , Helge Deller , Huacai Chen , Ingo Molnar , Jiaxun Yang , Johannes Berg , John Paul Adrian Glaubitz , Madhavan Srinivasan , Matt Turner , Max Filippov , Michael Ellerman , Michal Simek , Mike Rapoport , Palmer Dabbelt , Peter Zijlstra , Richard Weinberger , Russell King , Stafford Horne , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Vineet Gupta , Will Deacon , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 00/13] arch, mm: reduce code duplication in mem_init() Date: Thu, 6 Mar 2025 20:51:10 +0200 Message-ID: <20250306185124.3147510-1-rppt@kernel.org> X-Mailer: git-send-email 2.47.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250306_105147_284630_AACCF030 X-CRM114-Status: GOOD ( 14.25 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: "Mike Rapoport (Microsoft)" Hi, Every architecture has implementation of mem_init() function and some even more than one. All these release free memory to the buddy allocator, most of them set high_memory to the end of directly addressable memory and many of them set max_mapnr for FLATMEM case. These patches pull the commonalities into the generic code and refactor some of the mem_init() implementations so that many of them can be just dropped. Mike Rapoport (Microsoft) (13): arm: mem_init: use memblock_phys_free() to free DMA memory on SA1111 csky: move setup_initrd() to setup.c hexagon: move initialization of init_mm.context init to paging_init() MIPS: consolidate mem_init() for NUMA machines MIPS: make setup_zero_pages() use memblock nios2: move pr_debug() about memory start and end to setup_arch() s390: make setup_zero_pages() use memblock xtensa: split out printing of virtual memory layout to a function arch, mm: set max_mapnr when allocating memory map for FLATMEM arch, mm: set high_memory in free_area_init() arch, mm: streamline HIGHMEM freeing arch, mm: introduce arch_mm_preinit arch, mm: make releasing of memory to page allocator more explicit arch/alpha/mm/init.c | 8 ---- arch/arc/mm/init.c | 25 +---------- arch/arm/mm/init.c | 43 +------------------ arch/arm/mm/mmu.c | 2 - arch/arm/mm/nommu.c | 1 - arch/arm64/mm/init.c | 12 +----- arch/csky/kernel/setup.c | 43 +++++++++++++++++++ arch/csky/mm/init.c | 67 ------------------------------ arch/hexagon/mm/init.c | 32 ++------------ arch/loongarch/kernel/numa.c | 6 --- arch/loongarch/mm/init.c | 8 ---- arch/m68k/mm/init.c | 4 -- arch/m68k/mm/mcfmmu.c | 1 - arch/m68k/mm/motorola.c | 2 - arch/m68k/sun3/config.c | 1 - arch/microblaze/mm/init.c | 25 ----------- arch/mips/include/asm/mmzone.h | 2 - arch/mips/loongson64/numa.c | 7 ---- arch/mips/mm/init.c | 49 ++++------------------ arch/mips/sgi-ip27/ip27-memory.c | 9 ---- arch/nios2/kernel/setup.c | 3 +- arch/nios2/mm/init.c | 16 +------ arch/openrisc/mm/init.c | 6 --- arch/parisc/mm/init.c | 4 -- arch/powerpc/kernel/setup-common.c | 3 -- arch/powerpc/mm/mem.c | 18 +------- arch/riscv/mm/init.c | 5 +-- arch/s390/mm/init.c | 18 +------- arch/sh/mm/init.c | 10 ----- arch/sparc/mm/init_32.c | 31 +------------- arch/sparc/mm/init_64.c | 4 -- arch/um/include/shared/mem_user.h | 1 - arch/um/kernel/mem.c | 9 ++-- arch/um/kernel/physmem.c | 12 ------ arch/um/kernel/um_arch.c | 2 - arch/x86/include/asm/highmem.h | 3 -- arch/x86/include/asm/numa.h | 4 -- arch/x86/include/asm/numa_32.h | 13 ------ arch/x86/kernel/setup.c | 2 - arch/x86/mm/Makefile | 2 - arch/x86/mm/highmem_32.c | 34 --------------- arch/x86/mm/init_32.c | 41 ++---------------- arch/x86/mm/init_64.c | 7 ++-- arch/x86/mm/numa_32.c | 3 -- arch/xtensa/mm/init.c | 66 +++++++---------------------- include/asm-generic/memory_model.h | 5 ++- include/linux/memblock.h | 1 - include/linux/mm.h | 13 +----- mm/internal.h | 3 +- mm/memblock.c | 3 +- mm/memory.c | 16 ------- mm/mm_init.c | 58 ++++++++++++++++++++++---- mm/nommu.c | 6 --- 53 files changed, 151 insertions(+), 618 deletions(-) delete mode 100644 arch/x86/include/asm/numa_32.h delete mode 100644 arch/x86/mm/highmem_32.c base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6 Acked-by: Dave Hansen