cgroup_regression_test.sh: fix test_5 possible mount failure because of cgroup hierarchy
diff mbox series

Message ID 1560250815-2308-1-git-send-email-xuyang2018.jy@cn.fujitsu.com
State New
Headers show
Series
  • cgroup_regression_test.sh: fix test_5 possible mount failure because of cgroup hierarchy
Related show

Commit Message

Yang Xu June 11, 2019, 11 a.m. UTC
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 <xuyang2018.jy@cn.fujitsu.com>
---
 .../cgroup/cgroup_regression_test.sh           | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Comments

Yang Xu July 16, 2019, 6:01 a.m. UTC | #1
Hi 

Ping.  :-) 

> 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 <xuyang2018.jy@cn.fujitsu.com>
> ---
>  .../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
Yang Xu Aug. 2, 2019, 10:12 a.m. UTC | #2
Hi
Ping. :-)
> Hi 
>
> Ping.  :-) 
>
>> 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 <xuyang2018.jy@cn.fujitsu.com>
>> ---
>>  .../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

Patch
diff mbox series

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