From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DB71606A31A for ; Mon, 30 Nov 2026 21:11:46 +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=UKES1fLn Received: by kanga.kvack.org (Postfix) id 5CB756B05B0; Mon, 30 Nov 2026 16:11:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A3646B05B1; Mon, 30 Nov 2026 16:11:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B8DE6B05B2; Mon, 30 Nov 2026 16:11:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 18B7B6B05B0 for ; Mon, 30 Nov 2026 16:11:45 -0500 (EST) Received: from smtpin09.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6B779A0C75 for ; Mon, 30 Nov 2026 21:11:44 +0000 (UTC) X-FDA: 85493032128.09.3C5AAB6 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf05.hostedemail.com (Postfix) with ESMTP id BB970100004 for ; Mon, 30 Nov 2026 21:11:42 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=UKES1fLn; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796073102; b=z15VdWL8uAnEajR/DXQqce2Ic9yPKsBtmf2FDdw/iB24BRz8oC71Tzm+O2Yxp2yrOOVrBH IvNG0WJ8OZaSe8caT92LxpUmFabhLYr1ZMQUq+MPUlZ7hacEuSzuQdI6YAbGktSYJ6MwSY xlaVQUkU7XtbyVYlevCWCzzABuFzsTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796073102; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1fk8TyNA18nvnjoAq7/gw4/vAcGQmkMcKxyNGySpy8c=; b=NmfDsMUyOSc9uYOSo+4lESlulItTRGJUsxb2RVaN/LIoPIfCxeLajTYm9HAnpsGloXnsXr k3csv5AmdN0mgriQVDTVxmwVV/UZjaivaeYUU81ar3NwzHoS+/zlwDAhOn0/7cngLQGcQn 2hTiaJ8PoKOYgNfSz5sKznBOQm3YSDo= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=UKES1fLn; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id A44B543BE9; Mon, 30 Nov 2026 21:11:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FABB1F00897; Mon, 30 Nov 2026 21:11:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796073101; bh=1fk8TyNA18nvnjoAq7/gw4/vAcGQmkMcKxyNGySpy8c=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=UKES1fLnx77e/av3XyhU2l4t+hCFseAghGzxgUK+WUYqELGcwyigaKozSvVpGdZX0 I8IIwxn1q2z+L/A2bbrOxj7xdcP7mGQZMMyi/uuaTu8OcSsFUaQu9j3bYW0IJtxu3M 8thO2wrNQP99mPyfIK27RhaRrVirNPRS73HmtkaTY5B+vViJ9n2U0iZsJPmluXkmAf Ss0CKEe5uLnD978PEk4eX6uQpRrzJd7W1XXZAfOe1DQiFyZeI1XdvQuGSPxDpnjyZ2 SNeQw+BQ4S6FjF1jkp8hXMbEI49KkSnDmEbJ1udBeWCaFO0a/0UB3S28OcMPeVHt95 wHuod5ik+QrUA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] selftests/mm: improve memory hotplug test reliability Reply-To: sashiko-reviews@lists.linux.dev To: "Rama Krishna Katta" , linux-mm@kvack.org Cc: "Annam Sai Manisha" , "David Hildenbrand" , "Oscar Salvador" , "Shuah Khan" , linux-cxl@vger.kernel.org In-Reply-To: <20261129211101.3568096-1-ramakrishna.katta@arm.com> References: <20261129211101.3568096-1-ramakrishna.katta@arm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 21:11:40 +0000 X-Rspamd-Queue-Id: BB970100004 X-Stat-Signature: uzac9osk8dmggda5f3abcx94wjh6hcye X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DIET_1, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1796073102-995943 X-HE-Meta: U2FsdGVkX1/yiDgFwcqphX6bsNMMJkpXqvewIkab1GTw/1NwNb4K/a+UosVyRyIvvc70Amp+y2H8s3A6bJ+bIz209DUcVcMvUI7uABHBcIi3Z1uuoG/d4zeZ67h49TSttRbYqsAnbjCjar78NMYNTGAI+9TDaMEOnHsjf++Kfg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zhf+QStvg55ho1RepwuPxTwpBfeOfUWoNs7k3RQSI5gsY2Mc5dbxmPQc2IvQc8ohzN1umn247aIHYq+l7onIdCqNL7NNR9G3sRyOTMEqKrroC9QT1+mi6iVS0k0eUcvF4Optsv2Jk5Odd6lVRG/o8XonT9PIAlmSeaa/ekZlYUKxz0v8+wm7XyJwTOk1vPSkgXr0APRy03YJTqkP3oo+2Qq1SjgK8HMtC2vwvaCW7rw4LihbLJcMI9rNEu9tG71VLor30wPRGQPr8w8zFDj5W7pDSRftyTN1mhnjRaYwLLdfB1ccre7jwVFU3sPxLuWQtgxqr4O6bzhDCccIW2u5AsP5Q3fkGb26pum207VKUv7XmTV/I4dUW7U7w8b8zmbrxg5btUSa9d/tUlTzFELdk3AkkBPtKdFCp5zRA6lvgGQ53ohlphHY9ioDubJBxgtKanjrB68uF1tVVslv+xhncvdG+q8NOWVaEsJkd0l7LHUghoCLx9ORZ1If/4GB4xDNPjhQyiuMYeS/JvkBTpAvaJhgAlEM31Xdc26W3wyM+ovJAPrufz8GGU/GCpT11qXsn0Z0s5aKkk6KyUhxI35V88Wh+J Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] selftests/mm: late EXIT trap registration leaks module and offlined state - [Medium] selftests/mm: restore_memory_blocks() fails to restore initial memory zone - [Medium] selftests/mm: find_test_memory_blocks() loop exceeds 45s kselftest timeout - [Low] selftests/mm: unchecked online_memory_blocks() setup before offline test -- commit d0716524d2006fd022c5934bf01a1bab082cc05c Author: Rama Krishna Katta selftests/mm: improve memory hotplug test reliability This commit converts mem-on-off-test.sh to KTAP output, selects up to four memory blocks by attempting to offline them with a 10-second timeout, exercises notifier error injection and ZONE_MOVABLE onlining, and registers the script in TEST_PROGS. > diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/test= ing/selftests/memory-hotplug/Makefile > index e0a625e34f400..1cda8845977d3 100644 > --- a/tools/testing/selftests/memory-hotplug/Makefile > +++ b/tools/testing/selftests/memory-hotplug/Makefile > @@ -1,11 +1,8 @@ > # SPDX-License-Identifier: GPL-2.0 > -all: > - > -include ../lib.mk > =20 > TEST_PROGS :=3D mem-on-off-test.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 > 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..78e802587772e 100755 > --- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh > +++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh [ ... ] > +offline_memory() > +{ > + timeout --foreground 10s sh -c 'echo offline > "$1"' sh \ > + "$SYSFS/devices/system/memory/memory$1/state" > +} [ ... ] > +find_test_memory_blocks() > +{ > + local -a candidates > + local cur_block path > + local -n blocks=3D$1 > + local target > =20 > + for path in "$SYSFS"/devices/system/memory/memory[0-9]*; do > + candidates+=3D("${path##*/memory}") > + done > + target=3D$(((${#candidates[@]} + 1) / 2)) > + [ "$target" -gt "$MAX_BLOCKS" ] && target=3D$MAX_BLOCKS > + blocks=3D() > + ktap_print_msg "Trying to offline up to $target memory block(s):" > + > + for cur_block in "${candidates[@]}"; do > + [ "${#blocks[@]}" -ge "$target" ] && break > + if memory_is_offline "$cur_block"; then > + ktap_print_msg "$cur_block is already offline" > + INITIAL_STATE[$cur_block]=3Doffline > + blocks+=3D("$cur_block") > fi > + done > + for cur_block in "${candidates[@]}"; do > + [ "${#blocks[@]}" -ge "$target" ] && break > + memory_is_offline "$cur_block" && continue > + memory_is_online "$cur_block" || continue > + if offline_memory_blocks cur_block 0 &>/dev/null; then > + ktap_print_msg "Offlining $cur_block succeeded" > + INITIAL_STATE[$cur_block]=3Donline > + blocks+=3D("$cur_block") > fi > done > + [ "${#blocks[@]}" -gt 0 ] > +} [Severity: Medium] Can find_test_memory_blocks() exceed the default 45-second kselftest runner timeout when scanning online candidates? Adding mem-on-off-test.sh to TEST_PROGS without a settings file runs the script under kselftest's 45-second timeout, while each failed offline_memory() attempt in this loop can take 10 seconds if offline_pages() is retrying page migration on a busy block. If five early candidates time out before $target blocks are collected, runner.sh kills the script with TIMEOUT instead of letting it complete or skip. > +restore_memory_blocks() > +{ > + local block ret=3D0 > + for block in "${test_memory[@]}"; do > + if [ "${INITIAL_STATE[$block]}" =3D offline ]; then > + memory_is_offline "$block" || offline_memory "$block" || ret=3D1 > else > + memory_is_online "$block" || online_memory "$block" kernel || ret=3D1 > fi > done > + return $ret > +} [Severity: Medium] Does restore_memory_blocks() place initially-Movable blocks into a kernel zone and leave blocks onlined into ZONE_MOVABLE during the test in the wrong zone? find_test_memory_blocks() only records "online" in INITIAL_STATE rather than whether the block was originally in ZONE_MOVABLE or a kernel zone. When restore_memory_blocks() runs at the end of the test, online_memory "$block" kernel writes online_kernel, forcing blocks that were originally in ZONE_MOVABLE into a kernel zone where unmovable allocations can prevent future offlining. Conversely, if cleanup() runs while an initially kernel-zone block is online in ZONE_MOVABLE, memory_is_online "$block" succeeds and leaves it in ZONE_MOVABLE. > +cleanup() > { > + if [ -n "$NOTIFIER_ERR_INJECT_DIR" ]; then > + echo 0 > "$NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error" 2>= /dev/null > + echo 0 > "$NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error" 2>/= dev/null > + /sbin/modprobe -q -r memory-notifier-error-inject > fi > + restore_memory_blocks >/dev/null 2>&1 > } > =20 > +ktap_print_header > +prerequisite > +find_test_memory_blocks test_memory > +if [ "${#test_memory[@]}" -eq 0 ]; then > + ktap_skip_all "unable to offline any memory" > + exit "$KSFT_SKIP" > +fi > =20 > +trap cleanup EXIT [Severity: Medium] Should trap cleanup EXIT be installed before prerequisite() and find_test_memory_blocks()? prerequisite() loads the memory-notifier-error-inject module via prepare_error_inject(), and find_test_memory_blocks() offlines up to MAX_BLOCKS memory blocks. If no blocks can be offlined and the script exits with $KSFT_SKIP, cleanup() never runs and memory-notifier-error-inject is left loaded; if the script is interrupted or times out during find_test_memory_blocks() after offlining some blocks, those blocks are left offline. > +if [ -n "$NOTIFIER_ERR_INJECT_DIR" ]; then > + ktap_set_plan 7 > +else > + ktap_set_plan 3 > +fi > +ktap_print_msg "Test scope: ${#test_memory[@]} memory block(s)" > + > +ktap_test_result "Online memory to ZONE_MOVABLE" \ > + online_memory_blocks test_memory movable 0 > +ktap_test_result "Offline memory" \ > + offline_memory_blocks test_memory 0 > + > +if [ -n "$NOTIFIER_ERR_INJECT_DIR" ]; then > + online_memory_blocks test_memory movable 0 > + echo $ERR_INJECT_ERRNO > "$NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OF= FLINE/error" > + ktap_test_result "Offline memory with error injection" \ > + offline_memory_blocks test_memory 1 [Severity: Low] What happens if the setup call to online_memory_blocks test_memory movable 0 fails before "Offline memory with error injection"? Its return value is not checked, so any block that failed to re-online stays offline when offline_memory_blocks test_memory 1 runs; writing offline to an already-offline block fails with -EINVAL without exercising the MEM_GOING_OFFLINE notifier, and offline_memory_blocks() then fails with the misleading message "Memory block $block was offlined unexpectedly". --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129211101.3568= 096-1-ramakrishna.katta@arm.com?part=3D1