On Fri, 9 Jan 2026 17:43:13 +0800 Sun Jian <[email protected]> wrote:
> ksm_tests writes KSM sysfs knobs under /sys/kernel/mm/ksm, which requires
> root privileges. When run unprivileged, it fails with permission errors
> and reports FAIL, which is misleading.
>
> Skip the test early when not run as root to avoid false failures.
Thanks.
When reissuing a patch it's nice to cc those individuals who commented
on previous versions.
> --- a/tools/testing/selftests/mm/ksm_tests.c
> +++ b/tools/testing/selftests/mm/ksm_tests.c
> @@ -766,6 +766,11 @@ int main(int argc, char *argv[])
> bool merge_across_nodes = KSM_MERGE_ACROSS_NODES_DEFAULT;
> long size_MB = 0;
>
> + if (geteuid() != 0) {
> + printf("# SKIP ksm_tests requires root privileges\n");
> + return KSFT_SKIP;
> + }
> +
lgtm. selftests/ code performs this test in about 20 places already,
all different. In the interests of consistency and code cleanliness,
perhaps some kind person will centralize this check in some fashion!