1#! /bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2012 FUJITSU LIMITED 4# Copyright (c) 2014-2016 Linux Test Project 5# Copyright (c) 2021 Joerg Vehlow <[email protected]> 6# 7# Author: Peng Haitao <[email protected]> 8 9MEMCG_TESTFUNC=test 10TST_CNT=3 11 12 13test1() 14{ 15 tst_res TINFO "test if one of the ancestors goes over its limit, the proces will be killed" 16 17 local limit=$(memcg_adjust_limit_for_kmem $PAGESIZE) 18 19 ROD echo 1 \> memory.use_hierarchy 20 ROD echo $limit \> memory.limit_in_bytes 21 22 ROD mkdir subgroup 23 cd subgroup 24 test_proc_kill $((limit + PAGESIZE * 3)) "--mmap-lock1" $((limit + PAGESIZE * 2)) 0 25 26 cd .. 27 rmdir subgroup 28} 29 30test2() 31{ 32 tst_res TINFO "test Enabling will fail if the cgroup already has other cgroups" 33 34 memcg_require_hierarchy_disabled 35 36 ROD mkdir subgroup 37 EXPECT_FAIL echo 1 \> memory.use_hierarchy 38 39 rmdir subgroup 40} 41 42test3() 43{ 44 tst_res TINFO "test disabling will fail if the parent cgroup has enabled hierarchy" 45 46 memcg_require_hierarchy_disabled 47 48 ROD echo 1 > memory.use_hierarchy 49 mkdir subgroup 50 EXPECT_FAIL echo 0 \> subgroup/memory.use_hierarchy 51 52 rmdir subgroup 53} 54 55. memcg_lib.sh 56tst_run 57