Skip to contentSkip to conversation

cgroup/cgroup_regression_test: Fix umount failure

PATCH Superseded Leo Liang 6 participants 9 messages Jun 28, 2021 – Jul 12, 2021

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Leo Liang

author
#0 lore raw

PATCH 1/1 cgroup/cgroup_regression_test: Fix umount failure

From a151d48235629a125d5db57dd76c96fd951d5293 Mon Sep 17 00:00:00 2001
From: Leo Yu-Chi Liang <[email protected]>
Date: Mon, 28 Jun 2021 11:05:54 +0800
Subject: [PATCH 1/1] cgroup/cgroup_regression_test: Fix umount failure

The test sequence

	mount -t cgroup -o <controllers> <path>
	mkdir <path>/<dir>
	rmdir <path>/<dir>
	umount <path>
	mount -t cgroup -o <controllers> <path>

would easily fail at the last mount with -EBUSY.

The reason is that this test sequence have the chance of missing a release code path when doing rmdir and umount.

Add sync between every "rmdir, umount" pair to fix the problem.

Fixes #839
---
 .../kernel/controllers/cgroup/cgroup_regression_test.sh    | 7 +++++++
 1 file changed, 7 insertions(+)
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +7 -0
index 1f7f3820e..9a00df101 100755
@@ -145,6 +145,7 @@ test2()
 	fi
 
 	rmdir cgroup/0 cgroup/1
+	sync
 	umount cgroup/
 }
 
@@ -193,6 +194,7 @@ test3()
 	wait $pid2 2>/dev/null
 
 	rmdir $cpu_subsys_path/0 2> /dev/null
+	sync
 	umount cgroup/ 2> /dev/null
 	check_kernel_bug
 }
@@ -222,6 +224,7 @@ test4()
 	mount -t cgroup -o none,name=foo cgroup cgroup/
 	mkdir cgroup/0
 	rmdir cgroup/0
+	sync
 	umount cgroup/
 
 	if dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low"; then
@@ -254,6 +257,7 @@ test5()
 	mount -t cgroup none cgroup 2> /dev/null
 	mkdir cgroup/0
 	rmdir cgroup/0
+	sync
 	umount cgroup/ 2> /dev/null
 	check_kernel_bug
 }
@@ -290,6 +294,7 @@ test6()
 
 	mount -t cgroup -o ns xxx cgroup/ > /dev/null 2>&1
 	rmdir cgroup/[1-9]* > /dev/null 2>&1
+	sync
 	umount cgroup/
 	check_kernel_bug
 }
@@ -324,6 +329,7 @@ test_7_1()
 	mkdir $subsys_path/0
 	sleep 100 < $subsys_path/0 &	# add refcnt to this dir
 	rmdir $subsys_path/0
+	sync
 
 	# remount with new subsystems added
 	# since 2.6.28, this remount will fail
@@ -349,6 +355,7 @@ test_7_2()
 	mkdir cgroup/0
 	sleep 100 < cgroup/0 &	# add refcnt to this dir
 	rmdir cgroup/0
+	sync
 
 	# remount with some subsystems removed
 	# since 2.6.28, this remount will fail
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/1 cgroup/cgroup_regression_test: Fix umount failure

Hello,

Quoted 13 lines · Leo Liang

From a151d48235629a125d5db57dd76c96fd951d5293 Mon Sep 17 00:00:00 2001
From: Leo Yu-Chi Liang <[email protected]>
Date: Mon, 28 Jun 2021 11:05:54 +0800
Subject: [PATCH 1/1] cgroup/cgroup_regression_test: Fix umount failure

The test sequence

	mount -t cgroup -o <controllers> <path>
	mkdir <path>/<dir>
	rmdir <path>/<dir>
	umount <path>
	mount -t cgroup -o <controllers> <path>

would easily fail at the last mount with -EBUSY.

Quoted 8 lines

The reason is that this test sequence have the chance of missing a release code path when doing rmdir and umount.

Add sync between every "rmdir, umount" pair to fix the problem.

Fixes #839
Signature · 2 lines
Thank you,
Richard.
#2 lore raw

PATCH 1/1 cgroup/cgroup_regression_test: Fix umount failure

In reply to Leo Liang

Hi,

Quoted 78 lines · Leo Liang

From a151d48235629a125d5db57dd76c96fd951d5293 Mon Sep 17 00:00:00 2001
From: Leo Yu-Chi Liang <[email protected]>
Date: Mon, 28 Jun 2021 11:05:54 +0800
Subject: [PATCH 1/1] cgroup/cgroup_regression_test: Fix umount failure

