selftests/arm64: Treat KSM merge_across_nodes as optional
authorMuhammad Usama Anjum <usama.anjum@arm.com>
Tue, 25 Aug 2026 11:18:35 +0000 (12:18 +0100)
committerWill Deacon <will@kernel.org>
Thu, 27 Aug 2026 14:18:39 +0000 (14:18 +0000)
commit1a0dba077f34a2f8faa98308d30d4b546d073145
tree1388c79eb7c04f76b6de598b7b907161173a1e85
parent8d2237e9d6902e234bb89aabb9cd6a9e91357223
selftests/arm64: Treat KSM merge_across_nodes as optional

The MTE KSM test requires write access to KSM sysfs but does not check
that it is running as root. It also unconditionally saves, enables and
restores the merge_across_nodes attribute. The kernel only creates this
attribute when CONFIG_NUMA=y, so a non-NUMA kernel prints the following
message three times even though every KSM subtest passes:

  # ERR: missing /sys/kernel/mm/ksm/merge_across_nodes

Skip the test when it is not running as root. Check that the optional
attribute is readable and writable, treating ENOENT as its expected
absence on non-NUMA kernels and skipping the test for other access
failures. Only save, enable and restore the attribute when it is
available.

Check MTE availability before the privilege and sysfs checks so systems
without MTE retain the existing feature-unavailable skip result.

This preserves the existing behavior on NUMA kernels without requiring
NUMA or reducing KSM coverage on single-node systems.

Fixes: f981d8fa2646 ("kselftest/arm64: Verify KSM page merge for MTE pages")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@arm.com>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
tools/testing/selftests/arm64/mte/check_ksm_options.c