From: Andrew Morton <akpm@linux-foundation.org>
To: Sun Jian <sun.jian.kdev@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, SeongJae Park <sj@kernel.org>
Subject: Re: [PATCH] selftests/mm: ksm_tests: skip when not run as root
Date: Sat, 10 Jan 2026 16:37:04 -0800 [thread overview]
Message-ID: <20260110163704.7b5e1e10735113baa23f42ef@linux-foundation.org> (raw)
In-Reply-To: <20260109094313.52307-1-sun.jian.kdev@gmail.com>
On Fri, 9 Jan 2026 17:43:13 +0800 Sun Jian <sun.jian.kdev@gmail.com> 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!
prev parent reply other threads:[~2026-01-11 0:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 9:43 Sun Jian
2026-01-10 1:16 ` SeongJae Park
2026-01-10 12:44 ` sun jian
2026-01-10 17:00 ` SeongJae Park
2026-01-11 0:37 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260110163704.7b5e1e10735113baa23f42ef@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shuah@kernel.org \
--cc=sj@kernel.org \
--cc=sun.jian.kdev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox