[LTP] Question on .needs_cgroup_ctrls for cgroupv2

Cyril Hrubis chrubis@suse.cz
Mon Feb 27 15:58:41 CET 2023


Hi!
> How to setup correct test case for cgroupv2 check? I try to put following parameter but failed.
> 
> struct tst_test test = {
> 	...
>         .needs_cgroup_ctrls = (const char *const []){ "unified", NULL },
>         .needs_cgroup_ver = TST_CG_V2,
> };
> 
> 
> After some investigation i found cgroup_find_ctrl which called by tst_cg_require seems not implement 
> how to check cgroupv2, the controllers has no "unified" memeber, should we add CGROUP_CTRL_MEMBER("unified", xxx)
> into controllers?  Correct me if any misunderstanding.
> 
> 
> void tst_cg_require(const char *const ctrl_name,
>                         const struct tst_cg_opts *options)
> {
>         struct cgroup_ctrl *const ctrl = cgroup_find_ctrl(ctrl_name);

I think that you are misunderstanding something, controllers that are
checked by the .needs_cgroup_ctrls and tst_cg_require() are cgroup
controllers such as memory or cpu controller.

And unified can be the hierarchy, that means that all controllers are in
a single mount point which is how controllers are presented in the
cgroup V2.

You can have a mix of V1 and V2 controllers on a system and LTP library
abstracts away all the details so that you can focus on the test logic
rather than on how things are set up on the system. You have to start by
specifying which controllers is the test going to use, that's the
.needs_cgroup_ctrls array and if the test is V2 only you pass the
TST_CG_V2 in the flags.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list