The test sequence

	mount -t cgroup -o <controllers> <path>
	mkdir <path>/<dir>
	rmdir <path>/<dir>
	umount <path>
	mount -t cgroup -o <controllers> <path>

would easily fail at the last mount with -EBUSY.

The reason is that this test sequence have the chance of missing a release code path when doing rmdir and umount.

Add sync between every "rmdir, umount" pair to fix the problem.

Fixes #839
---
  .../kernel/controllers/cgroup/cgroup_regression_test.sh    | 7 +++++++
  1 file changed, 7 insertions(+)
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +6 -0
index 1f7f3820e..9a00df101 100755
@@ -145,6 +145,7 @@ test2()
  	fi
 
  	rmdir cgroup/0 cgroup/1
+	sync
  	umount cgroup/
  }
 
@@ -193,6 +194,7 @@ test3()
  	wait $pid2 2>/dev/null
 
  	rmdir $cpu_subsys_path/0 2> /dev/null
+	sync
  	umount cgroup/ 2> /dev/null
  	check_kernel_bug
  }
@@ -222,6 +224,7 @@ test4()
  	mount -t cgroup -o none,name=foo cgroup cgroup/
  	mkdir cgroup/0
  	rmdir cgroup/0
+	sync
  	umount cgroup/
 
  	if dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low"; then
@@ -254,6 +257,7 @@ test5()
  	mount -t cgroup none cgroup 2> /dev/null
  	mkdir cgroup/0
  	rmdir cgroup/0
+	sync
  	umount cgroup/ 2> /dev/null
  	check_kernel_bug
  }
@@ -290,6 +294,7 @@ test6()
 
  	mount -t cgroup -o ns xxx cgroup/ > /dev/null 2>&1
  	rmdir cgroup/[1-9]* > /dev/null 2>&1
+	sync
  	umount cgroup/
  	check_kernel_bug
  }
@@ -324,6 +329,7 @@ test_7_1()
  	mkdir $subsys_path/0
  	sleep 100 < $subsys_path/0 &	# add refcnt to this dir
  	rmdir $subsys_path/0
+	sync
 
  	# remount with new subsystems added
  	# since 2.6.28, this remount will fail

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test_7_2() · line 361

Quoted 7 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1 -0
@@ -349,6 +355,7 @@ test_7_2()
  	mkdir cgroup/0
  	sleep 100 < cgroup/0 &	# add refcnt to this dir
  	rmdir cgroup/0
+	sync
 
  	# remount with some subsystems removed
  	# since 2.6.28, this remount will fail

I would like a short comment close to the syncs. When I converted cpuset_regression_test.sh, I would have removed the sync in there, if there wouldn't have been any comment.
Most of the time syncs are not required and just added by paranoid developers, but if there is a real reason, I think it should be stated in a comment.

J?rg

#3 lore raw

PATCH 1/1 cgroup/cgroup_regression_test: Fix umount failure

Hi all,

