From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 A9B46208D0 for ; Sun, 26 Apr 2026 04:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777176054; cv=none; b=YUGUoPh2wPXMp3Pwyie+1KRFMm8ALjBCFcKasXlTBDH4xfKxPpJY2MUqn9UM0BRozr6zVLJvfrXCYUoTncdH54jgEGqUxJxDtKoPjQsfHvh+z8ZgrF1Rfh7GAAzjPlcf+VMPFNulxnOHPYOKxek3LBn9lzeEOWE186IddpKHbvY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777176054; c=relaxed/simple; bh=1dP19qrock3TlIk8KCB8gofJdMY3KduYXvxV80E2xAU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=P1b09V2/WBlrs8ZWoxod5S8plwzmWOyKPLkFpJZA3tSYNMbcBWo+LwSTHQUjtEtrXshd8RVoDiIq1mHPZ84Id5716CsquEb+Dgihpp0xpJB2d4qDoMj9+9yDLOLGls4YcVukQPfK5TQpLGxq2K9apXEeD6nGP7P1zOZsB+FQ0Es= 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=lwgijNjs; arc=none smtp.client-ip=209.85.208.54 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="lwgijNjs" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-672c12e95e9so12960336a12.2 for ; Sat, 25 Apr 2026 21:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777176051; x=1777780851; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=30kEFePSCv6k+rR7C3eCM4pXv1NgrpkpUSRGNoUTIh0=; b=lwgijNjsM2PEGWIBbKe166orkgidmLPuZOhGDLm7kPgjG6wXie8HT/PUdrPznRxJVh RzvPkb4NraIM/QE7+mSVcTNLjM+Tn4YHW9e2GQVYYap2II654Am2u97eZkzNycx1xucY BXwa4N3OU86gTWWIWXFPCBcPa/HAqUF+8CmgeikYtk0mMPOE3UzVb9ddU8hlPDZF6QAs A4qerdhxmvlLPQPEfLgccuxRV9yATH8BF8Ell5wjfSm2UtlzTd5X0DBPUgkb9ZaNFlLS aBPfE8aBPBw/JGufLuLw8uoPq8aMmxL/3FP26GX1qgxV4a9SXRdMAZ8xBjuschmuGTH2 e1gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777176051; x=1777780851; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=30kEFePSCv6k+rR7C3eCM4pXv1NgrpkpUSRGNoUTIh0=; b=nR1pVmUs4i9/ndqopipsJtUWnlopKaZB/KsJ9HaVl4whAW/6WAyammd8hIVMTtHhEy NLFItaUW89A+fymD2nbZQQ/Qzb0dRKuoM9Pm1+DDREKMgepqdKD153NATdMU5BXGId+O Cizpe6/Cyn73ZZp+8orasWir/gQAQdLFZK6buABw4P7rJ1BdO2yvarN80dnPKceEbBn5 xy18zVcJ2lQQZNp64o6H3BfsK1lq5na59b3tbIoK834AYThRF8oTioYsXRQ2tYACNDal negF9JeMmV4t3jYQsM17p6qi1t52fsaMyPMvEUzHrJ2m5Xmy1Gqq+dsRu828dGTchhGV Cx1A== X-Forwarded-Encrypted: i=1; AFNElJ+9aP3aXFycyWEGMuRfDYQRxGTumvLv4DdEgPWSple761FsblQmpaXHlfNyUTTSWimuSLRODVRyiSNT27E=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+pOK4zZOJ/9R4TW6SBivDcaVRcXE3yZakZIfMWxK4PG5a6lnS x5NsTwT5lc9ikb7jFT5/sk4dXNELGJWHo1vHugzsH98lQsdiD+C0uhCG X-Gm-Gg: AeBDiesH2WOknVrPHQEnXvdiPlx3gY8ne3K8JGESnTGG17uizC1daX+CCjUlT6gGGS9 1Rf/dJj8zNfiH+4YogTkdnfJf3v/1AQXk5gCXiQ4JjpwjP2Ghi0Y2chJ84a92N/hSwDRQLOXDJN FRg/2Pc13UXPihf7sAOHzSIDu8EwHo+ZhEPulvoSXHybZo1p3jiS+J0seMnqYnpjA8wdnOTKsx9 HEGBXMXVmia5Gy27lp013G6HO89RANWqRS2CYdtdKrk+MqWy06o/IZG3xHkniFWebcuCB690NCd df4lFgDsOPIp8GEyLa1PyCQNknGLkvvoBGPNQLpfdk9yFfKbECWuA5TKYTxN7QB6oecyw2xdoOV ZAdHE4/crtQ/gWa8NYEmnrAEGiLLNOfNHCRZ6vnPPNcXHbvwmQRybzcpJjSOgyquo05oRb0VJA4 SDBPFSp4bd2Ut1rWFCyeDLKh4mz4JmCFBC X-Received: by 2002:a05:6402:3214:b0:678:edab:6f40 with SMTP id 4fb4d7f45d1cf-678edab712amr1823623a12.4.1777176050801; Sat, 25 Apr 2026 21:00:50 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-67935440d52sm83328a12.16.2026.04.25.21.00.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 Apr 2026 21:00:49 -0700 (PDT) Date: Sun, 26 Apr 2026 04:00:48 +0000 From: Wei Yang To: Mike Rapoport Cc: Yuan Liu , David Hildenbrand , Oscar Salvador , Wei Yang , linux-mm@kvack.org, Yong Hu , Nanhai Zou , Tim Chen , Qiuxu Zhuo , Yu C Chen , Pan Deng , Tianyou Li , Chen Zhang , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/2] mm: move overlap memory map init check to memmap_init() Message-ID: <20260426040048.43sh3dgtp52eqcjw@master> Reply-To: Wei Yang References: <20260421125508.2317429-1-yuan1.liu@intel.com> <20260421125508.2317429-2-yuan1.liu@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) On Sat, Apr 25, 2026 at 11:01:42AM +0200, Mike Rapoport wrote: [...] >> >> for (j = 0; j < MAX_NR_ZONES; j++) { >> struct zone *zone = node->node_zones + j; >> @@ -978,6 +955,18 @@ static void __init memmap_init(void) >> if (!populated_zone(zone)) >> continue; >> >> + if (mirrored_kernelcore) { >> + const bool is_mirror = memblock_is_mirror(r); >> + const bool is_movable_zone = (j == ZONE_MOVABLE); >> + >> + if (is_mirror && is_movable_zone) >> + continue; >> + >> + if (!is_mirror && !is_movable_zone && >> + start_pfn >= zone_movable_pfn[nid]) >> + continue; >> + } >> + > Hi, Mike Thanks for your review. >I think this: > > if (mirrored_kernelcore && j == ZONE_MOVABLE && > memblock_is_mirror(r)) > continue; > >would be enough to remove overlap_memmap_init() and keep the existing >logic. > >I wouldn't deal the theoretical cases Wei mentioned in this thread for >now and prefer to keep the things simple. That would be great to keep things simple. >The assumptions that mirrored memory spans a contiguous range below some >limit and that mirrored memory is not removable existed for years and I >don't see why we should change the logic now and complicate the code for >exotic theoretical memory layouts. > I don't follow here. Still not clear what the memory layout should be. IIUC, case C is not real, but case A/B are. I took case B as an example and do some tests. Below is my finding. Here is memblock layout for case B, with the head 1G of ZONE_NORMAL is mirror memory. MEMBLOCK configuration: memory size = 0x000000017ff7dc00 reserved size = 0x0000000005a939c2 memory.cnt = 0x4 memory[0x0] [0x0000000000001000-0x000000000009efff], node 0 flags: 0x2 memory[0x1] [0x0000000000100000-0x00000000bffdefff], node 0 flags: 0x2 memory[0x2] [0x0000000100000000-0x000000013fffffff], node 1 flags: 0x2 memory[0x3] [0x0000000140000000-0x00000001bfffffff], node 1 flags: 0x0 This meets: * mirrored memory span from low to 0x13fffffff Then I add below change along with your suggested change. @@ -964,6 +964,8 @@ static void __init memmap_init_zone_range(struct zone *zone, if (start_pfn >= end_pfn) return; + pr_info(" [%lx, %lx] init to %s\n", + start_pfn, end_pfn, zone->name); memmap_init_range(end_pfn - start_pfn, nid, zone_id, start_pfn, zone_end_pfn, MEMINIT_EARLY, NULL, MIGRATE_MOVABLE, false); And see the last normal memory range is initialized twice. [140000, 1c0000] init to Normal [140000, 1c0000] init to Movable Then I removed your suggested change and adjust code like below. @@ -954,6 +954,7 @@ static void __init memmap_init_zone_range(struct zone *zone, unsigned long end_pfn, unsigned long *hole_pfn) { + unsigned long old_start = start_pfn, old_end = end_pfn; unsigned long zone_start_pfn = zone->zone_start_pfn; unsigned long zone_end_pfn = zone_start_pfn + zone->spanned_pages; int nid = zone_to_nid(zone), zone_id = zone_idx(zone); , start_pfn = clamp(start_pfn, zone_start_pfn, zone_end_pfn); end_pfn = clamp(end_pfn, zone_start_pfn, zone_end_pfn); - if (start_pfn >= end_pfn) + if (start_pfn >= end_pfn) { + pr_info(" [%lx, %lx] skipped to %s\n", + old_start, old_end, zone->name); return; + } + pr_info(" [%lx, %lx] init to %s\n", + start_pfn, end_pfn, zone->name); memmap_init_range(end_pfn - start_pfn, nid, zone_id, start_pfn, zone_end_pfn, MEMINIT_EARLY, NULL, MIGRATE_MOVABLE, false); This shows current code already could skip the mirror range to ZONE_MOVABLE for this kind memory layout, since ZONE_MOVABLE doesn't span to it. [100000, 140000] skipped to Movable [140000, 1c0000] init to Normal [140000, 1c0000] init to Movable So I am not sure the real mirrored memory layout could be. Would you mind giving more detail to help me get on the right track? >> memmap_init_zone_range(zone, start_pfn, end_pfn, >> &hole_pfn); >> zone_id = j; >> -- >> 2.47.3 >> > >-- >Sincerely yours, >Mike. -- Wei Yang Help you, Help me