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]) by smtp.lore.kernel.org (Postfix) with ESMTP id E89FEC282DE for ; Thu, 13 Mar 2025 13:50:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3075A280006; Thu, 13 Mar 2025 09:50:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B5FF280005; Thu, 13 Mar 2025 09:50:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 156BD280006; Thu, 13 Mar 2025 09:50:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EB33F280005 for ; Thu, 13 Mar 2025 09:50:23 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B30971220B3 for ; Thu, 13 Mar 2025 13:50:25 +0000 (UTC) X-FDA: 83216662410.20.E728E27 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf05.hostedemail.com (Postfix) with ESMTP id 1C1DA100014 for ; Thu, 13 Mar 2025 13:50:23 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="aBWKPm/h"; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741873824; a=rsa-sha256; cv=none; b=ibfqgwkz/LbblWs0M/GuRrPF9v8htdczWkD6hPVAspH756KyyEm4W3gyQ7hDZsUmZs31hq aFyqLDZbqFw+n7KgmXjYWAXfd5UTBj+i7wUQPx0cFkL4NS+j+SCPR3GSjEOszKeWs0aJuF /lHXxvBFZ3o8USYU2pxIf26bQ+C+eZ4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="aBWKPm/h"; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of rppt@kernel.org designates 147.75.193.91 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=1741873824; 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=q3twzRg7JFtCcj4wct+pthKqDwlnYSVDhBZsfaP3eKQ=; b=uTbSiPDMN5boqqA+mAqgus1ti8KoI2Gi8WKMPDdO8lljCT1TOC6uSOtOo2SV6fuhzFPJTU CCNvvU4e+BOy6eWKVTq8m6iaAH5PbDnzB+JsjRTSdOzdmviLrCJoOAW2KKfYvzVQK4nUwn 8uevUHdas2aD68c5uFamvHg99B4iEeI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 3BAE8A474BF; Thu, 13 Mar 2025 13:44:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C704BC4CEEA; Thu, 13 Mar 2025 13:50:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741873822; bh=62myLVbZVVZFvzPE89he3yMa/a5QAFc2vHsMKxeLVb8=; h=From:To:Cc:Subject:Date:From; b=aBWKPm/h37x/i5+4FCPzxXZYbNjC4QtR+6/uzYQ4j82YaZ0nkwcNlRiBhZ3s4R+Lr UbF6tAw/GLOmZOSjCm3jrX37f1OqnkT6FdjX3Szfhc1wjS/Zyf835B0imLzLMqYjcF W5cI3ghKtUKRswhAYc77+5GSp1YmJnwSpf+x4AqcOGMZBAqFa6QHJIit/O7bFjGzmZ g/lU9Dt6wqDCDU2wFqrq4LXF68UvvU/ytVgt54uUuF2Vagcx8WobuHEk6mGKRWMGKp aLWh5ch4M9p8CvWw5jWVVvEJFFmiQHZ9S4CLDqJpDLqZJs/1wj2uAhd2lAzYblfH7W BgZb5J0KHNyow== From: Mike Rapoport To: Andrew Morton Cc: Alexander Gordeev , Andreas Larsson , Andy Lutomirski , Ard Biesheuvel , 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 , Mark Brown , 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 v2 00/13] arch, mm: reduce code duplication in mem_init() Date: Thu, 13 Mar 2025 15:49:50 +0200 Message-ID: <20250313135003.836600-1-rppt@kernel.org> X-Mailer: git-send-email 2.47.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Queue-Id: 1C1DA100014 X-Stat-Signature: 5ogiq7x1yzs58q4sawp33xocndq4isd7 X-Rspamd-Server: rspam06 X-HE-Tag: 1741873823-227208 X-HE-Meta: U2FsdGVkX18vkYi2QSyjHyEzz3t/wMXOomo3QXwA9+NdUWH4/t2GpoQRYmLi+Z8nI2BZnNfPs7a3QBPC4WnVzY99cHqsjK7mghCMywo3l3ya0540WGgeQ4R4qWc1UxqlzBrUGh8GtNJ/I7zurPsv/7hG5GxXky9PY08DcvmheBzCNghLVwq7N71aJEuFaS595PttVsrNGVFUS6l5Jm+BKk2GKX532SQ/fTa07h46BIG4o2vaX0CZfVvorYxfhFLv2XxAL48lsd1T1gxYsSV/0/ueSc5MpBg3UplS3sivezq/MAD+j2OxtcIj4tIXK7eHuJ79N1fcRv9u9HPjEzUc3y9pOFnhXHgsVpUr20EY003paDbn5IOwz0F/3mQHB9/8KcDuwNMOEYer13avy33gA2mHzhkJ63a/up5BQ8/VJ9GiC1WazjCoa/MRCVF7GaR1fWRLn/GoAr+LRKFKJZPLUt8wzM3Iajjqlxa7erra4IlJEjUOTckhV2DArF8p1eBdYiGUJ7CrjwJZhn05Lq7SNWpwCT2vOe/V8AM8YH4QgruXafOcGlbxDfTt1xq7NvllH3ho09VE7GX9uhK4ahfX9kojEQ5C7kOzn7D1NpVDPwaNDxXuxRb7YOwCo0IIPggSwJ6KbKZkwl0Fx39qb1JH7L1u6aRuf/vFnZGn35kYXqy0HZILHVkhJw/cxuGnbPD6jYgeLb6oP5rR2kt9ycY3o6M0PG2SbcxZ0kbDiGcBZC0poB1ErEIegAPYJAQ0axkaCjferoADgKmssXDBpPHFkrSdrF0jXScTsYYZFuyJkborxiVDQ0SFhj/KeSkRd3VixzXT9AY+rGm7VBAfMW8+Yv+c3i7IZAeYuFwPYlkpifLa/1fRr/5TAU+Tc0MUTsYdVAS7ZAuvD6N/GiLCHKcSevn/Z/fImIBk92NDgdcRKRFLSlL71HYs+AeVUp4fubI/CQPMwo6kaWEYLvl/X7l fuQOcpZU mJyLyaphqoSZBD9NMpAU1TCm0BPYflqhvgSeh1TNcz7THgr2asXQYIno3koMSeusNv7InzF0otLHaDAAlgGoQzp0zsUUt3TUxcex9C7wBndvGDsk7MOlOy6c+qs2tm9RzIcDgrLqyBgaqduMvM4lC5Rahj0l85aH1mXlklsOFF03Vjo0U5u6/v+BnKJTEUxXaQdQFAt+sF700Cfy1EPyp7RthMIfxWQRyLsG5MLlAblnzStHja8SNRPg6ezM/mIYvwr5vVSr9gCyn8wz0Yj6mUI4aKw== 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, 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. v2 changes: * don't use generic version for setting high_memory on architectures that use that varialble earlier than free_area_init() * use memblock_alloc_or_panig() to allocate zero pages on MIPS and s390 * fix alignment in allocation of zero pages on s390 * add Acked-by v1: https://lore.kernel.org/all/20250306185124.3147510-1-rppt@kernel.org 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/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 | 2 - arch/microblaze/mm/init.c | 25 ----------- arch/mips/include/asm/mmzone.h | 2 - arch/mips/loongson64/numa.c | 7 ---- arch/mips/mm/init.c | 51 ++++------------------- 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 | 2 - arch/powerpc/mm/mem.c | 18 +------- arch/riscv/mm/init.c | 5 +-- arch/s390/mm/init.c | 20 +-------- 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 | 65 +++++++++++++++++++++++++---- mm/nommu.c | 6 --- 48 files changed, 158 insertions(+), 612 deletions(-) delete mode 100644 arch/x86/include/asm/numa_32.h delete mode 100644 arch/x86/mm/highmem_32.c base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6 -- 2.47.2