Skip to contentSkip to conversation

selftests/cpu-hotplug: Fix check for cpu hotplug not supported

PATCH In review Dmytro Maluka 2 participants 2 messages Mar 19 – Mar 31 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/cpu-hotplug: Fix check for cpu hotplug not supported

If CONFIG_HOTPLUG_CPU is disabled, /sys/devices/system/cpu/cpu* directories are still populated, so the test fails to correctly detect that CPU hotplug is not supported.

Fix this by checking for the presence of 'online' files in those directories instead. The 'online' node is created for the given CPU if and only if this CPU supports hotplug. So if none of the CPUs have 'online' nodes, it means CPU hotplug is not supported.

---
 tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh +1 -1
index 6232a46ca6e1..287cfd5809f6 100755
@@ -24,7 +24,7 @@ prerequisite()
 		exit $ksft_skip
 	fi
 
-	if ! ls $SYSFS/devices/system/cpu/cpu* > /dev/null 2>&1; then
+	if ! ls $SYSFS/devices/system/cpu/cpu*/online > /dev/null 2>&1; then
 		echo $msg cpu hotplug is not supported >&2
 		exit $ksft_skip
 	fi
Signature · 1 line
2.53.0.851.ga537e3e6e9-goog
maintainer
#1 lore raw
Quoted 11 lines · Dmytro Maluka

If CONFIG_HOTPLUG_CPU is disabled, /sys/devices/system/cpu/cpu* directories are still populated, so the test fails to correctly detect that CPU hotplug is not supported.

Fix this by checking for the presence of 'online' files in those directories instead. The 'online' node is created for the given CPU if and only if this CPU supports hotplug. So if none of the CPUs have 'online' nodes, it means CPU hotplug is not supported.

---

Applied to linux_kselftest next for Linux 7.1-rc1.

thanks,
-- Shuah