[ changed Cyril's address in Cc to the working one ]

Quoted 4 lines
Quoted 4 lines

mkdir cgroup/0
sleep 100 < cgroup/0 & # add refcnt to this dir
rmdir cgroup/0

(quoted diff) +1 -0
+	sync
Quoted 8 lines
Quoted 2 lines
  	# remount with some subsystems removed
  	# since 2.6.28, this remount will fail

I would like a short comment close to the syncs. When I converted cpuset_regression_test.sh, I would have removed the sync in there, if there wouldn't have been any comment.
Most of the time syncs are not required and just added by paranoid developers, but if there is a real reason, I think it should be stated in a comment.

Agree with this. Are all these sync really needed? Or just some?

Kind regards,
Petr

Quoted 1 line

J?rg

#4 lore raw

PATCH 1/1 cgroup/cgroup_regression_test: Fix umount failure

In reply to Joerg Vehlow

Hi!

Quoted 6 lines

I would like a short comment close to the syncs. When I converted cpuset_regression_test.sh, I would have removed the sync in there, if there wouldn't have been any comment.
Most of the time syncs are not required and just added by paranoid developers, but if there is a real reason, I think it should be stated in a comment.

Sounds reasonable to me, can we please add a comment there?

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#5 lore raw

PATCH 1/1 cgroup/cgroup_regression_test: Fix umount failure

Hi,

Sorry for the late response and thanks for all the replies and suggestions.

I am running on a rather new RISC-V platform (Andes/AE350) and with 5.4.0 off-tree kernel.
The umount in cgroup_regression_test mostly failed at test_2 and test_3,
so it would show FAIL result (mount not successfully executed) at test_3 and test_5 (test_4 shows TCONF on my platform).

Quoted 9 lines · Cyril Hrubis

Hi!

Quoted 6 lines

I would like a short comment close to the syncs. When I converted cpuset_regression_test.sh, I would have removed the sync in there, if there wouldn't have been any comment.
Most of the time syncs are not required and just added by paranoid developers, but if there is a real reason, I think it should be stated in a comment.

Sounds reasonable to me, can we please add a comment there?

Hi Cyril and Joerg,

Sounds reasonable to me as well,
will send a v2 patch with comment.

Quoted 6 lines
Signature · 5 lines
Cyril Hrubis
[email protected]


Agree with this. Are all these sync really needed? Or just some?

Hi Petr,

I've written a script containing only the following sequence
" mount 'cgroup mntpoint' "
" mkdir 'under cgroup mntpoint' "
" rmdir 'under cgroup mntpoint' "
" umount 'cgroup mntpoint' "
" mount 'cgroup mntpoint' "
and it could trigger the fail.

But only bumped into the umount fail when doing test_2 and test_3 in the cgroup_regression_test.

I am adding syncs in every sub-tests that execute the above sequence now. Should them be added only at the places where umount failure did occur ?

Quoted 6 lines

Kind regards,
Petr

IMO, Even we call sync, this umount may fail because sync ensures nothing. Why not use tst_umount?

Hi Yang,

I think this might be a timing issue and a little delay could fix this problem. (e.g. 'sleep 1') Using 'sync' here IMHO would be more descriptive and has a semantic meaning.

Speaking of tst_umount, do you mean to convert this test to C code ?

Quoted 2 lines

Best Regards
Yang Xu

Best regards,
Leo

#6 lore raw

PATCH 1/1 cgroup/cgroup_regression_test: Fix umount failure

Hi Leo

Quoted 50 lines

Hi,

Sorry for the late response and thanks for all the replies and suggestions.

I am running on a rather new RISC-V platform (Andes/AE350) and with 5.4.0 off-tree kernel.
The umount in cgroup_regression_test mostly failed at test_2 and test_3,
so it would show FAIL result (mount not successfully executed) at test_3 and test_5 (test_4 shows TCONF on my platform).

Quoted 9 lines · Cyril Hrubis

Hi!

Quoted 6 lines

I would like a short comment close to the syncs. When I converted cpuset_regression_test.sh, I would have removed the sync in there, if there wouldn't have been any comment.
Most of the time syncs are not required and just added by paranoid developers, but if there is a real reason, I think it should be stated in a comment.

Sounds reasonable to me, can we please add a comment there?

Hi Cyril and Joerg,

Sounds reasonable to me as well,
will send a v2 patch with comment.

Quoted 6 lines

--
Cyril Hrubis
[email protected]

Agree with this. Are all these sync really needed? Or just some?

Hi Petr,

I've written a script containing only the following sequence
" mount 'cgroup mntpoint' "
" mkdir 'under cgroup mntpoint' "
" rmdir 'under cgroup mntpoint' "
" umount 'cgroup mntpoint' "
" mount 'cgroup mntpoint' "
and it could trigger the fail.

But only bumped into the umount fail when doing test_2 and test_3 in the cgroup_regression_test.

I am adding syncs in every sub-tests that execute the above sequence now. Should them be added only at the places where umount failure did occur ?

Quoted 2 lines

Kind regards,
Petr

Quoted 7 lines
Quoted 2 lines

IMO, Even we call sync, this umount may fail because sync ensures nothing. Why not use tst_umount?

Hi Yang,

I think this might be a timing issue and a little delay could fix this problem. (e.g. 'sleep 1') Using 'sync' here IMHO would be more descriptive and has a semantic meaning.

Yes, it is a timing issue.
I also met a similar problem because of sync to lead EBUSY error in xfstests log time ago.

https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/commit/?id=b536de2a042484bb241cca120ce55c974309513a

So, I don't think using sync is a good idea because sync will make metadata into disk but no ensure it. So if we have other io work, then sync may push other's metadata into disk firstly instead of here's data.

Since we have tst_umount api to avoid EBUSY error, why not to use it in here to avoid your problem?

Quoted 2 lines

Speaking of tst_umount, do you mean to convert this test to C code ?

No, we also have shell api for tst_umount.

Quoted 6 lines
Quoted 3 lines

Best Regards
Yang Xu

Best regards,
Leo

author
#7 lore raw

PATCH 1/1 cgroup/cgroup_regression_test: Fix umount failure

Hi Yang,

Quoted 19 lines · On Tue, Jul 06, 2021 at 05:45:32AM +0000, [email protected] wrote:

Hi Leo

Quoted 8 lines
Quoted 3 lines

IMO, Even we call sync, this umount may fail because sync ensures nothing. Why not use tst_umount?

Hi Yang,

I think this might be a timing issue and a little delay could fix this problem. (e.g. 'sleep 1') Using 'sync' here IMHO would be more descriptive and has a semantic meaning.

Yes, it is a timing issue.
I also met a similar problem because of sync to lead EBUSY error in xfstests log time ago.

https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/commit/?id=b536de2a042484bb241cca120ce55c974309513a

So, I don't think using sync is a good idea because sync will make metadata into disk but no ensure it. So if we have other io work, then sync may push other's metadata into disk firstly instead of here's data.

Quoted 5 lines

Since we have tst_umount api to avoid EBUSY error, why not to use it in here to avoid your problem?

Quoted 2 lines

Speaking of tst_umount, do you mean to convert this test to C code ?

No, we also have shell api for tst_umount.

Thanks for the suggestion.
I've tested the cgroup_regression_test with the tst_umount api and it works fine!

I will convert "add sync" patch to this!
Thanks again.

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

Best Regards
Yang Xu

Best regards,
Leo

Best regards,
Leo

#8 lore raw

PATCH 1/1 cgroup/cgroup_regression_test: Fix umount failure

In reply to Leo Liang

Hi

IMO, Even we call sync, this umount may fail because sync ensures nothing. Why not use tst_umount?

Best Regards
Yang Xu

Quoted 85 lines

From a151d48235629a125d5db57dd76c96fd951d5293 Mon Sep 17 00:00:00 2001
From: Leo Yu-Chi Liang<[email protected]>
Date: Mon, 28 Jun 2021 11:05:54 +0800
Subject: [PATCH 1/1] cgroup/cgroup_regression_test: Fix umount failure

The test sequence

	mount -t cgroup -o<controllers>  <path>
	mkdir<path>/<dir>
	rmdir<path>/<dir>
	umount<path>
	mount -t cgroup -o<controllers>  <path>

would easily fail at the last mount with -EBUSY.

The reason is that this test sequence have the chance of missing a release code path when doing rmdir and umount.

Add sync between every "rmdir, umount" pair to fix the problem.

Fixes #839
---
  .../kernel/controllers/cgroup/cgroup_regression_test.sh    | 7 +++++++
  1 file changed, 7 insertions(+)
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +7 -0
index 1f7f3820e..9a00df101 100755
@@ -145,6 +145,7 @@ test2()
  	fi
 
  	rmdir cgroup/0 cgroup/1
+	sync
  	umount cgroup/
  }
 
