From patchwork Tue Jun 11 11:00:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xu X-Patchwork-Id: 1113680 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45NRrN59zPz9sDB for ; Tue, 11 Jun 2019 21:01:08 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E97D63EAFF1 for ; Tue, 11 Jun 2019 13:01:05 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id C861F3EA360 for ; Tue, 11 Jun 2019 13:01:03 +0200 (CEST) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-2.smtp.seeweb.it (Postfix) with ESMTP id D3A4A601629 for ; Tue, 11 Jun 2019 13:00:59 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.63,577,1557158400"; d="scan'208";a="66915347" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Jun 2019 19:00:56 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id 52E2D4CD846F for ; Tue, 11 Jun 2019 19:00:57 +0800 (CST) Received: from localhost.localdomain (10.167.215.30) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 11 Jun 2019 19:00:54 +0800 From: Yang Xu To: Date: Tue, 11 Jun 2019 19:00:15 +0800 Message-ID: <1560250815-2308-1-git-send-email-xuyang2018.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.167.215.30] X-yoursite-MailScanner-ID: 52E2D4CD846F.AE0CE X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: xuyang2018.jy@cn.fujitsu.com X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_NONE autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH] cgroup_regression_test.sh: fix test_5 possible mount failure because of cgroup hierarchy X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 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" Currently, if systems doesn't mount subsys1,subsys2 and the hierarchy is not equal to 0, running it reports the following error: mount: xxx is already mounted or /tmp/ltp-wPw08anmTI/LTP_cgroup_regression_test.V4jf0qrS7z/cgroup busy cgroup_regression_test 5 TFAIL: mount net_prio and pids failed It fails because libcgroup doesn't permmit destroy cgroup subsystem hierarchies. Simple umnout does not destroy the hierarchies. They still live inside kernel! When hierarchy is equal to 0 in /proc/cgroups, we can mount them together on a new mountpoint. I add a check for subsystem hierarchy and get subsystem from head. Notice: more information about"Bug 612805 - cgroup: mount: none already mounted or /cgroups busy" Signed-off-by: Yang Xu --- .../cgroup/cgroup_regression_test.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh b/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh index e197f5d3f..38cb760c2 100755 --- a/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +++ b/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh @@ -252,8 +252,10 @@ test5() return fi - local subsys1=`tail -n 1 /proc/cgroups | awk '{ print $1 }'` - local subsys2=`tail -n 2 /proc/cgroups | head -1 | awk '{ print $1 }'` + local subsys1=`head -2 /proc/cgroups | tail -n 1 | awk '{ print $1 }'` + local subsys1_hierarchy=`head -2 /proc/cgroups | tail -n 1 | awk '{ print $2 }'` + local subsys2=`head -3 /proc/cgroups | tail -n 1 | awk '{ print $1 }'` + local subsys2_hierarchy=`head -3 /proc/cgroups | tail -n 1 | awk '{ print $2 }'` # Accounting here for the fact that the chosen subsystems could # have been already previously mounted at boot time: in such a @@ -267,10 +269,16 @@ test5() if [ -z "$mounted" ]; then mntpoint=cgroup failing=$subsys1 - mount -t cgroup -o $subsys1,$subsys2 xxx $mntpoint/ + mount -t cgroup -o $subsys1,$subsys2 xxx $mntpoint/ 2>/dev/null + # Even subsystem has not been mounted, it still live in kernel. + # So we will get EBUSY when both mount subsys1 and subsys2 if + # hierarchy isn't equal to 0. if [ $? -ne 0 ]; then - tst_res TFAIL "mount $subsys1 and $subsys2 failed" - return + if [ "$subsys1_hierarchy" = 0 -a "$subsys2_hierarchy" = 0 ]; then + tst_res TFAIL "mount $subsys1 and $subsys2 failed" + return + fi + failing=$subsys1,$subsys2 fi else # Use the pre-esistent mountpoint as $mntpoint and use a