From nobody Sun Feb 8 23:04:19 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 C3E4A42EEBA for ; Tue, 20 Jan 2026 13:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768916015; cv=none; b=KJY16CyePoeUQzHsRXotqOWEsbPenX3MG+ib1FB2VaPPGYCR196Tgk73JJdTVGXWNsFET37XLJBEo9t2y63ghfOgWCEpJk7W5IE7E23iws+Fywk9X/6FPhJUNs0IGaZR2dVmULWZ5nzwkXwWV1tBO5W06MhQkKGv3iu0dF0IrwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768916015; c=relaxed/simple; bh=WxYMGLcFQNXnEaihySfQ/dWGKrp0fx37HvGdniAnji8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HWekmlyTLKbY0U9WGXxJanYfuprhoZELvEclvXYIjeh1y8JYAhoC+9PRMoyayaCTutukcEncE7u6l9IqniKpcT8NFcnM3q0rcp1DzcbPL2spuHT97/hL+W1A2/f+Bdnmxw3qNUuS7ZRV923BRC/tCXlYelyXBtLpY3jt9vV0gXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RPhsg6hM; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RPhsg6hM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1768916013; x=1800452013; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WxYMGLcFQNXnEaihySfQ/dWGKrp0fx37HvGdniAnji8=; b=RPhsg6hMZI4PShgvlHGbLQz4rf2ImEaAQhv3Qv0e4LCN3dRpGcRSgFbk e8l/XwzW7+RqZttsK9i3yS6r8vXPYZw5mxEU96JAtXqqlGY2hBnMZny20 RdLfzBtkFyi9KzMDHaT5Gd63NHg1gjsEpyILuJ4cH1iGdq2xk4tcKlpwh +TZma6edPBQkWgFv//tD/E3HgYL1TmSY7grZFr0BCkI0+8YrFWb6LTD5k jKR0clBntyjmKoWD+7yDL5RZ2mYvjue5aBHFi023NUssWBSFemYjclH31 L8JcKHmpXLLAhsKAwbpxPb1pu+94r4Jw2WbahIpiXsZZbxNELcXU218Ul A==; X-CSE-ConnectionGUID: LuJ3xdpYTo6XlSx3/+UAnQ== X-CSE-MsgGUID: Kd0f2iJASRS5mHyj91gOvw== X-IronPort-AV: E=McAfee;i="6800,10657,11676"; a="81494836" X-IronPort-AV: E=Sophos;i="6.21,240,1763452800"; d="scan'208";a="81494836" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2026 05:33:33 -0800 X-CSE-ConnectionGUID: mA9jWkbcR0uUM1E8F4F8Mw== X-CSE-MsgGUID: wwIIa3OIQ6OdJ+5U/2xA1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,240,1763452800"; d="scan'208";a="210272018" Received: from linux-pnp-server-27.sh.intel.com ([10.239.147.41]) by orviesa003.jf.intel.com with ESMTP; 20 Jan 2026 05:33:29 -0800 From: Tianyou Li To: David Hildenbrand , Oscar Salvador , Mike Rapoport , Wei Yang , Michal Hocko Cc: linux-mm@kvack.org, Yong Hu , Nanhai Zou , Yuan Liu , Tim Chen , Qiuxu Zhuo , Yu C Chen , Pan Deng , Tianyou Li , Chen Zhang , linux-kernel@vger.kernel.org Subject: [PATCH v8 1/3] mm/memory hotplug: Fix zone->contiguous always false when hotplug Date: Tue, 20 Jan 2026 22:33:44 +0800 Message-ID: <20260120143346.1427837-2-tianyou.li@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20260120143346.1427837-1-tianyou.li@intel.com> References: <20260120143346.1427837-1-tianyou.li@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Yuan Liu set_zone_contiguous() uses __pageblock_pfn_to_page() to detect pageblocks that either do not exist (hole) or that do not belong to the same zone. __pageblock_pfn_to_page(), however, relies on pfn_to_online_page(), effectively always returning NULL for memory ranges that were not onlined yet. So when called on a range-to-be-onlined, it indicates a memory hole to set_zone_contiguous(). Consequently, the set_zone_contiguous() call in move_pfn_range_to_zone(), which happens early during memory onlining, will never detect a zone as being contiguous. Bad. To fix the issue, move the set_zone_contiguous() call to a later stage in memory onlining, where pfn_to_online_page() will succeed: after we mark the memory sections to be online. Fixes: 2d070eab2e82 ("mm: consider zone which is not fully populated to hav= e holes") Cc: Michal Hocko Reviewed-by: Nanhai Zou Signed-off-by: Yuan Liu Signed-off-by: Tianyou Li --- mm/memory_hotplug.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index a63ec679d861..c8f492b5daf0 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -782,8 +782,6 @@ void move_pfn_range_to_zone(struct zone *zone, unsigned= long start_pfn, memmap_init_range(nr_pages, nid, zone_idx(zone), start_pfn, 0, MEMINIT_HOTPLUG, altmap, migratetype, isolate_pageblock); - - set_zone_contiguous(zone); } =20 struct auto_movable_stats { @@ -1205,6 +1203,13 @@ int online_pages(unsigned long pfn, unsigned long nr= _pages, } =20 online_pages_range(pfn, nr_pages); + + /* + * Now that the ranges are indicated as online, check whether the whole + * zone is contiguous. + */ + set_zone_contiguous(zone); + adjust_present_page_count(pfn_to_page(pfn), group, nr_pages); =20 if (node_arg.nid >=3D 0) --=20 2.47.1