| Message ID | 20250121111909.66487-1-acarmina@redhat.com |
|---|---|
| State | Changes Requested |
| Headers | show |
| Series | [v2] cfs-scheduler/starvation.c: Skip test on realtime kernels | expand |
On Tue, Jan 21, 2025 at 7:22 PM Alessandro Carminati <acarmina@redhat.com> wrote: > 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. > > Signed-off-by: Alessandro Carminati <acarmina@redhat.com> > Reviewed-by: Li Wang <liwang@redhat.com> > --- > > V1: > https://lore.kernel.org/ltp/20250120085017.63442-1-acarmina@redhat.com/ > > include/tst_kernel.h | 9 +++++++++ > lib/tst_kernel.c | 10 ++++++++++ > testcases/kernel/sched/cfs-scheduler/starvation.c | 3 +++ > 3 files changed, 22 insertions(+) > > diff --git a/include/tst_kernel.h b/include/tst_kernel.h > index 5f49952b7..63ecb19a4 100644 > --- a/include/tst_kernel.h > +++ b/include/tst_kernel.h > @@ -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__ */ > diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c > index 8dabfeba2..7084289c3 100644 > --- a/lib/tst_kernel.c > +++ b/lib/tst_kernel.c > @@ -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; > +} > diff --git a/testcases/kernel/sched/cfs-scheduler/starvation.c > b/testcases/kernel/sched/cfs-scheduler/starvation.c > index 901556a7b..27bf77f39 100644 > --- a/testcases/kernel/sched/cfs-scheduler/starvation.c > +++ b/testcases/kernel/sched/cfs-scheduler/starvation.c > @@ -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 > >
Hi Alessandro,
LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
Hi! > +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: Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Hello Cyril, Thanks for the feedback. On Fri, Jan 24, 2025 at 12:58 PM Cyril Hrubis <chrubis@suse.cz> wrote: > > Hi! > > +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. > > Otherwise: > > Reviewed-by: Cyril Hrubis <chrubis@suse.cz> > > -- > Cyril Hrubis > chrubis@suse.cz >
diff --git a/include/tst_kernel.h b/include/tst_kernel.h index 5f49952b7..63ecb19a4 100644 --- a/include/tst_kernel.h +++ b/include/tst_kernel.h @@ -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__ */ diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c index 8dabfeba2..7084289c3 100644 --- a/lib/tst_kernel.c +++ b/lib/tst_kernel.c @@ -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; +} diff --git a/testcases/kernel/sched/cfs-scheduler/starvation.c b/testcases/kernel/sched/cfs-scheduler/starvation.c index 901556a7b..27bf77f39 100644 --- a/testcases/kernel/sched/cfs-scheduler/starvation.c +++ b/testcases/kernel/sched/cfs-scheduler/starvation.c @@ -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 */
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. Signed-off-by: Alessandro Carminati <acarmina@redhat.com> --- V1: https://lore.kernel.org/ltp/20250120085017.63442-1-acarmina@redhat.com/ include/tst_kernel.h | 9 +++++++++ lib/tst_kernel.c | 10 ++++++++++ testcases/kernel/sched/cfs-scheduler/starvation.c | 3 +++ 3 files changed, 22 insertions(+)