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 750FCC28B30 for ; Sun, 23 Mar 2025 19:06:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20843280002; Sun, 23 Mar 2025 15:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B41F280001; Sun, 23 Mar 2025 15:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07D63280002; Sun, 23 Mar 2025 15:06:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D98D9280001 for ; Sun, 23 Mar 2025 15:06:53 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 357DAB88F3 for ; Sun, 23 Mar 2025 19:06:54 +0000 (UTC) X-FDA: 83253747948.12.E3187F7 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf21.hostedemail.com (Postfix) with ESMTP id 916F01C000F for ; Sun, 23 Mar 2025 19:06:52 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jQL7TQcT; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of nathan@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=nathan@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742756812; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CVLELM98HggnKQqs2C5CbsJVodu/jH2U/dgnbTT8SDY=; b=RYUlYI/iEbSljdXyHtw8/56ls5xl8Hb9OKotQimOvfnb67uSmYmWvJisvU1LPOoXZoWHrn lspFx1hNHjtjJXLz7JoQ6TczVDQ2DIuHRGTD+yaDO8jrLFQsnMyGZTiwUqxcvJ7QG0inPx /WelddifrvT2vmOrPIQ+vYvzVUmxc0o= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jQL7TQcT; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of nathan@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=nathan@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742756812; a=rsa-sha256; cv=none; b=V3O8Vxsd0WCJs6Tu7ZCQLlmQV2x8cMFWQ3aBfoCMefKi1s3wgX17d4zHhxbI0qFe8A56CM pxXVzf+Wc3bKjHLah5I6ktoGBFZFOmHBKs/5EqOETWxiqQyb4CnBy4U3k3Ozy6NIcex0C+ uzQbQ9D1Rmz2GQ9fD1W2H7S8RJdUEMQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 9913BA4A37A; Sun, 23 Mar 2025 19:01:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D155BC4CEE2; Sun, 23 Mar 2025 19:06:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742756811; bh=gSiVK54BaFE1wEuUqKWSMj5BQvcJRmD5TNSAbSLcb4g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jQL7TQcTZyLVxNaZanp8w7PAPcRH4eXRTp+zwa1fVLvF5RNXfwHOQMan+IZ/480BS J36iXtpvREPwHVbh+S0noYAmNgCjR0kF1d2InQsgzYc5STtc7o4YXlSsCioVzZrYiz wIf23ykcDVmXGQyA8PbN3cdvxQtwJ+DhU7qgnWnhod18nN8OQXj5/DlHIDG31v1ix4 qElFiWBy334oaPSIFMcVa3Pz1GsZEnOcU2yqrYgQzBS4cBE5q2FuDJvZK0u+8MITH8 Ebxhb99rOts9V9P2wMGpPU/1elBbVfhSMTDHxVLWiyN+WYJigvM3R1o2xALK9VHvdT vc0VfAUr5yPag== Date: Sun, 23 Mar 2025 14:06:47 -0500 From: Nathan Chancellor To: Mike Rapoport Cc: Andrew Morton , Jiaxun Yang , Thomas Bogendoerfer , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 11/13] arch, mm: streamline HIGHMEM freeing Message-ID: <20250323190647.GA1009914@ax162> References: <20250313135003.836600-1-rppt@kernel.org> <20250313135003.836600-12-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250313135003.836600-12-rppt@kernel.org> X-Rspamd-Server: rspam01 X-Stat-Signature: g7sman644eytcedmfnzgoj5ccjmf193r X-Rspam-User: X-Rspamd-Queue-Id: 916F01C000F X-HE-Tag: 1742756812-986721 X-HE-Meta: U2FsdGVkX18KMB9coVwwotIuvVrrBLGVvuflgR1fciClA566VH70Po1q09CTifi2dAYQVs+TsccRCjEdrHdXc5/6qJ8raVJ5+eXH2FqP49PBd2uNee32RB1mTOMpn/YVKyqWmIwKricIMRuxd4Dar3+oizZVM5+UAu6kTDuEE98oM1juGT4a3E3KKdi1JCqESq3ubiqGwn2cLxOl2VtWMEDegJ60zyJoa0GWWl7S95ou9lUXZMgdalreKz0Glzjjnyxo9PxlXCHb/UNEZvxke5+PgCIy7fL0X2xfgh7Hf+N69Ifq6wqUMrB5/4sR4xXzvEKT3najAoKWeMVC7SJ7jpxRMjVktwetlMpk1jDdkXRJovHezDbOCAGwA1BkMDN7z2rxsixAjnTH9ogsjV5JqLfkCW8T7X7OAkCM35xM5OIyf9X+KNM8v3legTBvtFxy28OZeQdJwYyPHH8YvThQILpAbAThpTZ/CvRDqYX7Q5Sx0+rEuW3SjOxumEtDljvUgUR+vlFLVth5qonaNUVYyfeZX+BjWwI/7O0wY5vMoEEA8KJ86QQcj7wZ5j7WhjAV3HSuj0Q+XAqck9oH7jY8dpILa7Taqy84Lh8dYo0JoPdZGukvw5iMnd4bfpZMteJiy1TqGLLR6yYF/HM9tL6m8gAu4fmrEbejcrp6abyR5f7CLXzEMs0NNLrRWU40ZWSUS3PSt7aw6IvsqtD47+ghfTldq08B/E3RdEgUqu0egNB0DN7sRamnC0miEP2NIonCv8U3C5eci9feUBJ8NBUHsvZtrpEvJazRD3btZLSimEILDCwjOnugn+01+U/H4dVzOukom8ERRDWodQtWcGrlK8UA92+QVrg8APD9DWtqMBZLn4x3V8VKDr3m1GGLwnI9fOEERANfd+H4Bnos4g+B5MSqUeoH3RP2DPkLW8IqfjQcczMBR32N5HTLwDj14hNB/P9dZyU8OTK3llESDrP 9OBIRlu/ x6OSEyU3SJfWMesOBa3pGQv00gt5GXFxrDDIVEaByZW8pXPzsTeieQQk5it0ZItcFUq6U1NxS/o2L84VTgeWslQhXr8Hdr/a5eOe6cQCgwv2eRMmfblM/LNLHAKh1dractHr2O1rWRwq6zUTfhNWzmJY8fvFpAAQ3IjHyri7UobOB5L5/itWa+swdiO6oIgs4/XRaXkePmJ0qZyRPe4BbMyJtgvmuT89X6z9cHLXzFdMME3WskvMeOr2mtmwvm5krGt84oxmdwOMes7Kriha04giTyrguN4bHKUaTvQzi/xKtoyM= 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: Hi Mike, On Thu, Mar 13, 2025 at 03:50:01PM +0200, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > All architectures that support HIGHMEM have their code that frees high > memory pages to the buddy allocator while __free_memory_core() is limited > to freeing only low memory. > > There is no actual reason for that. The memory map is completely ready > by the time memblock_free_all() is called and high pages can be released to > the buddy allocator along with low memory. > > Remove low memory limit from __free_memory_core() and drop per-architecture > code that frees high memory pages. > > Acked-by: Dave Hansen # x86 > Signed-off-by: Mike Rapoport (Microsoft) ... > diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c > index ed9dde6a00f7..075177e817ac 100644 > --- a/arch/mips/mm/init.c > +++ b/arch/mips/mm/init.c > @@ -425,25 +425,6 @@ void __init paging_init(void) > static struct kcore_list kcore_kseg0; > #endif > > -static inline void __init mem_init_free_highmem(void) > -{ > -#ifdef CONFIG_HIGHMEM > - unsigned long tmp; > - > - if (cpu_has_dc_aliases) > - return; > - > - for (tmp = highstart_pfn; tmp < highend_pfn; tmp++) { > - struct page *page = pfn_to_page(tmp); > - > - if (!memblock_is_memory(PFN_PHYS(tmp))) > - SetPageReserved(page); > - else > - free_highmem_page(page); > - } > -#endif > -} > - > void __init mem_init(void) > { > /* > @@ -454,7 +435,6 @@ void __init mem_init(void) > > maar_init(); > setup_zero_pages(); /* Setup zeroed pages. */ > - mem_init_free_highmem(); > memblock_free_all(); > > #ifdef CONFIG_64BIT ... > diff --git a/include/linux/mm.h b/include/linux/mm.h > index fdf20503850e..6fccd3b3248c 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -3172,7 +3172,6 @@ extern void reserve_bootmem_region(phys_addr_t start, > > /* Free the reserved page into the buddy system, so it gets managed. */ > void free_reserved_page(struct page *page); > -#define free_highmem_page(page) free_reserved_page(page) > > static inline void mark_page_reserved(struct page *page) > { > diff --git a/mm/memblock.c b/mm/memblock.c > index 95af35fd1389..64ae678cd1d1 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2164,8 +2164,7 @@ static unsigned long __init __free_memory_core(phys_addr_t start, > phys_addr_t end) > { > unsigned long start_pfn = PFN_UP(start); > - unsigned long end_pfn = min_t(unsigned long, > - PFN_DOWN(end), max_low_pfn); > + unsigned long end_pfn = PFN_DOWN(end); > > if (start_pfn >= end_pfn) > return 0; I bisected a crash that I see to this change as commit 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing") in -next. $ cat arch/mips/configs/repro.config CONFIG_RELOCATABLE=y CONFIG_RELOCATION_TABLE_SIZE=0x00200000 CONFIG_RANDOMIZE_BASE=y $ make -skj"$(nproc)" ARCH=mips CROSS_COMPILE=mips-linux- mrproper malta_defconfig repro.config vmlinux $ qemu-system-mipsel \ -display none \ -nodefaults \ -cpu 24Kf \ -machine malta \ -kernel vmlinux \ -initrd rootfs.cpio \ -m 512m \ -serial mon:stdio Linux version 6.14.0-rc6-00359-g6faea3422e3b (nathan@ax162) (mips-linux-gcc (GCC) 14.2.0, GNU ld (GNU Binutils) 2.42) #1 SMP Fri Mar 21 08:12:02 MST 2025 earlycon: uart8250 at I/O port 0x3f8 (options '38400n8') printk: legacy bootconsole [uart8250] enabled Config serial console: console=ttyS0,38400n8r CPU0 revision is: 00019300 (MIPS 24Kc) FPU revision is: 00739300 MIPS: machine is mti,malta Software DMA cache coherency enabled Initial ramdisk at: 0x8fad0000 (5360128 bytes) OF: reserved mem: Reserved memory: No reserved-memory node in the DT Primary instruction cache 2kB, VIPT, 2-way, linesize 16 bytes. Primary data cache 2kB, 2-way, VIPT, no aliases, linesize 16 bytes Zone ranges: DMA [mem 0x0000000000000000-0x0000000000ffffff] Normal [mem 0x0000000001000000-0x000000001fffffff] Movable zone start for each node Early memory node ranges node 0: [mem 0x0000000000000000-0x000000000fffffff] node 0: [mem 0x0000000090000000-0x000000009fffffff] Initmem setup node 0 [mem 0x0000000000000000-0x000000009fffffff] On node 0, zone Normal: 16384 pages in unavailable ranges random: crng init done percpu: Embedded 3 pages/cpu s18832 r8192 d22128 u49152 Kernel command line: rd_start=0xffffffff8fad0000 rd_size=5360128 console=ttyS0,38400n8r printk: log buffer data + meta data: 32768 + 102400 = 135168 bytes Dentry cache hash table entries: 65536 (order: 4, 262144 bytes, linear) Inode-cache hash table entries: 32768 (order: 3, 131072 bytes, linear) Writing ErrCtl register=00000000 Readback ErrCtl register=00000000 Built 1 zonelists, mobility grouping on. Total pages: 16384 mem auto-init: stack:all(zero), heap alloc:off, heap free:off Unhandled kernel unaligned access[#1]: CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.14.0-rc6-00359-g6faea3422e3b #1 Hardware name: mti,malta $ 0 : 00000000 00000001 81cb0880 00129027 $ 4 : 00000001 0000000a 00000002 00129026 $ 8 : ffffdfff 80101e00 00000002 00000000 $12 : 81c9c224 81c63e68 00000002 00000000 $16 : 805b1e00 00025800 81cb0880 00000002 $20 : 00000000 81c63e64 0000000a 81f10000 $24 : 81c63e64 81c63e60 $28 : 81c60000 81c63de0 00000001 81cc9d20 Hi : 00000000 Lo : 00000000 epc : 814a227c __free_pages_ok+0x144/0x3c0 ra : 81cc9d20 memblock_free_all+0x1d4/0x27c Status: 10000002 KERNEL EXL Cause : 00800410 (ExcCode 04) BadVA : 00129026 PrId : 00019300 (MIPS 24Kc) Modules linked in: Process swapper (pid: 0, threadinfo=(ptrval), task=(ptrval), tls=00000000) Stack : 81f10000 805a9e00 81c80000 00000000 00000002 814aa240 000003ff 00000400 00000000 81f10000 81c9c224 00003b1f 81c80000 81c63e60 81ca0000 81c63e64 81f10000 0000000a 0000001f 81cc9d20 81f10000 81cc96d8 00000000 81c80000 81c9c224 81c63e60 81c63e64 00000000 81f10000 00024000 00028000 00025c00 90000000 a0000000 00000002 00000017 00000000 00000000 81f10000 81f10000 ... Call Trace: [<814a227c>] __free_pages_ok+0x144/0x3c0 [<81cc9d20>] memblock_free_all+0x1d4/0x27c [<81cc6764>] mm_core_init+0x100/0x138 [<81cb4ba4>] start_kernel+0x4a0/0x6e4 Code: 1080ffd5 02003825 2467ffff <8ce30000> 7c630500 1060ffd4 00000000 8ce30000 7c630180 ---[ end trace 0000000000000000 ]--- Kernel panic - not syncing: Attempted to kill the idle task! ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]--- At the immediate parent of that change, the boot completes fine. Linux version 6.14.0-rc6-00358-ge120d1bc12da (nathan@ax162) (mips-linux-gcc (GCC) 14.2.0, GNU ld (GNU Binutils) 2.42) #1 SMP Sun Mar 23 13:57:15 CDT 2025 earlycon: uart8250 at I/O port 0x3f8 (options '38400n8') printk: legacy bootconsole [uart8250] enabled Config serial console: console=ttyS0,38400n8r CPU0 revision is: 00019300 (MIPS 24Kc) FPU revision is: 00739300 MIPS: machine is mti,malta Software DMA cache coherency enabled Initial ramdisk at: 0x8fad0000 (5360128 bytes) OF: reserved mem: Reserved memory: No reserved-memory node in the DT Primary instruction cache 2kB, VIPT, 2-way, linesize 16 bytes. Primary data cache 2kB, 2-way, VIPT, no aliases, linesize 16 bytes Zone ranges: DMA [mem 0x0000000000000000-0x0000000000ffffff] Normal [mem 0x0000000001000000-0x000000001fffffff] Movable zone start for each node Early memory node ranges node 0: [mem 0x0000000000000000-0x000000000fffffff] node 0: [mem 0x0000000090000000-0x000000009fffffff] Initmem setup node 0 [mem 0x0000000000000000-0x000000009fffffff] On node 0, zone Normal: 16384 pages in unavailable ranges random: crng init done percpu: Embedded 3 pages/cpu s18832 r8192 d22128 u49152 Kernel command line: rd_start=0xffffffff8fad0000 rd_size=5360128 console=ttyS0,38400n8r printk: log buffer data + meta data: 32768 + 102400 = 135168 bytes Dentry cache hash table entries: 65536 (order: 4, 262144 bytes, linear) Inode-cache hash table entries: 32768 (order: 3, 131072 bytes, linear) Writing ErrCtl register=00000000 Readback ErrCtl register=00000000 Built 1 zonelists, mobility grouping on. Total pages: 16384 mem auto-init: stack:all(zero), heap alloc:off, heap free:off SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 rcu: Hierarchical RCU implementation. rcu: RCU event tracing is enabled. rcu: RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1. rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies. rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1 NR_IRQS: 256 rcu: srcu_init: Setting srcu_struct sizes based on contention. CPU frequency 320.00 MHz clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 11945390257 ns sched_clock: 32 bits at 160MHz, resolution 6ns, wraps every 13421787132ns Console: colour dummy device 80x25 Calibrating delay loop... 1895.62 BogoMIPS (lpj=9478144) pid_max: default: 32768 minimum: 301 Mount-cache hash table entries: 4096 (order: 0, 16384 bytes, linear) Mountpoint-cache hash table entries: 4096 (order: 0, 16384 bytes, linear) rcu: Hierarchical SRCU implementation. rcu: Max phase no-delay instances is 1000. smp: Bringing up secondary CPUs ... smp: Brought up 1 node, 1 CPU Memory: 241200K/262144K available (7844K kernel code, 330K rwdata, 1424K rodata, 2352K init, 224K bss, 19984K reserved, 0K cma-reserved) devtmpfs: initialized ... If there is any additional information I can provide or patches I can test, I am more than happy to do so. Cheers, Nathan