From: Qiliang Yuan <qiliang.yuan@linux.dev>
To: Shuah Khan <shuah@kernel.org>, Peter Zijlstra <peterz@infradead.org>
Cc: Chris Hyser <chris.hyser@oracle.com>,
Sinadin Shan <sinadin.shan@oracle.com>,
Yifei Liu <yifei.l.liu@oracle.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Qiliang Yuan <qiliang.yuan@linux.dev>
Subject: [PATCH] selftests/sched: skip cs_prctl_test without core scheduling support
Date: Sun, 06 Dec 2026 07:46:01 -0500 [thread overview]
Message-ID: <20261206-fix-selftests-sched-cs-prctl-skip-v1-1-b8bf6e7cd711@linux.dev> (raw)
PR_SCHED_CORE fails with ENODEV when SMT is not active, and with EINVAL
when the kernel is built without CONFIG_SCHED_CORE. In both cases core
scheduling cannot be tested.
cs_prctl_test does not check for either and runs anyway, so it reports a
failure on any machine without SMT or with such a kernel:
Not a core sched system
tid=2445, / tgid=2445 / pgid=2445: ffffffffffffffff
...
(283) FAILED: get_cs_cookie(0) == 0
...
(cs_prctl_test.c:287) - core_sched create failed -- PGID: Invalid argument
Read the cookie of the test itself before anything else and exit with
KSFT_SKIP on ENODEV or EINVAL, saying which one applies. Any other error
still fails the test.
Fixes: 9f26990074931 ("kselftest: Add test for core sched prctl interface")
Signed-off-by: Qiliang Yuan <qiliang.yuan@linux.dev>
---
Sinadin Shan [1] and Yifei Liu [2] posted fixes for this before, and
neither was merged. [2] returns 1 after reporting the skip, so the
runner still counts a failure, and it does not cover kernels without
CONFIG_SCHED_CORE. [1] probes with pid_max + 1 and treats any error but
ESRCH as unsupported. This one reads the test's own cookie and skips
only on ENODEV or EINVAL.
[1] https://lore.kernel.org/r/20250225200910.260569-3-sinadin.shan@oracle.com
[2] https://lore.kernel.org/r/20251120230235.2857291-1-yifei.l.liu@oracle.com
---
tools/testing/selftests/sched/cs_prctl_test.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
index 52d97fae4dbd8..727cbe0459816 100644
--- a/tools/testing/selftests/sched/cs_prctl_test.c
+++ b/tools/testing/selftests/sched/cs_prctl_test.c
@@ -20,6 +20,7 @@
*/
#define _GNU_SOURCE
+#include <linux/types.h>
#include <sys/eventfd.h>
#include <sys/wait.h>
#include <sys/types.h>
@@ -32,6 +33,8 @@
#include <stdlib.h>
#include <string.h>
+#include "../kselftest.h"
+
#if __GLIBC_PREREQ(2, 30) == 0
#include <sys/syscall.h>
static pid_t gettid(void)
@@ -109,6 +112,24 @@ static void handle_usage(int rc, char *msg)
exit(rc);
}
+/* Skip unless this kernel can do core scheduling on this machine */
+static void check_core_sched(void)
+{
+ /* Keep it aligned or PR_SCHED_CORE_GET fails with EINVAL */
+ __aligned_u64 cookie;
+
+ if (!prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, 0, PIDTYPE_PID,
+ (unsigned long)&cookie))
+ return;
+
+ if (errno == ENODEV)
+ ksft_exit_skip("core scheduling needs SMT, which is not active\n");
+ if (errno == EINVAL)
+ ksft_exit_skip("core scheduling is not supported (CONFIG_SCHED_CORE)\n");
+
+ handle_error("core_sched get failed");
+}
+
static unsigned long get_cs_cookie(int pid)
{
unsigned long long cookie;
@@ -270,6 +291,8 @@ int main(int argc, char *argv[])
if (keypress)
delay = -1;
+ check_core_sched();
+
srand(time(NULL));
/* put into separate process group */
---
base-commit: d14d00a5fea1ee2540be6a2238314b7ba1e41f86
change-id: 20261206-fix-selftests-sched-cs-prctl-skip-c0b0120abdc4
Best regards,
--
Qiliang Yuan <qiliang.yuan@linux.dev>
reply other threads:[~2026-12-06 12:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261206-fix-selftests-sched-cs-prctl-skip-v1-1-b8bf6e7cd711@linux.dev \
--to=qiliang.yuan@linux.dev \
--cc=chris.hyser@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=shuah@kernel.org \
--cc=sinadin.shan@oracle.com \
--cc=sshegde@linux.ibm.com \
--cc=yifei.l.liu@oracle.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
all inboxes | Powered by JetHome®