From patchwork Tue Jul 20 15:05:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 1507601 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=aXhYsepA; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GThq14yDQz9sWd for ; Wed, 21 Jul 2021 01:05:33 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 295AE3C9815 for ; Tue, 20 Jul 2021 17:05:31 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id A8EA33C2090 for ; Tue, 20 Jul 2021 17:05:28 +0200 (CEST) Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 6BFDF1400E0E for ; Tue, 20 Jul 2021 17:05:27 +0200 (CEST) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id 719D1400FC for ; Tue, 20 Jul 2021 15:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1626793526; bh=KTu0Qj7Jz15SFKc4itqrIPw8ZfrS6SiwNXRQZtQaCJg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=aXhYsepAUeqQ91+KeEu61/d/vH+LLPcBzPQPTy/ZJxUk0KDKqkzSpZyEkMsiGNoGa KLjkzR+sQBSGN4BGwUTvGNbEEio02/uuKzJn4uHIU+ugb1GRCLphyJ2Wkm/UTHYIEL 7kGfb4T32mU3C+YOXoheFDaxd8AVSZXMxae1hn0McUMf2EUrIXeFToNK6FdPqFmfYj /sOhtBabO0zzdqgyEFCyOBc1O9Rq9GB2H/oKlPMHfXRj83PQRqBrvRnNf+32zF30pk ffYShEK+nc4X2IezBgJSQ+z5HWTdxLvONc3tYL8UuyVhzb78aLA78UPB6ogRAKRy+B RyZsZqMHtJlhg== Received: by mail-ej1-f70.google.com with SMTP id p20-20020a1709064994b02903cd421d7803so6928194eju.22 for ; Tue, 20 Jul 2021 08:05:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KTu0Qj7Jz15SFKc4itqrIPw8ZfrS6SiwNXRQZtQaCJg=; b=SUWD/fNUD7Etr8N/tKJ8EOq1Li6T5O7p75jBMMUbpVgzKCaPGILrwcgyc0gwpShcZX o2BpjL1M3l7WjrOHGeXP2dQ7FS0/k/CKTQOPPqQQ0Q5yhWq4XXeArqTyzMSYkDFZTwhK 9SK+xLLSnG6gRj6sLT//p/XDe/2jcGfz60wJhFCdD72BlUFHbDE+/XoPyGJdo8McauOK +/v8kureoD4WWNsmfn/hcN6UctbwhDCsVaZSjYq+Ky0/AGs6pzeO4Q7nyVCsS/S8oVjB VUjZAe6xXq6td3zrNrIv3e/aXAT4XIwgVCLASNdS8ylxOIQVl0V+SyDXVrbJEmMDEf5s i2Lg== X-Gm-Message-State: AOAM532vLZXv/GZNxZUvDTvlIwBPBshIL9EzP/XNCzVUS0DguvtH6daA spt+nesoEeuPYqg2hsFWiZWX3yQpqNN7O1hl+nD19acuPb+CO8OCoTe0erYpU8uqyELQiT7Zt5U 27jw4o2L1hdu1JC7ga8FgnJPheshl X-Received: by 2002:a17:906:c354:: with SMTP id ci20mr33033095ejb.435.1626793525657; Tue, 20 Jul 2021 08:05:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6PYinqc+5DlKTTpLz+Dn7RCUoISXriIDQ6C8pBlc/Z3eSPxDTgKvJQ0+0gDhEVjRzM83ywQ== X-Received: by 2002:a17:906:c354:: with SMTP id ci20mr33033066ejb.435.1626793525406; Tue, 20 Jul 2021 08:05:25 -0700 (PDT) Received: from localhost.localdomain ([86.32.47.9]) by smtp.gmail.com with ESMTPSA id h8sm7455129ejj.22.2021.07.20.08.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 08:05:25 -0700 (PDT) From: Krzysztof Kozlowski To: ltp@lists.linux.it Date: Tue, 20 Jul 2021 17:05:20 +0200 Message-Id: <20210720150520.17612-1-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH] controllers: detect previous test failure on cgroup mounts X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The failure of memcg_stress_test.sh cleanup went unnoticed (except echo message) and caused further cgroup_fj and memcg_control_test failures because of unclean cgroups. Flow is usually like: 1. memcg_stress_test succeeds but actually the /dev/memcg was not cleaned up. Notice lack of any error message due to 2>/dev/null. memcg_stress_test 1 TINFO: Testing 150 cgroups, using 1273 MB, interval 5 memcg_stress_test 1 TINFO: Starting cgroups memcg_stress_test 1 TINFO: Testing cgroups for 900s memcg_stress_test 1 TINFO: Killing groups tag=memcg_stress stime=1626770787 dur=903 exit=exited stat=2 core=no cu=19 cs=12 2. memcg_control_test has false-positive. It succeeds but actually no test was done due to /dev/memcg pollution from previous test: mkdir: cannot create directory ‘/tmp/ltp-q8DjShPJeB/mnt/1’: File exists memcg_control 0 TINFO : Test #1: Checking if the memory usage limit imposed by the topmost group is enforced sh: echo: I/O error /opt/ltp/testcases/bin/memcg_control_test.sh: 86: /opt/ltp/testcases/bin/memcg_control_test.sh: cannot create /tmp/ltp-q8DjShPJeB/mnt/1/memory.memsw.limit_in_bytes: Permission denied rmdir: failed to remove 'sub': Device or resource busy rmdir: failed to remove '/tmp/ltp-q8DjShPJeB/mnt/1': Device or resource busy memcg_control 1 TPASS : memcg_control: passed tag=memcg_control stime=1626771695 dur=6 exit=exited stat=0 core=no cu=2 cs=1 3. cgroup_fj_function2_memory fails with a cryptic message of mounting a path with new line (because /dev/memcg was not cleaned up before): cgroup_fj_function2_memory 1 TINFO: Subsystem memory is mounted at /sys/fs/cgroup/memory /dev/memcg mkdir: cannot create directory ‘/sys/fs/cgroup/memory’: File exists cgroup_fj_function2_memory 1 TBROK: mkdir /sys/fs/cgroup/memory /dev/memcg/ltp failed cgroup_fj_function2_memory 1 TINFO: Removing all ltp subgroups... find: ‘/sys/fs/cgroup/memory\n/dev/memcg/ltp/’: No such file or directory The actual failure was in memcg_stress_test executed before other tests, however it went unnoticed. Debugging such failures is difficult as result of failing test depends on running another which did not fail. Instead, detect unclean cgroups mounts and explicitly test it. Signed-off-by: Krzysztof Kozlowski --- .../kernel/controllers/cgroup_fj/cgroup_fj_common.sh | 4 ++-- .../controllers/memcg/control/memcg_control_test.sh | 10 ++++++---- .../controllers/memcg/stress/memcg_stress_test.sh | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh index 5594fe9de426..53ab637e8910 100755 --- a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh +++ b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh @@ -123,10 +123,10 @@ cleanup() fi if grep -q "$mount_point" /proc/mounts; then - umount "$mount_point" + EXPECT_PASS umount "$mount_point" fi if [ -e "$mount_point" ]; then - rmdir "$mount_point" + EXPECT_PASS rmdir "$mount_point" fi } diff --git a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh index 4d9f1bb5d586..626f5e676831 100644 --- a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh +++ b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh @@ -53,6 +53,8 @@ STATUS_PIPE="$TMP/status_pipe" PASS=0 FAIL=1 +. test.sh + # Check if the test process is killed on crossing boundary test_proc_kill() { @@ -118,8 +120,8 @@ result() cleanup() { if [ -e $TST_PATH/mnt ]; then - umount $TST_PATH/mnt 2> /dev/null - rm -rf $TST_PATH/mnt + EXPECT_PASS umount $TST_PATH/mnt + EXPECT_PASS rm -rf $TST_PATH/mnt fi } @@ -127,8 +129,8 @@ do_mount() { cleanup - mkdir $TST_PATH/mnt - mount -t cgroup -o memory cgroup $TST_PATH/mnt 2> /dev/null + EXPECT_PASS mkdir $TST_PATH/mnt + EXPECT_PASS mount -t cgroup -o memory cgroup $TST_PATH/mnt 2> /dev/null if [ $? -ne 0 ]; then tst_brkm TBROK NULL "Mounting cgroup to temp dir failed" rmdir $TST_PATH/mnt diff --git a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh index c2501e164018..8f7a0eb9dc37 100755 --- a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh +++ b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh @@ -44,8 +44,8 @@ setup() cleanup() { if [ -e /dev/memcg ]; then - umount /dev/memcg 2> /dev/null - rmdir /dev/memcg 2> /dev/null + EXPECT_PASS umount /dev/memcg + EXPECT_PASS rmdir /dev/memcg fi } @@ -53,8 +53,8 @@ do_mount() { cleanup - mkdir /dev/memcg 2> /dev/null - mount -t cgroup -omemory memcg /dev/memcg + EXPECT_PASS mkdir /dev/memcg + EXPECT_PASS mount -t cgroup -omemory memcg /dev/memcg } # $1 Number of cgroups