* [PATCH] selftests/sched: skip cs_prctl_test without core scheduling support
@ 2026-12-06 12:46 Qiliang Yuan
0 siblings, 0 replies; only message in thread
From: Qiliang Yuan @ 2026-12-06 12:46 UTC (permalink / raw)
To: Shuah Khan, Peter Zijlstra
Cc: Chris Hyser, Sinadin Shan, Yifei Liu, Shrikanth Hegde,
linux-kselftest, linux-kernel, Qiliang Yuan
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>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-06 12:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-06 12:46 [PATCH] selftests/sched: skip cs_prctl_test without core scheduling support Qiliang Yuan
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®