[LTP] [PATCH v1] sched_rr_get_interval01.c: Put test process into absolute root cgroup (0::/)

Petr Vorel pvorel@suse.cz
Thu Jun 5 11:40:19 CEST 2025


Hi Wei, all,

> When the CONFIG_RT_GROUP_SCHED=y config is set, test cases like sched_rr_get_interval01
> will failed since limitation of RT processes with cgroup v2 cpu controller.
> The limitation is RT processes have to be in the root cgroup before enabling cpu controller.
> By default the shell will not running in root cgroup "0::/" since systemd will put shell
> into 0::/user.slice/user-xx.slice/session-xx.scope, so ltp case run within shell will failed.
> We can use this patch to workaround above limitation. If we agree on this patch, i will
> continue do same patch to following cases:
> sched_rr_get_interval02
> sched_rr_get_interval03
> sched_setparam02
> sched_getscheduler01

Acked-by: Petr Vorel <pvorel@suse.cz>

LGTM.

@Michal @Li WDYT?

Kind regards,
Petr

> Fixes: https://github.com/linux-test-project/ltp/issues/1245
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>  .../sched_rr_get_interval/sched_rr_get_interval01.c         | 6 ++++++
>  1 file changed, 6 insertions(+)

> diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
> index b4d75bdcc..55516ec89 100644
> --- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
> +++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
> @@ -43,6 +43,12 @@ static void setup(void)

>  	tp.type = tv->ts_type;

> +	if (access("/sys/fs/cgroup/cgroup.controllers", F_OK) == 0) {
> +		int pid = getpid();
> +
> +		SAFE_FILE_PRINTF("/sys/fs/cgroup/cgroup.procs", "%d", pid);
> +	}
> +
>  	if ((sys_sched_setscheduler(0, SCHED_RR, &p)) == -1)
>  		tst_res(TFAIL | TERRNO, "sched_setscheduler() failed");


More information about the ltp mailing list