From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796312288; b=B0Of1g4Lz77lFk6S4QQa7NFq+3nF8cF12Q8df+wf180ChhVuxz9nTgaZMMGnHCSKaTdL qZtQfBBHr1WGvdfr+WoF2c2Wjz+7HhaJqp89AF7+/mvj+syM2FqjocZRl9AHhRdgeYcGU Un9+rZPilImulIBpqiL1fwRVZ292KvH5j6PNfgRy/GVvV3gBBcKh9hiKETceyCGwyJ39x 1cGKxCMQ5sy8b3cNP2P6hoPgsTlq6hghTeE3Bes5r5bzIrZJO3lpZ8UK6ZEhwWk6ibMgo wo6cLe0fRrijp54wF5A/tTIT7XiBc/fq1lL8v+giSdKBMEaJ7Si3nuvs0ejNYxJRDIQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796312288; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=IjrzOZ31X1vJt70WPkoj61/vZw84necopAVxlH+fbec=; b=zk8wchLqGr0pvCXAt+cgNToPjsQniO9KOVRsRaV0PdF7ln8sQP45Zxgxu5pkIaMwY0LE lEtMmmU8z8YKTGk0z69jgcIT8AdMmozL8tyPX6PHXMpDI5TkmkqTSjtcg2MXiStAKgSOs os/+781LaMETg1AJGhiIHfOajTKHquyZwNcM9rGYwki2IgmH/fdMDcOa87QbLe8tnmHLB DjSwNYVoD0xr3bUWvRcC7FgeOH5QIyCy6uHaQ9s1/AxchH6bl22ZOiAJxkQV2+HEYMDt/ YU18qOi1AcbPd/AOqBDr7i8DyUy9TbKylMQHfmMONtPScAyZ4G6wq9DcBfggfIURAxw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gjLFPTbW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46AA8606A322 for ; Thu, 3 Dec 2026 15:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gjLFPTbW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D3151F00893; Thu, 3 Dec 2026 15:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796312287; bh=IjrzOZ31X1vJt70WPkoj61/vZw84necopAVxlH+fbec=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=gjLFPTbWfICWU5iz8kNU4dQzjCdOGNsoTLBPulJvuxjbkR+5AAaONobifi5nKA1Su iMzoqqmAF+Hb2MWSlx4h+HC1Pk1i9ouYAM8ka9N96dDgLGecQpnnnjJfPbumtx4VTa 3Aqlw+mpPli4nxXDeVvH8kt0msTYcVaUmy12lARh5EkKAQWaD5fFzJUn5UNZVL7IWZ r5nZDEjGrVVE32ns3J/FlMtie5FgsJds6MNHQyOgBbE2g3h/dzQBJoavb8yjVS7u6B eQb+0VKQPeFEXi2tJmYdYpM3HmaiPEuIAuntgiL5wVaJTV+/X1PwIoPx9s77Q1zk+1 mSVLVVx/34ZNQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] selftests/mm: improve memory hotplug test reliability Reply-To: sashiko-reviews@lists.linux.dev To: "Rama Krishna Katta" , david@kernel.org, osalvador@suse.de, shuah@kernel.org Cc: linux-mm@kvack.org, linux-cxl@vger.kernel.org, "Annam Sai Manisha" In-Reply-To: <20261202204303.2777765-1-ramakrishna.katta@arm.com> References: <20261202204303.2777765-1-ramakrishna.katta@arm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 15:38:07 +0000 X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] selftests/mm: DMA/DMA32 zone restoration failure in restore_memory_block() - [Medium] selftests/mm: out-of-tree run_hotplug failure in run_full_test target -- commit b63a4a9a717654c3ff50e9a2c850549c49f04eec Author: Rama Krishna Katta selftests/mm: improve memory hotplug test reliability This commit converts the memory hotplug selftest to KTAP, bounds memory block selection and offlining attempts, and adds cleanup to restore each block's initial state and zone. > diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/test= ing/selftests/memory-hotplug/Makefile > index e0a625e34f400..078cb59cbd07a 100644 > --- a/tools/testing/selftests/memory-hotplug/Makefile > +++ b/tools/testing/selftests/memory-hotplug/Makefile > @@ -1,11 +1,9 @@ > # SPDX-License-Identifier: GPL-2.0 > -all: > - > -include ../lib.mk > =20 > TEST_PROGS :=3D mem-on-off-test.sh > +TEST_INCLUDES :=3D ../kselftest/ktap_helpers.sh > =20 > -run_full_test: > - @/bin/bash ./mem-on-off-test.sh -r 10 && echo "memory-hotplug selftests= : [PASS]" || echo "memory-hotplug selftests: [FAIL]" > +include ../lib.mk > =20 > -clean: > +.PHONY: run_full_test > +run_full_test: run_tests [Severity: Medium] Does aliasing run_full_test to run_tests break the top-level run_hotplug target for out-of-tree builds (O=3D or KBUILD_OUTPUT=3D)? tools/testing/selftests/Makefile: hotplug: @for TARGET in $(TARGETS_HOTPLUG); do \ BUILD_TARGET=3D$$BUILD/$$TARGET; \ $(MAKE) OUTPUT=3D$$BUILD_TARGET -C $$TARGET;\ done; run_hotplug: hotplug @for TARGET in $(TARGETS_HOTPLUG); do \ BUILD_TARGET=3D$$BUILD/$$TARGET; \ $(MAKE) OUTPUT=3D$$BUILD_TARGET -C $$TARGET run_full_test;\ done; Unlike the top-level all and run_tests targets, hotplug and run_hotplug do not run mkdir -p $$BUILD_TARGET and do not pass SRC_PATH or OBJ_PATH to sub-makes. When building_out_of_srctree is set, lib.mk's run_tests fails to stage TEST_PROGS into a missing $(OUTPUT) directory and runs INSTALL_INCLUDES with SRC_PATH and OBJ_PATH empty, causing INSTALL_INCLUDES to strip only the leading slash from entry_dir, cd to $HOME, and attempt to rsync to /. > diff --git a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh b/= tools/testing/selftests/memory-hotplug/mem-on-off-test.sh > index 611be86eaf3de..654a981fa8a11 100755 > --- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh > +++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh [ ... ] > + for path in "${candidates[@]}"; do > + [ "${#test_memory[@]}" -lt "$target" ] || break > + [ "$attempts" -lt "$MAX_OFFLINE_ATTEMPTS" ] || break > + read -r state < "$path/state" || continue > + [ "$state" =3D online ] || continue > + IFS=3D read -r zone < "$path/valid_zones" || continue > + case "$zone" in > + DMA|DMA32|Normal|Movable) ;; > + *) continue ;; > + esac [ ... ] > +restore_memory_block() > +{ > + local block=3D$1 type=3Dkernel zone=3D${initial_zone[$1]} > + > + if [ "${initial_state[$block]}" =3D offline ]; then > + memory_state_is "$block" offline || > + offline_memory "$block" || return 1 > + memory_state_is "$block" offline > + return > + fi > + > + if memory_state_is "$block" online; then > + memory_zone_is "$block" "$zone" && return 0 > + offline_memory "$block" || return 1 > + fi > + memory_state_is "$block" offline || return 1 > + # online_kernel selects a kernel zone; verify the exact original zone. > + [ "$zone" !=3D Movable ] || type=3Dmovable > + online_memory "$block" "$type" || return 1 > + memory_state_is "$block" online && memory_zone_is "$block" "$zone" > +} [Severity: Medium] Can restore_memory_block() fail to restore a DMA or DMA32 block to its original zone? When find_test_memory_blocks() offlines a block at the start or end of ZONE_DMA or ZONE_DMA32 (or the last online block in that zone), offline_pages() -> remove_pfn_range_from_zone() -> shrink_zone_span() shrinks the zone span so it no longer covers that block's PFN range. When restore_memory_block() later writes online_kernel, default_kernel_zone_for_pfn() checks whether the PFN range still intersects any zone below ZONE_NORMAL: mm/memory_hotplug.c:default_kernel_zone_for_pfn() { for (zid =3D 0; zid < ZONE_NORMAL; zid++) { struct zone *zone =3D &pgdat->node_zones[zid]; if (zone_intersects(zone, start_pfn, nr_pages)) return zone; } return &pgdat->node_zones[ZONE_NORMAL]; } Because the shrunken DMA or DMA32 zone span no longer intersects the block, the kernel places the block into ZONE_NORMAL, causing the memory_zone_is check to fail and leaving the block in ZONE_NORMAL. Should find_test_memory_blocks() only select online blocks from Normal and Movable zones? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202204303.2777= 765-1-ramakrishna.katta@arm.com?part=3D1