Skip to contentSkip to conversation

cfs-scheduler/starvation.c: Skip test on realtime kernels

PATCH Superseded Alessandro Carminati 4 participants 5 messages Jan 21, 2025 – Jan 27, 2025 Library code

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cfs-scheduler/starvation.c: Skip test on realtime kernels

This commit introduces a check in the starvation test case to detect and skip execution on realtime kernels. The test is designed for use with the Completely Fair Scheduler and produces meaningless results when run on realtime kernels.

By skipping the test on realtime kernels, we avoid confusion caused by misleading results.

Changes include:
- Added a detection mechanism for realtime kernels.
- Logic to skip the test execution if the kernel is identified as realtime.

---

V1: https://lore.kernel.org/ltp/[email protected]/

 include/tst_kernel.h                              |  9 +++++++++
 lib/tst_kernel.c                                  | 10 ++++++++++
 testcases/kernel/sched/cfs-scheduler/starvation.c |  3 +++
 3 files changed, 22 insertions(+)
include/tst_kernel.h +9 -0
index 5f49952b7..63ecb19a4 100644
@@ -58,4 +58,13 @@ int tst_check_builtin_driver(const char *driver);
  */
 int tst_check_driver(const char *driver);
 
+/**
+ * tst_check_preempt_rt() - Check if the running kernel is RT.
+ *
+ * Check support for the kernel module (both built-in and loadable).
+ *
+ * Return: -1 if the kernel is RT, 0 otherwise.
+ */
+int tst_check_preempt_rt(void);
+
 #endif	/* TST_KERNEL_H__ */
lib/tst_kernel.c +10 -0
index 8dabfeba2..7084289c3 100644
@@ -214,3 +214,13 @@ int tst_check_driver(const char *driver)
 
 	return -1;
 }
+
+int tst_check_preempt_rt(void)
+{
+	struct utsname uval;
+
+	uname(&uval);
+	if (strstr(uval.version, "PREEMPT_RT"))
+		return -1;
+	return 0;
+}
testcases/kernel/sched/cfs-scheduler/starvation.c +3 -0
index 901556a7b..27bf77f39 100644
@@ -80,6 +80,9 @@ static void setup(void)
 	int cpu = 0;
 	long ncpus = tst_ncpus_conf();
 
+	if (tst_check_preempt_rt())
+		tst_brk(TCONF, "This test is not designed for the RT kernel");
+
 	CPU_ZERO(&mask);
 
 	/* Restrict test to a single cpu */
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Alessandro Carminati

This commit introduces a check in the starvation test case to detect and skip execution on realtime kernels. The test is designed for use with the Completely Fair Scheduler and produces meaningless results when run on realtime kernels.

By skipping the test on realtime kernels, we avoid confusion caused by misleading results.

Quoted 7 lines

Changes include:
- Added a detection mechanism for realtime kernels.
- Logic to skip the test execution if the kernel is identified as realtime.

Quoted 66 lines

---

V1:
https://lore.kernel.org/ltp/[email protected]/

 include/tst_kernel.h                              |  9 +++++++++
 lib/tst_kernel.c                                  | 10 ++++++++++
 testcases/kernel/sched/cfs-scheduler/starvation.c |  3 +++
 3 files changed, 22 insertions(+)
include/tst_kernel.h +9 -0
index 5f49952b7..63ecb19a4 100644
@@ -58,4 +58,13 @@ int tst_check_builtin_driver(const char *driver);
  */
 int tst_check_driver(const char *driver);
 
+/**
+ * tst_check_preempt_rt() - Check if the running kernel is RT.
+ *
+ * Check support for the kernel module (both built-in and loadable).
+ *
+ * Return: -1 if the kernel is RT, 0 otherwise.
+ */
+int tst_check_preempt_rt(void);
+
 #endif /* TST_KERNEL_H__ */
lib/tst_kernel.c +10 -0
index 8dabfeba2..7084289c3 100644
@@ -214,3 +214,13 @@ int tst_check_driver(const char *driver)
 
        return -1;
 }
+
+int tst_check_preempt_rt(void)
+{
+       struct utsname uval;
+
+       uname(&uval);
+       if (strstr(uval.version, "PREEMPT_RT"))
+               return -1;
+       return 0;
+}
testcases/kernel/sched/cfs-scheduler/starvation.c +3 -0
index 901556a7b..27bf77f39 100644
@@ -80,6 +80,9 @@ static void setup(void)
        int cpu = 0;
        long ncpus = tst_ncpus_conf();
 
+       if (tst_check_preempt_rt())
+               tst_brk(TCONF, "This test is not designed for the RT
 kernel");
+
        CPU_ZERO(&mask);
 
        /* Restrict test to a single cpu */

--
2.34.1

Signature · 5 lines
Regards,
Li Wang

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v2 1/1
#3 lore raw
In reply to Alessandro Carminati

Hi!

lib/tst_kernel.c int tst_check_driver(const char *driver) · line 224

Quoted 7 lines
lib/tst_kernel.c +7 -0
+int tst_check_preempt_rt(void)
+{
+	struct utsname uval;
+
+	uname(&uval);
+	if (strstr(uval.version, "PREEMPT_RT"))
+		return -1;

Maybe just return 1; here instead.

Otherwise:

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Hello Cyril,
Thanks for the feedback.

Quoted 11 lines · Cyril Hrubis

Hi!

lib/tst_kernel.c int tst_check_driver(const char *driver) · line 224

Quoted 7 lines
lib/tst_kernel.c +7 -0
+int tst_check_preempt_rt(void)
+{
+     struct utsname uval;
+
+     uname(&uval);
+     if (strstr(uval.version, "PREEMPT_RT"))
+             return -1;

Maybe just return 1; here instead.

Fixing in v3 that will follow in a few minutes.

Quoted 9 lines

Otherwise:

--
Cyril Hrubis
[email protected]

Signature · 8 lines
---
Thanks
Alessandro
172


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp