<div dir="ltr"><div>Hey,<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 5, 2022 at 11:00 PM Li Wang <<a href="mailto:liwang@redhat.com">liwang@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div style="font-size:small">Hi Edward,</div><div style="font-size:small"><br></div><div style="font-size:small">Thanks for your patch and I believe it makes sense.</div><div style="font-size:small">But the whole memcg test has been re-written by Luke's patchset which is still reviewing.</div><div style="font-size:small"><a href="https://lists.linux.it/pipermail/ltp/2022-April/028777.html" target="_blank">https://lists.linux.it/pipermail/ltp/2022-April/028777.html<br></a></div><div style="font-size:small"><br></div><div style="font-size:small"><a class="gmail_plusreply" id="gmail-m_-3967992612121128723plusReplyChip-0" href="mailto:luke.nowakowskikrijger@canonical.com" target="_blank">@Luke Nowakowski-Krijger</a> </div><div style="font-size:small">Luke, I guess V3 should be the final version (if you take the time to do</div><div style="font-size:small">rebase/modification) and we'll happy to help merge those patches next:).</div><div style="font-size:small"><br></div></div></div></blockquote><div><br></div><div>Let me finally get around to putting up the (hopefully) final revision so that people don't start doing things I already did :) <br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div style="font-size:small"></div><div style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 2, 2022 at 5:38 AM Edward Liaw via ltp <<a href="mailto:ltp@lists.linux.it" target="_blank">ltp@lists.linux.it</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The memcg_regression test creates a memcg/ directory that can be left<br>
behind if the test exits unexpectedly. Use a trap to clean up the<br>
directories on exit.<br>
<br>
Signed-off-by: Edward Liaw <<a href="mailto:edliaw@google.com" target="_blank">edliaw@google.com</a>><br>
---<br>
.../memcg/regression/memcg_regression_test.sh | 20 +++++++++++--------<br>
.../memcg/regression/memcg_test_4.sh | 11 ++++++----<br>
2 files changed, 19 insertions(+), 12 deletions(-)<br>
<br>
diff --git a/testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh b/testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh<br>
index c91a4069e..2467ae0e6 100755<br>
--- a/testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh<br>
+++ b/testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh<br>
@@ -54,6 +54,15 @@ nr_null=0<br>
nr_warning=0<br>
nr_lockdep=0<br>
<br>
+clean_up()<br>
+{<br>
+ # remove the cgroup<br>
+ rmdir memcg/0 2> /dev/null<br>
+ # unmount cgroup if still mounted<br>
+ umount memcg/<br>
+ rmdir memcg/<br>
+}<br>
+<br>
# check_kernel_bug - check if some kind of kernel bug happened<br>
check_kernel_bug()<br>
{<br>
@@ -102,12 +111,12 @@ check_kernel_bug()<br>
#---------------------------------------------------------------------------<br>
test_1()<br>
{<br>
- mkdir memcg/0/<br>
+ mkdir memcg/0<br>
echo 0 > memcg/0/memory.limit_in_bytes<br>
<br>
./memcg_test_1<br>
<br>
- rmdir memcg/0/<br>
+ rmdir memcg/0<br>
<br>
check_kernel_bug<br>
if [ $? -eq 1 ]; then<br>
@@ -211,14 +220,12 @@ test_4()<br>
killall -9 memcg_test_4 2> /dev/null<br>
killall -9 memcg_test_4.sh 2> /dev/null<br>
<br>
- # if test_4.sh gets killed, it won't clean cgroup it created<br>
- rmdir memcg/0 2> /dev/null<br>
-<br>
swapon -a<br>
}<br>
<br>
# main<br>
failed=0<br>
+trap clean_up EXIT<br>
mkdir memcg/<br>
<br>
for cur in $(seq 1 $TST_TOTAL); do<br>
@@ -236,7 +243,4 @@ for cur in $(seq 1 $TST_TOTAL); do<br>
umount memcg/<br>
done<br>
<br>
-rmdir memcg/<br>
-<br>
exit $failed<br>
-<br>
diff --git a/testcases/kernel/controllers/memcg/regression/memcg_test_4.sh b/testcases/kernel/controllers/memcg/regression/memcg_test_4.sh<br>
index 620031366..d002601f1 100755<br>
--- a/testcases/kernel/controllers/memcg/regression/memcg_test_4.sh<br>
+++ b/testcases/kernel/controllers/memcg/regression/memcg_test_4.sh<br>
@@ -22,6 +22,13 @@<br>
## ##<br>
################################################################################<br>
<br>
+clean_up()<br>
+{<br>
+ # remove the cgroup when exiting<br>
+ rmdir memcg/0<br>
+}<br>
+<br>
+trap clean_up EXIT<br>
# attach current task to memcg/0/<br>
mkdir memcg/0<br>
echo $$ > memcg/0/tasks<br>
@@ -42,7 +49,3 @@ swapoff -a<br>
sleep 1<br>
echo $pid > memcg/tasks 2> /dev/null<br>
echo $$ > memcg/tasks 2> /dev/null<br>
-<br>
-# now remove the cgroup<br>
-rmdir memcg/0<br>
-<br>
-- <br>
2.37.0.rc0.161.g10f37bed90-goog<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div></blockquote><div><br></div><div>- Luke <br></div></div></div>