From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 DEC1C30DD0C for ; Fri, 30 Jan 2026 15:37:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769787449; cv=none; b=dvUjHFUma8eE0kdu30Mo5zZEZb72ZomdEsqiHZCw8rzO0axJ75gdufdmut7r5/jkfR3nsxnf9/OApGHUz7qYnGztPRCJhUNQ16Mf6czYA6k6UdJ207NjP9QROpq3VfIDtH8GAUxZ+K+uZHUco0pJoZDg2LiYlJex4NxA4s7zhUg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769787449; c=relaxed/simple; bh=uSb4t7pnsOqvxu0VMSD/Ba2NeQ5REWSQ7aHHa7N/Xzs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mHz4e96C2TiZLL0nTJbCu7EDL4AmThObT5tcSDywINjsoWSsrw5C24bvvwkeSJ7xV2pk5m/3wj6fQBC45x5k02S74qEY2pVCHjII6rLw1f44vYVkoOGlW2VII8tjWlPI1OUGBRGjY0KV6QFps14qNsfhIX+Tt22+UhhvPJw9b98= 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=CgL6fnsI; arc=none smtp.client-ip=192.198.163.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="CgL6fnsI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1769787447; x=1801323447; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=uSb4t7pnsOqvxu0VMSD/Ba2NeQ5REWSQ7aHHa7N/Xzs=; b=CgL6fnsIBjaC2WmlolXolz/fknbYqZvTrp8DXDKhb2o86EmP7zAw7Gr/ oavyhDPqALjVWkvXsIw7zv9YmSYrBHFjNhpwyRu2XKu6vPpRcBb5Fpn/0 dOJvBERYOJGwM9Bdp4fex9zfMjk47wAincUiW80esz0vbPFIMlJ/9g5mN GfQUqSviGvjWaOwAYmu9/+w6mE52PuesNsEIO1mXZI2FeGAnAEcAvG/oQ Ah5iKxJ5roqdMvRdjUaGe6EoKkYJKnJD3fAdVkl5BxoncGkwj13qrxhDU Zk4Cxivt6kXPBF5k09bbg9fn3BDg/jHK99QX/y09R0or+IpeTQjToJ4cP Q==; X-CSE-ConnectionGUID: WXbtYwi3Roqc6XQTfSgaTg== X-CSE-MsgGUID: c+H6sq51QJapYjbhKPl2Mw== X-IronPort-AV: E=McAfee;i="6800,10657,11686"; a="71124506" X-IronPort-AV: E=Sophos;i="6.21,263,1763452800"; d="scan'208";a="71124506" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2026 07:37:27 -0800 X-CSE-ConnectionGUID: Ur4XIj3iQpOTBSjjx52ftA== X-CSE-MsgGUID: v0WOKj+IRwSyuIgLO9agLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,263,1763452800"; d="scan'208";a="208989042" Received: from linux-pnp-server-27.sh.intel.com ([10.239.147.41]) by orviesa007.jf.intel.com with ESMTP; 30 Jan 2026 07:37:24 -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 v9 0/2] Optimize zone->contiguous update Date: Sat, 31 Jan 2026 00:37:54 +0800 Message-ID: <20260130163756.2674225-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: 8bit This series contains 2 patches. The first one encapsulate the mhp_init_memmap_on_memory() and online_pages() into online_memory_block_pages(), the mhp_deinit_memmap_on_memory() and offline_pages() into offline_memory_block_pages(). Then move most of memory_block_online() to the new function mhp_block_online(struct memory_block *block) and correspondingly memory_block_offline() to mhp_block_offline(struct memory_block *block). The second one add a fast path to check the zone->contiguous. Changes History =============== v9 changes: 1. Separate the bug fix and optimization into two patches. 2. This patchset depends on the https://lore.kernel.org/linux-mm/20260130160938.2671462-1-tianyou.li@intel.com/. 3. Refactor the code to move most of memory_block_online() to mhp_block_online() and correspondingly memory_block_offline() to mhp_block_offline(). v8 changes: 1. Rebased to 6.19-rc6 2. Add online_memory_block_pages() and offline_memory_block_pages() v7 changes: 1. Rebased to 6.19-rc1 2. Reorder the patches so that the fix will be the first in the series. v6 changes: 1. Improve coding style. 2. Add comments. v5 changes: 1. Improve coding style. 2. Fix a issue in which zone->contiguous was always false when adding new memory, leveraging the fast path optimization. v4 changes: 1. Improve coding style. 2. Add fast path for zone contiguity check in memory unplugged cases, and update test results. 3. Refactor set_zone_contiguous: the new set_zone_contiguous updates zone contiguity based on the fast path results. v3 changes: Add zone contiguity check for empty zones. v2 changes: Add check_zone_contiguous_fast function to check zone contiguity for new memory PFN ranges. Tianyou Li (2): mm/memory hotplug/unplug: Add online_memory_block_pages() and offline_memory_block_pages() mm/memory hotplug/unplug: Optimize zone->contiguous update when changes pfn range drivers/base/memory.c | 115 +----------------- include/linux/memory_hotplug.h | 13 +-- include/linux/mm.h | 6 + mm/internal.h | 8 +- mm/memory_hotplug.c | 208 ++++++++++++++++++++++++++++++--- mm/mm_init.c | 15 ++- 6 files changed, 228 insertions(+), 137 deletions(-) -- 2.47.1