@@ -193,6 +194,7 @@ test3()
  	wait $pid2 2>/dev/null
 
  	rmdir $cpu_subsys_path/0 2>  /dev/null
+	sync
  	umount cgroup/ 2>  /dev/null
  	check_kernel_bug
  }
@@ -222,6 +224,7 @@ test4()
  	mount -t cgroup -o none,name=foo cgroup cgroup/
  	mkdir cgroup/0
  	rmdir cgroup/0
+	sync
  	umount cgroup/
 
  	if dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low"; then
@@ -254,6 +257,7 @@ test5()
  	mount -t cgroup none cgroup 2>  /dev/null
  	mkdir cgroup/0
  	rmdir cgroup/0
+	sync
  	umount cgroup/ 2>  /dev/null
  	check_kernel_bug
  }
@@ -290,6 +294,7 @@ test6()
 
  	mount -t cgroup -o ns xxx cgroup/>  /dev/null 2>&1
  	rmdir cgroup/[1-9]*>  /dev/null 2>&1
+	sync
  	umount cgroup/
  	check_kernel_bug
  }
@@ -324,6 +329,7 @@ test_7_1()
  	mkdir $subsys_path/0
  	sleep 100<  $subsys_path/0&	# add refcnt to this dir
  	rmdir $subsys_path/0
+	sync
 
  	# remount with new subsystems added
  	# since 2.6.28, this remount will fail
@@ -349,6 +355,7 @@ test_7_2()
  	mkdir cgroup/0
  	sleep 100<  cgroup/0&	# add refcnt to this dir
  	rmdir cgroup/0
+	sync
 
  	# remount with some subsystems removed
  	# since 2.6.28, this remount will fail