lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251120230235.2857291-1-yifei.l.liu@oracle.com>
Date: Thu, 20 Nov 2025 15:02:35 -0800
From: Yifei Liu <yifei.l.liu@...cle.com>
To: shuah@...nel.org
Cc: yifei.l.liu@...cle.com, linux-kselftest@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH RESEND v2 1/1] selftest/sched: skip the test if smt is not enabled

The core scheduling is for smt enabled cpus. It is not returns
failure and gives plenty of error messages and not clearly points
to the smt issue if the smt is disabled. It just mention
"not a core sched system" and many other messages. For example:

Not a core sched system
tid=210574, / tgid=210574 / pgid=210574: ffffffffffffffff
Not a core sched system
    tid=210575, / tgid=210575 / pgid=210574: ffffffffffffffff
Not a core sched system
        tid=210577, / tgid=210575 / pgid=210574: ffffffffffffffff

(similar things many other times)

In this patch, the test will first read /sys/devices/system/cpu/smt/active,
if the file cannot be opened or its value is 0, the test is skipped with
an explanatory message. This helps developers understand why it is skipped
and avoids unnecessary attention when running the full selftest suite.

Cc: stable@...r.kernel.org
Signed-off-by: Yifei Liu <yifei.l.liu@...cle.com>
---
 tools/testing/selftests/sched/cs_prctl_test.c | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
index 52d97fae4dbd..7ce8088cde6a 100644
--- a/tools/testing/selftests/sched/cs_prctl_test.c
+++ b/tools/testing/selftests/sched/cs_prctl_test.c
@@ -32,6 +32,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 +111,22 @@ static void handle_usage(int rc, char *msg)
 	exit(rc);
 }
 
+int check_smt(void)
+{
+	int c = 0;
+	FILE *file;
+
+	file = fopen("/sys/devices/system/cpu/smt/active", "r");
+	if (!file)
+		return 0;
+	c = fgetc(file) - 0x30;
+	fclose(file);
+	if (c == 0 || c == 1)
+		return c;
+	//if fgetc returns EOF or -1 for correupted files, return 0.
+	return 0;
+}
+
 static unsigned long get_cs_cookie(int pid)
 {
 	unsigned long long cookie;
@@ -271,7 +289,10 @@ int main(int argc, char *argv[])
 		delay = -1;
 
 	srand(time(NULL));
-
+	if (!check_smt()) {
+		ksft_test_result_skip("smt not enabled\n");
+		return 1;
+	}
 	/* put into separate process group */
 	if (setpgid(0, 0) != 0)
 		handle_error("process group");
-- 
2.50.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