From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EDA5364925 for ; Tue, 23 Jun 2026 09:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782206663; cv=none; b=On2cb50ztliIFcxms6KiuXVjD7QodHyUNsLQJk9JfHXOteCWwoqbcI6N3zJV8AM0pbnMMhuTgO0d9ZZquhFLADkQB28vt0FN9gMYWKcpMcN0+ia6wATya9PGdP8HxiCtbZw/BtmkeR92CPgL+XSGxeJ8Hb5wQpHgJojU12SMurg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782206663; c=relaxed/simple; bh=JpzHzbW81LEBrhP2snUKxq3V4FYFkht8pLOQDCwfTbU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=ahMvZzouQru6nHcuKeNlVIUhZi1Ltns0xxie4FHu+nP6/yTvSKRFu1XsbYwVZMj4NrY44+eKelVlmSVQHzdKBrheKprZP6B1x0hNqtDrA8dPbQ4vR1TYfOfEiQ3E9RDK+PBpZsD2tewhkFj+h1P9TbfDmAdN3/S4KgWt602kkko= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gI8pj1UD; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gI8pj1UD" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-c074142cf6dso117655766b.0 for ; Tue, 23 Jun 2026 02:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782206660; x=1782811460; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=h1js4iTIk2T/KClSyxWwkjP+L1YbVSXomlj6I6PanWg=; b=gI8pj1UDyri0ILdLP25NT3PJdz/0R63BsqsWlMjzLjNjFduPnMoaz8Ct+1fuvMb0Xm ym68NzRZqbmuxhqGTlSIvRI9NTRz49vS2Y2JaJeiK9FcdN8vRJAzI/uDSe1s0HwKcVsR x2Rejor2mWOAFzQV2Uak4Gd2ScgUZI3lPICQMvNGwL0D2yCA2Yn7H/rIHVWPcFgaO6ie YuC2gP5dJOKECswxdh+QsYPek9ra0uKfqHBTAS6umFReONl6iDUn4uU2legAQsIeIBhe 4fwFbBXm85wqXt8GxNBm8aVP01cbT0HbOLh46+up8tEt/Y5czcuEUf4NeLgY1dzaVqho dyqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782206660; x=1782811460; h=references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=h1js4iTIk2T/KClSyxWwkjP+L1YbVSXomlj6I6PanWg=; b=tNKGV4mKq/ifHI88DUyMjDGdDYDQnIHitbp7AulLiO/IwcUyOskoJDHhavYysX8Vze kPK8GXwZU3VTF40db5hrdtLRnUemchTVWr8SQIcAm6RFUDaKVjFJwM2/NOcxit2triTP vEqZ24OlTcjRgpco5AeZZ7izZwt2VHp5jc6Dt3EqPPTno7RngYoWpLTvaQhmBVvvR5yv YQb1KY51P5bxmKwDPV7jqgfAg+uIQJdMekVKMozo/6IBe/5TK3UQsI7bi80jhv6SdeeR /FnGi41D7DwxQUmzdu4bJ68GkLji1OPNhs3mrS8McaUVIK7thJBE6cj+Hjb0jDUVWhNZ 1UoQ== X-Forwarded-Encrypted: i=1; AFNElJ+JOstZmQNbqX/fvO75cSSd7xgQREaHL9VoFUilpX7E/6rkwmeSymYtXNbzhbT/Vprn95CVL/CXWR9TEj4=@vger.kernel.org X-Gm-Message-State: AOJu0YyBLEPayQYyXnwoKa4xoE1nYgwasBxCJ98x1Q80JfxkgJhZNADg AIjbF9pBfmywstekMmlahA6xoFhnIGQ8bVn7JmultAhYONDE2zRTH4bU X-Gm-Gg: AfdE7cmSy4OxiYCcDnOVpUkq8Cl4Q8NIkk40aP3uzgo3ebHBAQeGfDBgIMXxRFfrrg5 UCkXs+49oiu1bGJbcWT7pV0pEa1UhblKdfANKsOo2B61mHY4atqd1pZaSlQXgZZjmqxhQrWgO4B CyHujrke1GYuorgVYfo+625bNNBMk5nBU7FPr/xrGiXlDlFP187mlP//MMzFDIxsksRFHZtaeOD qre4BMKCjqX1OZHlFd//qBU0399kP1Mi9e/wQ0rGh+yFOgL6+oNxwVaYh0w6l0Eue6E7tjzvmEJ onNgVPfVCHlJ4nUJDB3ePvFuFqFPE0quT/iLm98SUr3UojW3xRya1WFNckXFJt1gjAfwH4n3QZR zqdhWPf9bSjwbGchavAcSy3x1RJw6iPyK5U9N722vH3B/E808S2mm2euN50Wkyts4utM71ipMwK dBCeCOPKH2mtY= X-Received: by 2002:a17:906:9f86:b0:c0d:7c31:26a9 with SMTP id a640c23a62f3a-c102faa5967mr165140566b.2.1782206659723; Tue, 23 Jun 2026 02:24:19 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c0c6161ec94sm479276666b.59.2026.06.23.02.24.19 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jun 2026 02:24:19 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org, izumi.taku@jp.fujitsu.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, david@kernel.org, yuan1.liu@intel.com, Wei Yang Subject: [RFC Patch 2/3] mm/mm_init: remove overlap_memmap_init() as no overlapped zone Date: Tue, 23 Jun 2026 09:23:50 +0000 Message-Id: <20260623092351.13031-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20260623092351.13031-1-richard.weiyang@gmail.com> References: <20260623092351.13031-1-richard.weiyang@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: When commit 342332e6a925 ("mm/page_alloc.c: introduce kernelcore=mirror option") is introduced, it would have overlapped Zone Normal and Zone Movable. And this original code would initialize overlapped range twice. For example, if the memory layout is below: memory[0x0] [0x0000000000001000-0x000000000009efff], 0x000000000009e000 bytes on node 0 flags: 0x2 memory[0x1] [0x0000000000100000-0x00000000bffdefff], 0x00000000bfedf000 bytes on node 0 flags: 0x2 memory[0x2] [0x0000000100000000-0x000000013fffffff], 0x0000000040000000 bytes on node 0 flags: 0x2 memory[0x3] [0x0000000140000000-0x00000001bfffffff], 0x0000000080000000 bytes on node 0 flags: 0x0 We would get Zone range with kernelcore=mirror set: Normal [100000, 1c0000] Movable [140000, 1c0000] According to original logic, during memmap_init() it calls memmap_init_zone_range() with the same range from for_each_mem_pfn_range() for each populated zone. And then clamp the same memory range with specific zone boundary. memmap_init() for_each_mem_pfn_range(&start_pfn, &end_pfn) for: zone = ZONE_DMA, ZONE_DEVICE memmap_init_zone_range(zone, start_pfn, end_pfn) <-- same range, but different zone memmap_init_range() <-- clamped with zone range For the last memblock region: [0x0000000140000000-0x00000001bfffffff] It belongs to both Zone Normal and Zone Movable, which means the same range would be initialized twice by memmap_init_range(), but with different zone_id. Original code is expected to skip overlapped range with overlap_memmap_init(). But it only skip when (zone == ZONE_MOVABLE), which in turn has no effect for this memory layout. So the last range is first initialized to Zone Normal, then to Zone Movable which is what we expect. After previous cleanup, the overlapped zone is gone, so the overlap_memmap_init() is not necessary anymore. Signed-off-by: Wei Yang Cc: "David Hildenbrand (Arm)" Cc: Yuan Liu --- mm/mm_init.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index b8ff4aff19c0..da0e65bf8d02 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -797,28 +797,6 @@ void __meminit init_deferred_page(unsigned long pfn, int nid) __init_deferred_page(pfn, nid); } -/* If zone is ZONE_MOVABLE but memory is mirrored, it is an overlapped init */ -static bool __meminit -overlap_memmap_init(unsigned long zone, unsigned long *pfn) -{ - static struct memblock_region *r __meminitdata; - - if (mirrored_kernelcore && zone == ZONE_MOVABLE) { - if (!r || *pfn >= memblock_region_memory_end_pfn(r)) { - for_each_mem_region(r) { - if (*pfn < memblock_region_memory_end_pfn(r)) - break; - } - } - if (*pfn >= memblock_region_memory_base_pfn(r) && - memblock_is_mirror(r)) { - *pfn = memblock_region_memory_end_pfn(r); - return true; - } - } - return false; -} - /* * Only struct pages that correspond to ranges defined by memblock.memory * are zeroed and initialized by going through __init_single_page() during @@ -905,8 +883,6 @@ void __meminit memmap_init_range(unsigned long size, int nid, unsigned long zone * function. They do not exist on hotplugged memory. */ if (context == MEMINIT_EARLY) { - if (overlap_memmap_init(zone, &pfn)) - continue; if (defer_init(nid, pfn, zone_end_pfn)) { deferred_struct_pages = true; break; -- 2.34.1