• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <joerg.vehlow@aox-tech.de>
6#
7# Author: Peng Haitao <penght@cn.fujitsu.com>
8
9MEMCG_TESTFUNC=test
10TST_CNT=3
11
12. memcg_lib.sh
13
14test1()
15{
16	tst_res TINFO "test if one of the ancestors goes over its limit, the proces will be killed"
17
18	local limit=$(memcg_adjust_limit_for_kmem $PAGESIZE)
19
20	ROD echo 1 \> memory.use_hierarchy
21	ROD echo $limit \> memory.limit_in_bytes
22
23	ROD mkdir subgroup
24	cd subgroup
25	test_proc_kill $((limit + PAGESIZE * 3)) "--mmap-lock1" $((limit + PAGESIZE * 2)) 0
26
27	cd ..
28	rmdir subgroup
29}
30
31test2()
32{
33	tst_res TINFO "test Enabling will fail if the cgroup already has other cgroups"
34
35	memcg_require_hierarchy_disabled
36
37	ROD mkdir subgroup
38	EXPECT_FAIL echo 1 \> memory.use_hierarchy
39
40	rmdir subgroup
41}
42
43test3()
44{
45	tst_res TINFO "test disabling will fail if the parent cgroup has enabled hierarchy"
46
47	memcg_require_hierarchy_disabled
48
49	ROD echo 1 > memory.use_hierarchy
50	mkdir subgroup
51	EXPECT_FAIL echo 0 \> subgroup/memory.use_hierarchy
52
53	rmdir subgroup
54}
55
56tst_run
57