public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v3] controllers/memcg_lib.sh: reset root cgroup's memory.use_hierarchy to 0
@ 2014-02-14  8:25 Xiaoguang Wang
  2014-02-25 16:25 ` chrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaoguang Wang @ 2014-02-14  8:25 UTC (permalink / raw)
  To: ltp-list

In some linux distribution, such as RHEL7U0Beta, memory.use_hierarchy is
set to 1 by systemd default, which will cause some tests failed, such as
memcg_stat_test.sh, memcg_use_hierarchy_test.sh.

According to kernel Documentation/cgroups/memory.txt's description,
the default value should be 0, and some ltp tests are written based on
this assumption, so here we set the root cgroup's memory.use_hierarchy
to 0 before running the test and restore it when finishing the test.

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 .../controllers/memcg/functional/memcg_lib.sh      | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index 16e30ec..ffbe006 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -38,6 +38,7 @@ HUGEPAGESIZE=`grep Hugepagesize /proc/meminfo | awk '{ print $2 }'`
 HUGEPAGESIZE=$(( $HUGEPAGESIZE * 1024 ))
 PASS=0
 FAIL=1
+orig_memory_use_hierarchy=""
 
 cur_id=0
 failed=0
@@ -396,6 +397,16 @@ test_move_charge()
 
 cleanup()
 {
+	if [ -n "$orig_memory_use_hierarchy" ];then
+		echo $orig_memory_use_hierarchy > \
+		     /dev/memcg/memory.use_hierarchy
+		if [ $? -ne 0 ];then
+			tst_resm TINFO "restore "\
+				 "/dev/memcg/memory.use_hierarchy failed"
+		fi
+		orig_memory_use_hierarchy=""
+	fi
+
 	killall -9 memcg_process 2>/dev/null
 	if [ -e /dev/memcg ]; then
 		umount /dev/memcg 2>/dev/null
@@ -409,4 +420,21 @@ do_mount()
 
 	mkdir /dev/memcg 2> /dev/null
 	mount -t cgroup -omemory memcg /dev/memcg
+
+	# The default value for memory.use_hierarchy is 0 and some of tests
+	# (memcg_stat_test.sh and memcg_use_hierarchy_test.sh) expect it so
+	# while there are distributions (RHEL7U0Beta for example) that sets
+	# it to 1.
+	orig_memory_use_hierarchy=$(cat /dev/memcg/memory.use_hierarchy)
+	if [ -z "orig_memory_use_hierarchy" ];then
+		tst_resm TINFO "cat /dev/memcg/memory.use_hierarchy failed"
+	elif [ "$orig_memory_use_hierarchy" = "0" ];then
+		orig_memory_use_hierarchy=""
+	else
+		echo 0 > /dev/memcg/memory.use_hierarchy
+		if [ $? -ne 0 ];then
+			tst_resm TINFO "set /dev/memcg/memory.use_hierarchy" \
+				"to 0 failed"
+		fi
+	fi
 }
-- 
1.8.2.1


------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-25 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-14  8:25 [LTP] [PATCH v3] controllers/memcg_lib.sh: reset root cgroup's memory.use_hierarchy to 0 Xiaoguang Wang
2014-02-25 16:25 ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox