[LTP] [PATCH v1 1/4] lib: add new cgroup test API
Jan Stancek
jstancek@redhat.com
Wed May 27 09:40:51 CEST 2020
----- Original Message -----
> +
> +void tst_cgroup_mem_set_maxbytes(long memsz)
> +{
> + tst_cgroup_move_current(TST_CGROUP_MEMCG);
It seems a bit unexpected, that setting a limit also moves current
process to cgroup. If test forks two processes, it has to set maxbytes
twice, to get the desired side-effect.
> +
> + if (tst_cg_ver & TST_CGROUP_V1)
> + SAFE_FILE_PRINTF(PATH_CG1_MEM_LTP "/memory.limit_in_bytes", "%ld", memsz);
> +
> + if (tst_cg_ver & TST_CGROUP_V2)
> + SAFE_FILE_PRINTF(PATH_TMP_CG2_LTP "/memory.max", "%ld", memsz);
> +}
> +
> +void tst_cgroup_mem_set_maxswap(long memsz)
> +{
> + tst_cgroup_move_current(TST_CGROUP_MEMCG);
> +
> + if (tst_cg_ver & TST_CGROUP_V1)
> + SAFE_FILE_PRINTF(PATH_CG1_MEM_LTP "/memory.memsw.limit_in_bytes", "%ld",
> memsz);
> + if (tst_cg_ver & TST_CGROUP_V2)
> + SAFE_FILE_PRINTF(PATH_TMP_CG2_LTP "/memory.swap.max", "%ld", memsz);
> +}
> --
> 2.21.1
>
>
More information about the ltp
mailing list