From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (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 A45582E6CC0 for ; Thu, 9 Apr 2026 02:35:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775702159; cv=none; b=jHh8pzNO0ZY0iUA7cdOzZ0wKGNPZ29XdetuJJNweP2PNhi88ItfAKzpfxuAcT72THKmmG5/l08V0Mj2Z6nQgbgPUbwKQPbpIR7BA52czfHwcLDmqoTemlAj3WdcyHA7SrpIKEoTwJcQcwIg62l0uwS7ZAV4tNERQD2hV/Rjo4VQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775702159; c=relaxed/simple; bh=EgyQWAqjXBYcAVjTVnSrVpV0lEF60rPjz8EdGAuNOIc=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:In-Reply-To: Content-Type:References; b=lXi9Rg9yGMRNbGUemWUeTWcn2bjkubQllNcrTrRZIa7dU94itJp/OI+gTl/Ee9Q37j+Xzavz8KDfKXyt0FYYhEE3+w9kncOEezFm6eqpPj8d5LJt3OaCVUqPPv9kCIkrg0hNHTzwFvzJJpJdBFr38pWea6rZIsXfBVfp8zeb81I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=UGpa0zeX; arc=none smtp.client-ip=203.254.224.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="UGpa0zeX" Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20260409023554epoutp017199e7a746c73f9b11d72447c67a2838~kj7OMjKPa1815618156epoutp014 for ; Thu, 9 Apr 2026 02:35:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20260409023554epoutp017199e7a746c73f9b11d72447c67a2838~kj7OMjKPa1815618156epoutp014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1775702154; bh=Svwkd34gA5sOnhAwfBHI8rDp7I4bZYBAYTElFQpGfuY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UGpa0zeXYvwxImJu2Xw0qS9DNYeORc4H7+2xLADkYUxMdVnVQLJ8TbF4n+Ave30V0 NIsNWjDoG/u7BZBKQIkc9ev/6kDBwyqq9hcS0X/ta1G/hHJxMN9mvX1nSMve2SZ5v2 sMHpRwgFi8LNqKaug2sNw8ze95gAu/4MjtO0SHK0= Received: from epsnrtp01.localdomain (unknown [182.195.42.153]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPS id 20260409023554epcas2p29b35a3c31622764ae384f17ce2139964~kj7N0E8dH1248612486epcas2p2R; Thu, 9 Apr 2026 02:35:53 +0000 (GMT) Received: from epcas2p3.samsung.com (unknown [182.195.38.209]) by epsnrtp01.localdomain (Postfix) with ESMTP id 4frkZK3t6Kz6B9m7; Thu, 9 Apr 2026 02:35:53 +0000 (GMT) Received: from epsmtip1.samsung.com (unknown [182.195.34.30]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20260409023553epcas2p2e40d1d79206f0169a765fadcf180b010~kj7M6g5qo1249512495epcas2p2L; Thu, 9 Apr 2026 02:35:53 +0000 (GMT) Received: from AE (unknown [12.81.78.179]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20260409023552epsmtip12b61a69ae4dbba27ca8fa276504ffec5~kj7M0tsTX2647326473epsmtip1j; Thu, 9 Apr 2026 02:35:52 +0000 (GMT) Date: Thu, 9 Apr 2026 11:35:52 +0900 From: Sion Ji To: Yuan Liu Cc: David Hildenbrand , Oscar Salvador , Mike Rapoport , 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] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range Message-ID: <20260409023552.GA2807@AE> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20260319095622.1130380-1-yuan1.liu@intel.com> X-CMS-MailID: 20260409023553epcas2p2e40d1d79206f0169a765fadcf180b010 X-Msg-Generator: CA Content-Type: multipart/mixed; boundary="----atTJT_IMamyeT3aYIDqNfPm07F0lpbeBE4hx2ZgfjOvbTF6B=_51383_" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P cpgsPolicy: CPGSC10-223,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20260409023553epcas2p2e40d1d79206f0169a765fadcf180b010 References: <20260319095622.1130380-1-yuan1.liu@intel.com> ------atTJT_IMamyeT3aYIDqNfPm07F0lpbeBE4hx2ZgfjOvbTF6B=_51383_ Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline On Thu, Mar 19, 2026 at 05:56:22AM -0400, Yuan Liu wrote: > When invoke move_pfn_range_to_zone or remove_pfn_range_from_zone, it will > update the zone->contiguous by checking the new zone's pfn range from the > beginning to the end, regardless the previous state of the old zone. When > the zone's pfn range is large, the cost of traversing the pfn range to > update the zone->contiguous could be significant. > > Add a new zone's pages_with_memmap member, it is pages within the zone that > have an online memmap. It includes present pages and memory holes that have > a memmap. When spanned_pages == pages_with_online_memmap, pfn_to_page() can > be performed without further checks on any pfn within the zone span. > > The following test cases of memory hotplug for a VM [1], tested in the > environment [2], show that this optimization can significantly reduce the > memory hotplug time [3]. > > +----------------+------+---------------+--------------+----------------+ > | | Size | Time (before) | Time (after) | Time Reduction | > | +------+---------------+--------------+----------------+ > | Plug Memory | 256G | 10s | 3s | 70% | > | +------+---------------+--------------+----------------+ > | | 512G | 36s | 7s | 81% | > +----------------+------+---------------+--------------+----------------+ > > +----------------+------+---------------+--------------+----------------+ > | | Size | Time (before) | Time (after) | Time Reduction | > | +------+---------------+--------------+----------------+ > | Unplug Memory | 256G | 11s | 4s | 64% | > | +------+---------------+--------------+----------------+ > | | 512G | 36s | 9s | 75% | > +----------------+------+---------------+--------------+----------------+ > > [1] Qemu commands to hotplug 256G/512G memory for a VM: > object_add memory-backend-ram,id=hotmem0,size=256G/512G,share=on > device_add virtio-mem-pci,id=vmem1,memdev=hotmem0,bus=port1 > qom-set vmem1 requested-size 256G/512G (Plug Memory) > qom-set vmem1 requested-size 0G (Unplug Memory) > > [2] Hardware : Intel Icelake server > Guest Kernel : v7.0-rc4 > Qemu : v9.0.0 > > Launch VM : > qemu-system-x86_64 -accel kvm -cpu host \ > -drive file=./Centos10_cloud.qcow2,format=qcow2,if=virtio \ > -drive file=./seed.img,format=raw,if=virtio \ > -smp 3,cores=3,threads=1,sockets=1,maxcpus=3 \ > -m 2G,slots=10,maxmem=2052472M \ > -device pcie-root-port,id=port1,bus=pcie.0,slot=1,multifunction=on \ > -device pcie-root-port,id=port2,bus=pcie.0,slot=2 \ > -nographic -machine q35 \ > -nic user,hostfwd=tcp::3000-:22 > > Guest kernel auto-onlines newly added memory blocks: > echo online > /sys/devices/system/memory/auto_online_blocks > > [3] The time from typing the QEMU commands in [1] to when the output of > 'grep MemTotal /proc/meminfo' on Guest reflects that all hotplugged > memory is recognized. Since the above results were tested in a QEMU environment, we ran the tests in a real-world environment [1]. The kernel version is v7.0-rc4, which is the same as the QEMU guest kernel. We configured remote memory node using 2 and 4 CXL devices for the 256G and 512G tests, respectively. We replaced the QEMU hotplug commands with the daxctl [2]. We tested by changing the value of /sys/devices/system/memory/auto_online_blocks. The following is the result when the kernel onlines added memory blocks: (echo online > /sys/devices/system/memory/auto_online_blocks) +----------------+------+---------------+--------------+----------------+ | | Size | Time (before) | Time (after) | Time Reduction | | +------+---------------+--------------+----------------+ | Plug Memory | 256G | 6.7s | 4.4s | -35% | | +------+---------------+--------------+----------------+ | | 512G | 18s | 8.7s | -52% | +----------------+------+---------------+--------------+----------------+ +----------------+------+---------------+--------------+----------------+ | | Size | Time (before) | Time (after) | Time Reduction | | +------+---------------+--------------+----------------+ | Unplug Memory | 256G | 2.8s | 2.6s | -8% | | +------+---------------+--------------+----------------+ | | 512G | 5.2s | 5s | -4% | +----------------+------+---------------+--------------+----------------+ [1] Platform : Intel GNR-AP CPU : Intel(R) Xeon(R) 6960P Memory : Samsung DDR5-4800 Hotplug devices : Samsung CXL 2.0 128G Devices Kernel : v7.0-rc4 [2] daxctl commands to hotplug memory for a test: time daxctl reconfigure-device --force --mode=system-ram dax0.0 (Plug Memory) time daxctl reconfigure-device --force --mode=devdax dax0.0 (Unplug Memory) The following is the result when the value is set to online_movable: (echo online_movable > /sys/devices/system/memory/auto_online_blocks) +----------------+------+---------------+--------------+----------------+ | | Size | Time (before) | Time (after) | Time Reduction | | +------+---------------+--------------+----------------+ | Plug Memory | 256G | 4.5s | 4.4s | -3% | | +------+---------------+--------------+----------------+ | | 512G | 18.6s | 6.6s | -65% | +----------------+------+---------------+--------------+----------------+ +----------------+------+---------------+--------------+----------------+ | | Size | Time (before) | Time (after) | Time Reduction | | +------+---------------+--------------+----------------+ | Unplug Memory | 256G | 2.2s | 2.6s | +18% | | +------+---------------+--------------+----------------+ | | 512G | 5.2s | 4.2s | -20% | +----------------+------+---------------+--------------+----------------+ FYI, it is the result when kernel does not automatically online memory. (echo offline > /sys/devices/system/memory/auto_online_blocks) +----------------+------+---------------+--------------+----------------+ | | Size | Time (before) | Time (after) | Time Reduction | | +------+---------------+--------------+----------------+ | Plug Memory | 256G | 3.3s | 4.4s | +33% | | +------+---------------+--------------+----------------+ | | 512G | 6.7s | 6.6s | -2% | +----------------+------+---------------+--------------+----------------+ +----------------+------+---------------+--------------+----------------+ | | Size | Time (before) | Time (after) | Time Reduction | | +------+---------------+--------------+----------------+ | Unplug Memory | 256G | 2.2s | 2.6s | +18% | | +------+---------------+--------------+----------------+ | | 512G | 4.4s | 4.2s | -5% | +----------------+------+---------------+--------------+----------------+ We hope this result is helpful. Regards, Sion Ji ------atTJT_IMamyeT3aYIDqNfPm07F0lpbeBE4hx2ZgfjOvbTF6B=_51383_ Content-Type: text/plain; charset="utf-8" ------atTJT_IMamyeT3aYIDqNfPm07F0lpbeBE4hx2ZgfjOvbTF6B=_51383_--