Skip to contentSkip to conversation

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

PATCH Superseded Alessandro Carminati 2 participants 4 messages Jan 20, 2025 – Jan 21, 2025 Library code

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 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..c620c9c3e 100644
@@ -82,6 +82,9 @@ static void setup(void)
 
 	CPU_ZERO(&mask);
 
+	if (tst_check_preempt_rt())
+		tst_brk(TCONF, "This test is not designed for the RT kernel");
+
 	/* Restrict test to a single cpu */
 	if (sched_getaffinity(0, sizeof(mask), &mask) < 0)
 		tst_brk(TBROK | TERRNO, "sched_getaffinity() failed");
Signature · 5 lines
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/1
#1 lore raw

Hi Alessandro,

Quoted 5 lines

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.

Quoted 7 lines

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.

LGTM. Could you please test if starvation.c worked previously? Or was it always broken?

Quoted 14 lines
lib/tst_kernel.c +9 -0
+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 +0 -0
index 901556a7b..c620c9c3e 100644

testcases/kernel/sched/cfs-scheduler/starvation.c static void setup(void) · line 86

Quoted 5 lines
testcases/kernel/sched/cfs-scheduler/starvation.c +2 -0
@@ -82,6 +82,9 @@ static void setup(void)
 
 	CPU_ZERO(&mask);
 
+	if (tst_check_preempt_rt())
+		tst_brk(TCONF, "This test is not designed for the RT kernel");

nit: I would move it above CPU_ZERO().

NOTE: we should also move tst_has_slow_kconfig() check to be at the top of setup(). But that's unrelated. Also at least on Tumbleweed and SLES which get detected as slow due CONFIG_LATENCYTOP test was worked before.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hello Petr,

Quoted 11 lines · Petr Vorel

Hi Alessandro,

Quoted 7 lines

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
Quoted 4 lines

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

LGTM. Could you please test if starvation.c worked previously? Or was it always broken?

Before submitting the patch, I tested the case in various environments. One thing that puzzled me for a while was the test's high sensitivity to latencies.
While it works correctly on bare-metal systems under the intended conditions with the CFS scheduler, running it on a real-time kernel or in a virtualized/emulated environment is likely to cause the test to fail.

This patch addresses the real-time kernel scenario, which is relatively easier to handle.
In a separate RFC patch I plan to send, I would like to ask the community for guidance on how to handle the virtualization/emulation environment issue.

Quoted 18 lines
Quoted 14 lines
lib/tst_kernel.c +9 -0
+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 +0 -0
index 901556a7b..c620c9c3e 100644
@@ -82,6 +82,9 @@ static void setup(void)
Quoted 5 lines

testcases/kernel/sched/cfs-scheduler/starvation.c static void setup(void) · line 86

Quoted 4 lines
testcases/kernel/sched/cfs-scheduler/starvation.c +2 -0
      CPU_ZERO(&mask);
 
+     if (tst_check_preempt_rt())
+             tst_brk(TCONF, "This test is not designed for the RT kernel");

nit: I would move it above CPU_ZERO().

Ok, I'll fix it in the v2

Quoted 4 lines

NOTE: we should also move tst_has_slow_kconfig() check to be at the top of setup(). But that's unrelated. Also at least on Tumbleweed and SLES which get detected as slow due CONFIG_LATENCYTOP test was worked before.

Want me to address this issue?

Quoted 4 lines

Kind regards,
Petr

Cheers
Alessandro

Signature · 6 lines
---
172


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

Hi Alessandro,

Quoted 1 line

Hello Petr,

...

Quoted 11 lines
Quoted 2 lines

LGTM. Could you please test if starvation.c worked previously? Or was it always broken?

Before submitting the patch, I tested the case in various environments. One thing that puzzled me for a while was the test's high sensitivity to latencies.
While it works correctly on bare-metal systems under the intended conditions with the CFS scheduler, running it on a real-time kernel or in a virtualized/emulated environment is likely to cause the test to fail.

Quoted 5 lines

This patch addresses the real-time kernel scenario, which is relatively easier to handle.
In a separate RFC patch I plan to send, I would like to ask the community for guidance on how to handle the virtualization/emulation environment issue.

Thanks, reply send.

FYI there is a git freeze before upcoming release, only fixes are merged.
https://lore.kernel.org/ltp/[email protected]/T/#t

But fixes like this should go in (I'll leave the decision to Cyril).

Quoted 17 lines
Quoted 16 lines
Quoted 14 lines
lib/tst_kernel.c +9 -0
+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 +0 -0
index 901556a7b..c620c9c3e 100644
@@ -82,6 +82,9 @@ static void setup(void)
Quoted 6 lines
Quoted 5 lines

testcases/kernel/sched/cfs-scheduler/starvation.c static void setup(void) · line 86

Quoted 4 lines
testcases/kernel/sched/cfs-scheduler/starvation.c +2 -0
      CPU_ZERO(&mask);
 
+     if (tst_check_preempt_rt())
+             tst_brk(TCONF, "This test is not designed for the RT kernel");

nit: I would move it above CPU_ZERO().

Ok, I'll fix it in the v2

Thanks!

Quoted 5 lines
Quoted 3 lines

NOTE: we should also move tst_has_slow_kconfig() check to be at the top of setup(). But that's unrelated. Also at least on Tumbleweed and SLES which get detected as slow due CONFIG_LATENCYTOP test was worked before.

Want me to address this issue?

Already done:
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/

Kind regards,
Petr

Quoted 6 lines
Quoted 2 lines

Kind regards,
Petr

Cheers
Alessandro

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp