[LTP] [PATCH 10/16] controllers: Update memcg_control_test to newer test lib and cgroup lib
Li Wang
liwang@redhat.com
Mon Jan 24 10:43:44 CET 2022
Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com> wrote:
> +test1()
> {
> - TST_COUNT=1
> - tst_resm TINFO "Test #1: Checking if the memory usage limit imposed by the topmost group is enforced"
> + cd $TST_TMPDIR
> +
> + tst_res TINFO "Test #1: Checking if the memory usage limit imposed by the topmost group is enforced"
>
> - echo "$ACTIVE_MEM_LIMIT" > $TST_PATH/mnt/$TST_NUM/memory.limit_in_bytes
> - echo "$TOT_MEM_LIMIT" > $TST_PATH/mnt/$TST_NUM/memory.memsw.limit_in_bytes
> + ROD echo "$ACTIVE_MEM_LIMIT" > "$test_dir/$memory_limit"
> + ROD echo "$TOT_MEM_LIMIT" > "$test_dir/$memsw_memory_limit"
...
> }
> +setup()
> {
> - RES=$1
> - INFO=$2
> -
> - if [ $RES -eq $PASS ]; then
> - tst_resm TPASS "$INFO"
> + cgroup_require "memory"
> + cgroup_v=$(cgroup_get_version "memory")
> + test_dir=$(cgroup_get_test_path "memory")
> + task_list=$(cgroup_get_task_list "memory")
> +
> + if [ "$cgroup_v" = "V2" ]; then
> + memory_limit="memory.max"
> + memsw_memory_limit="memory.swap.max"
As we already built the controller files mapping from V2 to V1
in C library and you actually add many new (in patch 5/16).
I'm thinking maybe we could make use of it in tst_cgctl.c to
avoid handling these (in shell) separately.
Something like:
# ./tst_cgctl set "$pid" "cgroup.procs" "$target_pid"
# ./tst_cgctl set "$pid" "memory.max" "$ACTIVE_MEM_LIMIT"
Otherwise, it seems to make no sense to add so many new
files mapping (like that patch 5/16) at this moment.
What do you think?
> else
> - : $((FAILED_CNT += 1))
> - tst_resm TFAIL "$INFO"
> + memory_limit="memory.limit_in_bytes"
> + memsw_memory_limit="memory.memsw.limit_in_bytes"
> fi
> -}
--
Regards,
Li Wang
More information about the ltp
mailing list