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