From 6d3658acf524b83e072d752f5cdc94dccf225a52 Mon Sep 17 00:00:00 2001 From: Juxin Gao Date: Wed, 17 Jun 2026 11:53:22 +0800 Subject: [PATCH 1/2] sched/starvation: honor explicit runtime option The -t option is documented as the maximum timeout for the test. However, the parsed value is overwritten by the automatic calibration step. As a result starvation -t 10 and starvation -t 240 both use the calibrated runtime instead of the requested value. Only run the calibration when -t was not provided, and keep the user supplied value otherwise. Signed-off-by: Juxin Gao --- testcases/kernel/sched/cfs-scheduler/starvation.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/testcases/kernel/sched/cfs-scheduler/starvation.c b/testcases/kernel/sched/cfs-scheduler/starvation.c index 045254ba417..92d5976b2b2 100644 --- a/testcases/kernel/sched/cfs-scheduler/starvation.c +++ b/testcases/kernel/sched/cfs-scheduler/starvation.c @@ -105,10 +105,12 @@ static void setup(void) if (tst_parse_long(str_loop, &loop, 1, LONG_MAX)) tst_brk(TBROK, "Invalid number of loop number '%s'", str_loop); - if (tst_parse_int(str_timeout, &timeout, 1, INT_MAX)) - tst_brk(TBROK, "Invalid number of timeout '%s'", str_timeout); - else + if (str_timeout) { + if (tst_parse_int(str_timeout, &timeout, 1, INT_MAX)) + tst_brk(TBROK, "Invalid number of timeout '%s'", str_timeout); + } else { timeout = callibrate() / 1000; + } if (tst_has_slow_kconfig()) tst_brk(TCONF, "Skip test due to slow kernel configuration"); From e823c5acc15e2b6c4e6e3641796b39194b062ec8 Mon Sep 17 00:00:00 2001 From: Juxin Gao Date: Wed, 17 Jun 2026 11:53:39 +0800 Subject: [PATCH 2/2] sched/starvation: skip voluntary preemption kernels The starvation reproducer pins the parent and child to a single CPU. The child then busy-loops in kill(SIGUSR1) while the parent waits in sleep() and depends on signal wakeups to make progress. On CONFIG_PREEMPT_VOLUNTARY=y kernels this workload may be limited by the scheduler tick rather than by the cost of signal delivery. On a LoongArch 3C6000 system with HZ=250, starvation -l 10000 took about 40 seconds. perf reported about 20003 context switches. trace-cmd showed roughly 4ms between waking the parent and switching from the child to the parent. A minimal reproducer had the same behavior: child busy kill: 10000 loops in 39.999s, about 4000us/loop child kill + sched_yield: 10000 loops in 0.056s, about 5.6us/loop The test therefore does not produce a reliable scheduler starvation verdict on voluntary preemption kernels. Skip it in the same spirit as the existing realtime and slow-kernel skips. Signed-off-by: Juxin Gao --- testcases/kernel/sched/cfs-scheduler/starvation.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/testcases/kernel/sched/cfs-scheduler/starvation.c b/testcases/kernel/sched/cfs-scheduler/starvation.c index 92d5976b2b2..a00b344805b 100644 --- a/testcases/kernel/sched/cfs-scheduler/starvation.c +++ b/testcases/kernel/sched/cfs-scheduler/starvation.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "tst_test.h" #include "tst_kconfig.h" @@ -30,6 +31,15 @@ static int timeout; #define CALLIBRATE_LOOPS 120000000 +static int has_preempt_voluntary(void) +{ + struct tst_kconfig_var kconfig = TST_KCONFIG_INIT("CONFIG_PREEMPT_VOLUNTARY"); + + tst_kconfig_read(&kconfig, 1); + + return kconfig.choice == 'y'; +} + static int callibrate(void) { int i; @@ -81,6 +91,9 @@ static void setup(void) if (tst_check_preempt_rt()) tst_brk(TCONF, "This test is not designed for the RT kernel"); + if (has_preempt_voluntary()) + tst_brk(TCONF, "This test is not reliable on voluntary preemption kernels"); + CPU_ZERO(&mask); /* Restrict test to a single cpu */