From nobody Sun Feb 8 09:10:53 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 BF2072BE04B for ; Fri, 30 Jan 2026 15:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769785753; cv=none; b=G9nZJT/K6iCaz2P2h51A+y2TbRSWQwcNQoEVDbClMVsthvsMpV/CiixSLOf6keUYAkb0mmuL6QlKMB/r40HBYFGOJAf/1QstBo11NDoJ1PfsTtCc1SdogXwTW13DSk6yIt1WoQtlo+teiI4zR7Uv/huA5DkGf6yJ0ws8engpqYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769785753; c=relaxed/simple; bh=vFZM82pSaymmTWBe40lRSwnDX7vpqqmpLiq/Cb19+88=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VdDCCH9Z4lEtyn7zKYVwzHCyZgtuwxDekZ+08YjAOiN5OQBZRmimIHb/b4v6YuiJkw2NOZoVNrB6PYFWTXwUXhhsdqt0U0uUS8TmvSKcUUydzvNTeVj3rX+itgZFVJntTnb+lOXG0ruEugFRgRc26IyfGOv70wIJQ0nS30XhDXg= 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=eGxqSab4; arc=none smtp.client-ip=198.175.65.15 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="eGxqSab4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1769785752; x=1801321752; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=vFZM82pSaymmTWBe40lRSwnDX7vpqqmpLiq/Cb19+88=; b=eGxqSab4kR3kNQLOR9FXEb11j7xIr9OBgt68HmMbBahy6j0qGsD6/Bzv Px7LTWNb88fVseKXoEqSIY2ia9Wlk+lXH+K+nG5/Ia+PcsOTRkczV8+pN ydYkmmTl0pSH2v+aAOLDbEiaI8iCT++eI/9F1yjfZG9ojw+ezaaeNV+zZ fdpiswGz0iqd7LxB+6dSqn3IHUw6GtRauWoNohLvJkipd0aTt4+lI7h3R cvUanaFiC0qSkHlAQpM1dacN12x50x+bfJvPItFw8IceN9qGUGnXgEuQt LVZKgzTWPKa0ZEQKhukuoltW4KGMq5xgh3UFIWtM0wSwmUOtOS425Vc0A A==; X-CSE-ConnectionGUID: GQ9TRlW6Q2C4mK89rRcelA== X-CSE-MsgGUID: /IyTPTyJR/i7/AHI7osRIQ== X-IronPort-AV: E=McAfee;i="6800,10657,11686"; a="74659847" X-IronPort-AV: E=Sophos;i="6.21,263,1763452800"; d="scan'208";a="74659847" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2026 07:09:11 -0800 X-CSE-ConnectionGUID: AdpxE0LwSkGuKfBxrwrP3Q== X-CSE-MsgGUID: FC6X6yZ7QyuuUFA60B2CoQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,263,1763452800"; d="scan'208";a="212950008" Received: from linux-pnp-server-27.sh.intel.com ([10.239.147.41]) by orviesa003.jf.intel.com with ESMTP; 30 Jan 2026 07:09:07 -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] mm/memory hotplug: Fix zone->contiguous always false when hotplug Date: Sat, 31 Jan 2026 00:09:38 +0800 Message-ID: <20260130160938.2671462-1-tianyou.li@intel.com> X-Mailer: git-send-email 2.47.1 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: the fast path relies on the zone contiguous state may skipped. 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 Cc: stable@vger.kernel.org Reviewed-by: Nanhai Zou Signed-off-by: Yuan Liu Signed-off-by: Tianyou Li Acked-by: David Hildenbrand (Arm) --- Separated from: https://lore.kernel.org/linux-mm/20260120143346.1427837-1-t= ianyou.li@intel.com/ 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