From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D60839903B for ; Tue, 30 Jun 2026 07:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782804143; cv=none; b=kPW6coCOZk8oFWT4h3D+1S9pRDNWm6hDI33XIz2qQhqc02D3u+kL9yXOlzNYwVhOuw7f9KWxWtxo8IB9fvBx0GwyfiBZddnZEblGjAHTXagI5+/JjNSB/aGNw3YxNxwoxo8iHOU29mZ2coIeriRFTlLUpMp8cmZwB1C5xRWhf30= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782804143; c=relaxed/simple; bh=IAgpGKDNYEwJM/aA/ORRt2fnKw00Dr5obBT4vtAYIWk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iGFdeoA2JZGWAK32iUxuMl3CErtwPk8GI9qgxRMHxf0DboOlvj7vK672c9cI+C0REKHClOr0tQXsD2GsSihN7egDDpfhFYk/Rfp8JuJdz9rN/KmC0+JxmqqCWkJuTxmoFNZ8LAfIPrip3o0ZMxd1cyOtdb6NY8RvITi16KO85Bo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AYkVcW4v; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AYkVcW4v" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95A841F00A3A; Tue, 30 Jun 2026 07:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782804141; bh=oLrSE68xNG5mT8tgW/ijHmTinKP2lAELluUkxa6reBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AYkVcW4vLvETM8EM9k6g8TRBEKovdAiH65GAjFHQbeyvFHqjqWoXkn3QmRZ7PH/00 Tb8WKGDaVvJi9ya9hB1uXMOtF3Q6RqjaA/exQOsoQQmIGlpg2daX8IbkD2ldOLgX1a 6F7D+Fw7fmDyUwDVa5l5D11NQop9CWIjW7uUSsshRFJg7y4xY21KuoPOHMQLLv4HqE NbnKZew5zoxyrJlTPnH/K6Ml8EgKol9UQ40oTWYZSL5Q6WuIPd5PtmM4cYknVpUn5f 7bebsE7cZu3Py1vd59obinwsEByOgwHcNEMN7g88533Iz7/YjBtkDQVx8WlKgVgwiV HH5FWuhly1C2A== From: Mike Rapoport To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Mike Rapoport , Taku Izumi , Wei Yang , Yuan Liu , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] mm/mm_init: don't overlap NORMAL and MOVABLE zones with kernelcore=mirror Date: Tue, 30 Jun 2026 10:22:11 +0300 Message-ID: <20260630072212.624305-2-rppt@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260630072212.624305-1-rppt@kernel.org> References: <20260630072212.624305-1-rppt@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Mike Rapoport (Microsoft)" When kernelcore or movablecore kernel parameters define size of the NORMAL and MOVABLE zones as percents of the total memory or by absolute value, ZONE_NORMAL is clamped at the beginning of ZONE_MOVABLE. However, when kernelcore=mirror the ZONE_NORMAL span is not changed but rather pages from ZONE_MOVABLE counted as absent in ZONE_NORMAL. Make the behaviour of kernelcore= parameter uniform and treat mirror just as another way to size the zones. Co-developed-by: Wei Yang Signed-off-by: Wei Yang Signed-off-by: Mike Rapoport (Microsoft) --- mm/mm_init.c | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 0f64909e8d20..57923dd33d06 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1174,9 +1174,8 @@ static void __init adjust_zone_range_for_zone_movable(int nid, arch_zone_highest_possible_pfn[movable_zone]); /* Adjust for ZONE_MOVABLE starting within this range */ - } else if (!mirrored_kernelcore && - *zone_start_pfn < zone_movable_pfn[nid] && - *zone_end_pfn > zone_movable_pfn[nid]) { + } else if (*zone_start_pfn < zone_movable_pfn[nid] && + *zone_end_pfn > zone_movable_pfn[nid]) { *zone_end_pfn = zone_movable_pfn[nid]; /* Check if this whole range is within ZONE_MOVABLE */ @@ -1224,40 +1223,11 @@ static unsigned long __init zone_absent_pages_in_node(int nid, unsigned long zone_start_pfn, unsigned long zone_end_pfn) { - unsigned long nr_absent; - /* zone is empty, we don't have any absent pages */ if (zone_start_pfn == zone_end_pfn) return 0; - nr_absent = __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn); - - /* - * ZONE_MOVABLE handling. - * Treat pages to be ZONE_MOVABLE in ZONE_NORMAL as absent pages - * and vice versa. - */ - if (mirrored_kernelcore && zone_movable_pfn[nid]) { - unsigned long start_pfn, end_pfn; - struct memblock_region *r; - - for_each_mem_region(r) { - start_pfn = clamp(memblock_region_memory_base_pfn(r), - zone_start_pfn, zone_end_pfn); - end_pfn = clamp(memblock_region_memory_end_pfn(r), - zone_start_pfn, zone_end_pfn); - - if (zone_type == ZONE_MOVABLE && - memblock_is_mirror(r)) - nr_absent += end_pfn - start_pfn; - - if (zone_type == ZONE_NORMAL && - !memblock_is_mirror(r)) - nr_absent += end_pfn - start_pfn; - } - } - - return nr_absent; + return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn); } /* -- 2.53.0