controllers.memcg_regression: add trap to clean up directories
PATCH 1/1 controllers.memcg_regression: add trap to clean up directories
The memcg_regression test creates a memcg/ directory that can be left behind if the test exits unexpectedly. Use a trap to clean up the directories on exit.
--- .../memcg/regression/memcg_regression_test.sh | 20 +++++++++++-------- .../memcg/regression/memcg_test_4.sh | 11 ++++++---- 2 files changed, 19 insertions(+), 12 deletions(-)
testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh +12 -8
@@ -54,6 +54,15 @@ nr_null=0 nr_warning=0 nr_lockdep=0 +clean_up() +{ + # remove the cgroup + rmdir memcg/0 2> /dev/null + # unmount cgroup if still mounted + umount memcg/ + rmdir memcg/ +} + # check_kernel_bug - check if some kind of kernel bug happened check_kernel_bug() {
@@ -102,12 +111,12 @@ check_kernel_bug() #--------------------------------------------------------------------------- test_1() { - mkdir memcg/0/ + mkdir memcg/0 echo 0 > memcg/0/memory.limit_in_bytes ./memcg_test_1 - rmdir memcg/0/ + rmdir memcg/0 check_kernel_bug if [ $? -eq 1 ]; then
@@ -211,14 +220,12 @@ test_4() killall -9 memcg_test_4 2> /dev/null killall -9 memcg_test_4.sh 2> /dev/null - # if test_4.sh gets killed, it won't clean cgroup it created - rmdir memcg/0 2> /dev/null - swapon -a } # main failed=0 +trap clean_up EXIT mkdir memcg/ for cur in $(seq 1 $TST_TOTAL); do
@@ -236,7 +243,4 @@ for cur in $(seq 1 $TST_TOTAL); do umount memcg/ done -rmdir memcg/ - exit $failed -
testcases/kernel/controllers/memcg/regression/memcg_test_4.sh +7 -4
@@ -22,6 +22,13 @@ ## ## ################################################################################ +clean_up() +{ + # remove the cgroup when exiting + rmdir memcg/0 +} + +trap clean_up EXIT # attach current task to memcg/0/ mkdir memcg/0 echo $$ > memcg/0/tasks
@@ -42,7 +49,3 @@ swapoff -a sleep 1 echo $pid > memcg/tasks 2> /dev/null echo $$ > memcg/tasks 2> /dev/null - -# now remove the cgroup -rmdir memcg/0 -
Signature · 5 lines
2.37.0.rc0.161.g10f37bed90-goog -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Edward,
Thanks for your patch and I believe it makes sense.
But the whole memcg test has been re-written by Luke's patchset which is still reviewing.
https://lists.linux.it/pipermail/ltp/2022-April/028777.html
@Luke Nowakowski-Krijger <[email protected]> Luke, I guess V3 should be the final version (if you take the time to do rebase/modification) and we'll happy to help merge those patches next:).
Quoted 111 lines · Edward Liaw via ltp
The
memcg_regressiontest creates a memcg/ directory that can be left behind if the test exits unexpectedly. Use a trap to clean up the directories on exit.Signed-off-by Edward Liaw <[email protected]>--- .../memcg/regression/memcg_regression_test.sh | 20 +++++++++++-------- .../memcg/regression/memcg_test_4.sh | 11 ++++++---- 2 files changed, 19 insertions(+), 12 deletions(-)diff --git
a/testcases/kernel/controllers/memcg/regression/memcg_regression_test.shb/testcases/kernel/controllers/memcg/regression/memcg_regression_test.shindexc91a4069e..2467ae0e6100755
---a/testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh
+++b/testcases/kernel/controllers/memcg/regression/memcg_regression_test.shtestcases/kernel/controllers/memcg/regression/memcg_regression_test.sh +11
-2@@ -54,6 +54,15 @@ nr_null=0 nr_warning=0 nr_lockdep=0 +clean_up() +{ + # remove the cgroup + rmdir memcg/0 2> /dev/null + # unmount cgroup if still mounted + umount memcg/ + rmdir memcg/ +} + # check_kernel_bug - check if some kind of kernel bug happened check_kernel_bug() {@@ -102,12 +111,12 @@ check_kernel_bug() #--------------------------------------------------------------------------- test_1() { - mkdir memcg/0/ + mkdir memcg/0 echo 0 > memcg/0/memory.limit_in_bytes ./memcg_test_1 - rmdir memcg/0/ + rmdir memcg/0 check_kernel_bugif [ $? -eq 1 ]; thentestcases/kernel/controllers/memcg/regression/memcg_regression_test.sh +1
-6@@ -211,14 +220,12 @@ test_4() killall -9 memcg_test_4 2> /dev/null killall -9 memcg_test_4.sh 2> /dev/null - # if test_4.sh gets killed, it won't clean cgroup it created - rmdir memcg/0 2> /dev/null - swapon -a } # main failed=0 +trap clean_up EXIT mkdir memcg/ for cur in $(seq 1 $TST_TOTAL); do@@ -236,7 +243,4 @@ for cur in $(seq 1 $TST_TOTAL); do umount memcg/ done -rmdir memcg/ - exit $failed -testcases/kernel/controllers/memcg/regression/memcg_test_4.sh +7
-0@@ -22,6 +22,13 @@ ## ## ################################################################################ +clean_up() +{ + # remove the cgroup when exiting + rmdir memcg/0 +} + +trap clean_up EXIT # attach current task to memcg/0/mkdir memcg/0
echo $$ > memcg/0/taskstestcases/kernel/controllers/memcg/regression/memcg_test_4.sh +0
-5@@ -42,7 +49,3 @@ swapoff -a sleep 1 echo $pid > memcg/tasks 2> /dev/null echo $$ > memcg/tasks 2> /dev/null - -# now remove the cgroup -rmdir memcg/0 - --2.37.0.rc0.161.g10f37bed90-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Hey,
Quoted 12 lines · Li Wang
Hi Edward,
Thanks for your patch and I believe it makes sense.
But the whole memcg test has been re-written by Luke's patchset which is still reviewing.
https://lists.linux.it/pipermail/ltp/2022-April/028777.html@Luke Nowakowski-Krijger <[email protected]> Luke, I guess V3 should be the final version (if you take the time to do rebase/modification) and we'll happy to help merge those patches next:).
Let me finally get around to putting up the (hopefully) final revision so that people don't start doing things I already did :)
Quoted 113 lines
Quoted 108 lines · Edward Liaw via ltp
The
memcg_regressiontest creates a memcg/ directory that can be left behind if the test exits unexpectedly. Use a trap to clean up the directories on exit.Signed-off-by Edward Liaw <[email protected]>--- .../memcg/regression/memcg_regression_test.sh | 20 +++++++++++-------- .../memcg/regression/memcg_test_4.sh | 11 ++++++---- 2 files changed, 19 insertions(+), 12 deletions(-)diff --git
a/testcases/kernel/controllers/memcg/regression/memcg_regression_test.shb/testcases/kernel/controllers/memcg/regression/memcg_regression_test.shindexc91a4069e..2467ae0e6100755
---a/testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh
+++b/testcases/kernel/controllers/memcg/regression/memcg_regression_test.shtestcases/kernel/controllers/memcg/regression/memcg_regression_test.sh +11
-2@@ -54,6 +54,15 @@ nr_null=0 nr_warning=0 nr_lockdep=0 +clean_up() +{ + # remove the cgroup + rmdir memcg/0 2> /dev/null + # unmount cgroup if still mounted + umount memcg/ + rmdir memcg/ +} + # check_kernel_bug - check if some kind of kernel bug happened check_kernel_bug() {@@ -102,12 +111,12 @@ check_kernel_bug() #--------------------------------------------------------------------------- test_1() { - mkdir memcg/0/ + mkdir memcg/0 echo 0 > memcg/0/memory.limit_in_bytes ./memcg_test_1 - rmdir memcg/0/ + rmdir memcg/0 check_kernel_bugif [ $? -eq 1 ]; thentestcases/kernel/controllers/memcg/regression/memcg_regression_test.sh +1
-6@@ -211,14 +220,12 @@ test_4() killall -9 memcg_test_4 2> /dev/null killall -9 memcg_test_4.sh 2> /dev/null - # if test_4.sh gets killed, it won't clean cgroup it created - rmdir memcg/0 2> /dev/null - swapon -a } # main failed=0 +trap clean_up EXIT mkdir memcg/ for cur in $(seq 1 $TST_TOTAL); do@@ -236,7 +243,4 @@ for cur in $(seq 1 $TST_TOTAL); do umount memcg/ done -rmdir memcg/ - exit $failed -diff --git
a/testcases/kernel/controllers/memcg/regression/memcg_test_4.shb/testcases/kernel/controllers/memcg/regression/memcg_test_4.shindex 620031366..d002601f1 100755testcases/kernel/controllers/memcg/regression/memcg_test_4.sh +7
-0@@ -22,6 +22,13 @@ ## ## ################################################################################ +clean_up() +{ + # remove the cgroup when exiting + rmdir memcg/0 +} + +trap clean_up EXIT # attach current task to memcg/0/mkdir memcg/0
echo $$ > memcg/0/taskstestcases/kernel/controllers/memcg/regression/memcg_test_4.sh +0
-5@@ -42,7 +49,3 @@ swapoff -a sleep 1 echo $pid > memcg/tasks 2> /dev/null echo $$ > memcg/tasks 2> /dev/null - -# now remove the cgroup -rmdir memcg/0 - --2.37.0.rc0.161.g10f37bed90-goog
Quoted 9 lines
Quoted 4 lines
--
Mailing list info: https://lists.linux.it/listinfo/ltp--
Regards,
Li Wang
- Luke
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
Quoted 11 lines
Hey,
Quoted 6 lines · Li Wang
Hi Edward,
Thanks for your patch and I believe it makes sense.
But the whole memcg test has been re-written by Luke's patchset which is still reviewing.
https://lists.linux.it/pipermail/ltp/2022-April/028777.html
Quoted 7 lines
Quoted 3 lines
@Luke Nowakowski-Krijger <[email protected]> Luke, I guess V3 should be the final version (if you take the time to do rebase/modification) and we'll happy to help merge those patches next:).
Let me finally get around to putting up the (hopefully) final revision so that people don't start doing things I already did :)
Thanks Luke!
Edward, FYI Luke fixed this in his big cleanup
https://patchwork.ozlabs.org/project/ltp/list/?series=311414&state=*
Therefore closing this in patchwork as "Not Applicable".
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp