Skip to contentSkip to conversation

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

PATCH In review Alessandro Carminati 2 participants 5 messages Jan 27, 2025 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v3 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..9ab02e5d3 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
#1 lore raw
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.

Thanks a lot for fixing -1 in v3. I was thinking to merge v2 and fix -1 manually, but I'm really not sure if the test is meaningless for realtime. Was the test really written for CFS? It would be nice to get ack from any realtime developer.

BTW test is working well on x86_64 SLES realtime kernel on VM, i.e. both you want to skip (RT) or warn about unreliable results (VM). That of course does not mean it's relevant for RT kernel.

Kind regards,
Petr

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

Hi Petr,

Thanks for the feedback.

Quoted 9 lines · Petr Vorel
Quoted 8 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 8 lines

Thanks a lot for fixing -1 in v3. I was thinking to merge v2 and fix -1 manually, but I'm really not sure if the test is meaningless for realtime. Was the test really written for CFS? It would be nice to get ack from any realtime developer.

BTW test is working well on x86_64 SLES realtime kernel on VM, i.e. both you want to skip (RT) or warn about unreliable results (VM). That of course does not mean it's relevant for RT kernel.

Here's what I observed:
* In our CI pipeline, the test consistently fails on our RT kernel running on AARCH64 boards.
* Upon investigating and reading through the code, I noticed that the test seems to rely on an equal number of times the child and parent tasks get scheduled. This behavior aligns with how CFS works... less with RT.
* That said, there are scenarios where CFS and RT might make similar scheduling decisions, particularly in RT when all tasks share the same priority.
* Finally, as a hint, I noticed that the test is currently placed in the cfs-scheduler directory. I interpret this as a strong suggestion from the author that the test was intended for the CFS scheduler.

Quoted 4 lines

Kind regards,
Petr

Signature · 8 lines
---
Thanks
Alessandro
172


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

Hi Petr,

Thanks for the feedback.

Quoted 8 lines · Petr Vorel
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 8 lines

Thanks a lot for fixing -1 in v3. I was thinking to merge v2 and fix -1 manually, but I'm really not sure if the test is meaningless for realtime. Was the test really written for CFS? It would be nice to get ack from any realtime developer.

BTW test is working well on x86_64 SLES realtime kernel on VM, i.e. both you want to skip (RT) or warn about unreliable results (VM). That of course does not mean it's relevant for RT kernel.

Quoted 12 lines

Here's what I observed:
* In our CI pipeline, the test consistently fails on our RT kernel running on AARCH64 boards.
* Upon investigating and reading through the code, I noticed that the test seems to rely on an equal number of times the child and parent tasks get scheduled. This behavior aligns with how CFS works... less with RT.
* That said, there are scenarios where CFS and RT might make similar scheduling decisions, particularly in RT when all tasks share the same priority.
* Finally, as a hint, I noticed that the test is currently placed in the cfs-scheduler directory. I interpret this as a strong suggestion from the author that the test was intended for the CFS scheduler.

Oops, I completely missed the directory. And all the above sounds right. Also reproducer was posted for EEVDF, which is CFS replacement.

OTOH cfs_bandwidth01.c, which requires CONFIG_CFS_BANDWIDTH works on RT kernel well, also very old hackbench.c (which needs to be rewritten).

Anyway I wanted to have ack of somebody who actually understands the kernel code. I got a confirmation from Mike Galbraith that "the test is about fair class vs fair class wakeup latency, has little relevance to RT. It does bang on locks in the wakeup path, but no more than about a zillion other things." therefore I'm going to merge.

Kind regards,
Petr

Quoted 2 lines
Quoted 2 lines

Kind regards,
Petr

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