controllers/memcg_lib.sh: reset root cgroup's memory.use_hierarchy to 0
PATCH 1/1 controllers/memcg_lib.sh: reset root cgroup's memory.use_hierarchy to 0
For some linux distribution, such as RHEL7U0Beta, memory.use_hierarchy is 1 by default, which will caused some tests failed, such as memcg_stat_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 reset the root cgroup's memory.use_hierarchy to 0 before the test.
--- .../controllers/memcg/functional/memcg_lib.sh | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+)
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +23 -0
@@ -38,6 +38,7 @@ HUGEPAGESIZE=`grep Hugepagesize /proc/meminfo | awk '{ print $2 }'` HUGEPAGESIZE=$(( $HUGEPAGESIZE * 1024 )) PASS=0 FAIL=1 +orig_memory_use_hierarchy="none" cur_id=0 failed=0
@@ -396,6 +397,15 @@ test_move_charge() cleanup() { + if [ "$orig_memory_use_hierarchy" != "none" ];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 + fi + orig_memory_use_hierarchy="none" killall -9 memcg_process 2>/dev/null if [ -e /dev/memcg ]; then umount /dev/memcg 2>/dev/null
@@ -409,4 +419,17 @@ do_mount() mkdir /dev/memcg 2> /dev/null mount -t cgroup -omemory memcg /dev/memcg + + # For some linux distribution, such as RHEL7U0Beta, + # memory.use_hierarchy is 1 by default, which will caused some tests + # failed, such as memcg_stat_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 reset the root cgroup's memory.use_hierarchy to 0 + # before the test. + orig_memory_use_hierarchy=$(cat /dev/memcg/memory.use_hierarchy) + echo 0 > /dev/memcg/memory.use_hierarchy + if [ $? -ne 0 ];then + tst_resm TINFO "set /dev/memcg/memory.use_hierarchy to 0 failed" + fi }
Signature · 13 lines
1.8.2.1 ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH v2 1/1 controllers/memcg_lib.sh: reset root cgroup's memory.use_hierarchy to 0
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.
--- .../kernel/controllers/memcg/functional/memcg_lib.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +16 -0
@@ -38,6 +38,7 @@ HUGEPAGESIZE=`grep Hugepagesize /proc/meminfo | awk '{ print $2 }'` HUGEPAGESIZE=$(( $HUGEPAGESIZE * 1024 )) PASS=0 FAIL=1 +orig_memory_use_hierarchy="none" cur_id=0 failed=0
@@ -396,6 +397,15 @@ test_move_charge() cleanup() { + if [ "$orig_memory_use_hierarchy" != "none" ];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 + fi + orig_memory_use_hierarchy="none" killall -9 memcg_process 2>/dev/null if [ -e /dev/memcg ]; then umount /dev/memcg 2>/dev/null
@@ -409,4 +419,10 @@ do_mount() mkdir /dev/memcg 2> /dev/null mount -t cgroup -omemory memcg /dev/memcg + + orig_memory_use_hierarchy=$(cat /dev/memcg/memory.use_hierarchy) + echo 0 > /dev/memcg/memory.use_hierarchy + if [ $? -ne 0 ];then + tst_resm TINFO "set /dev/memcg/memory.use_hierarchy to 0 failed" + fi }
Signature · 13 lines
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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 13 lines
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +1
-0@@ -38,6 +38,7 @@ HUGEPAGESIZE=`grep Hugepagesize /proc/meminfo | awk '{ print $2 }'` HUGEPAGESIZE=$(( $HUGEPAGESIZE * 1024 )) PASS=0 FAIL=1 +orig_memory_use_hierarchy="none" cur_id=0 failed=0
testcases/kernel/controllers/memcg/functional/memcg_lib.sh test_move_charge() · line 400
Quoted 4 lines
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +1
-0@@ -396,6 +397,15 @@ test_move_charge() cleanup() { + if [ "$orig_memory_use_hierarchy" != "none" ];then
It would be a bit better to check for non empty string here, because if the:
orig_memory_use_hierarchy=$(cat /dev/memcg/memory.use_hierarchy)
has failed for any reason the value would be set to empty string and we will write only newline into the /dev/memcg/... file which will likely result in error.
Quoted 13 lines
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +8
-0+ 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 + fi + orig_memory_use_hierarchy="none" killall -9 memcg_process 2>/dev/null if [ -e /dev/memcg ]; then umount /dev/memcg 2>/dev/null@@ -409,4 +419,17 @@ do_mount()
testcases/kernel/controllers/memcg/functional/memcg_lib.sh do_mount() · line 429
Quoted 10 lines
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +8
-0mkdir /dev/memcg 2> /dev/null mount -t cgroup -omemory memcg /dev/memcg + + # For some linux distribution, such as RHEL7U0Beta, + # memory.use_hierarchy is 1 by default, which will caused some tests + # failed, such as memcg_stat_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 reset the root cgroup's memory.use_hierarchy to 0 + # before the test.
I would keep this a bit shorter (it's comment in the code, not poetry :)
Such as:
# The default value for memory.use_hierarchy is 0 and some of tests # (memcg_stat_test.sh) expects it so while there are distributions # (RHEL7U0Beta for example) that sets it to 1.
The fact that we set it to 0 before the test is obvious from the code.
testcases/kernel/controllers/memcg/functional/memcg_lib.sh do_mount() · line 431
Quoted 2 lines
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +2
-0+ orig_memory_use_hierarchy=$(cat /dev/memcg/memory.use_hierarchy) + echo 0 > /dev/memcg/memory.use_hierarchy
What about setting this only when the orig value is not 0?
Moreover setting the orig value to empty if it's 0 to avoid the restoration in cleanup()?
Quoted 4 lines
testcases/kernel/controllers/memcg/functional/memcg_lib.sh +3
-0+ if [ $? -ne 0 ];then + tst_resm TINFO "set /dev/memcg/memory.use_hierarchy to 0 failed" + fi }
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ 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 [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list