Skip to content

Commit

Permalink
cfs-scheduler/starvation.c: Skip test on realtime kernels
Browse files Browse the repository at this point in the history
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.

Link: https://lore.kernel.org/ltp/[email protected]/
Reviewed-by: Petr Vorel <[email protected]>
Reviewed-by: Li Wang <[email protected]>
Reviewed-by: Cyril Hrubis <[email protected]>
Signed-off-by: Alessandro Carminati <[email protected]>
  • Loading branch information
alessandrocarminati authored and pevik committed Jan 27, 2025
1 parent 41d8524 commit 7287595
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/tst_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
10 changes: 10 additions & 0 deletions lib/tst_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions testcases/kernel/sched/cfs-scheduler/starvation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 7287595

Please sign in to comment.