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# Test the memory charge won't move to subgroup 16# $1 - memory.limit_in_bytes in sub group 17test_subgroup() 18{ 19 local limit_subgroup=$1 20 21 if [ $limit_subgroup -ne 0 ]; then 22 limit_subgroup=$(memcg_adjust_limit_for_kmem $limit_subgroup) 23 fi 24 25 ROD mkdir subgroup 26 EXPECT_PASS echo $limit_subgroup \> subgroup/memory.limit_in_bytes 27 28 start_memcg_process --mmap-anon -s $MEM_TO_ALLOC 29 30 warmup 31 if [ $? -ne 0 ]; then 32 return 33 fi 34 35 echo $MEMCG_PROCESS_PID > tasks 36 signal_memcg_process $MEM_TO_ALLOC 37 check_mem_stat "rss" $MEM_TO_ALLOC 38 39 cd subgroup 40 echo $MEMCG_PROCESS_PID > tasks 41 check_mem_stat "rss" 0 42 43 # cleanup 44 cd .. 45 stop_memcg_process 46 rmdir subgroup 47} 48 49test1() 50{ 51 tst_res TINFO "Test that group and subgroup have no relationship" 52 test_subgroup $((2 * MEM_TO_ALLOC)) 53} 54 55test2() 56{ 57 test_subgroup $MEM_TO_ALLOC 58} 59 60test3() 61{ 62 test_subgroup 0 63} 64 65. memcg_lib.sh 66 67# Allocate memory bigger than per-cpu kernel memory 68MEM_TO_ALLOC=$((PAGESIZES * 2)) 69 70tst_run 71