• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2009 FUJITSU LIMITED
4# Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
5# Copyright (c) 2018 Xiao Yang <yangx.jy@cn.fujitsu.com>
6# Copyright (c) 2021 Joerg Vehlow <joerg.vehlow@aox-tech.de>
7#
8# Author: Li Zefan <lizf@cn.fujitsu.com>
9# Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>
10# Added memcg enable/disable functinality: Rishikesh K Rajak <risrajak@linux.vnet.ibm.com
11
12MEMCG_TESTFUNC=test
13TST_CNT=3
14
15. memcg_lib.sh
16
17# Test the memory charge won't move to subgroup
18# $1 - memory.limit_in_bytes in parent group
19# $2 - memory.limit_in_bytes in sub group
20test_subgroup()
21{
22	mkdir subgroup
23	echo $1 > memory.limit_in_bytes
24	echo $2 > subgroup/memory.limit_in_bytes
25
26	start_memcg_process --mmap-anon -s $PAGESIZES
27
28	warmup
29	if [ $? -ne 0 ]; then
30		return
31	fi
32
33	echo $MEMCG_PROCESS_PID > tasks
34	signal_memcg_process $PAGESIZES
35	check_mem_stat "rss" $PAGESIZES
36
37	cd subgroup
38	echo $MEMCG_PROCESS_PID > tasks
39	check_mem_stat "rss" 0
40
41	# cleanup
42	cd ..
43	stop_memcg_process
44	rmdir subgroup
45}
46
47test1()
48{
49	tst_res TINFO "Test that group and subgroup have no relationship"
50	test_subgroup $PAGESIZES $((2 * PAGESIZES))
51}
52
53test2()
54{
55	test_subgroup $PAGESIZES $PAGESIZES
56}
57
58test3()
59{
60	test_subgroup $PAGESIZES 0
61}
62
63tst_run
64