Skip to contentSkip to conversation

cgroup/cgroup_regression_test: Fix umount failure

PATCH Superseded Leo Liang 4 participants 10 messages Jul 19, 2021 – Jul 29, 2021

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Leo Liang

author
#0 lore raw

PATCH v4 2/2 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 on certain platform.

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

Adding a little delay between "rmdir" and "umount" could fix the problem, so use tst_umount API instead of umount in "rmdir, umount" sequence.

Fixes #839
---
 .../controllers/cgroup/cgroup_regression_test.sh       | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +5 -5
index 1f7f3820e..06379c7ae 100755
@@ -145,7 +145,7 @@ test2()
 	fi
 
 	rmdir cgroup/0 cgroup/1
-	umount cgroup/
+	tst_umount cgroup/	# Avoid possible EBUSY error
 }
 
 #---------------------------------------------------------------------------
@@ -193,7 +193,7 @@ test3()
 	wait $pid2 2>/dev/null
 
 	rmdir $cpu_subsys_path/0 2> /dev/null
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error
 	check_kernel_bug
 }
 
@@ -222,7 +222,7 @@ test4()
 	mount -t cgroup -o none,name=foo cgroup cgroup/
 	mkdir cgroup/0
 	rmdir cgroup/0
-	umount cgroup/
+	tst_umount cgroup/		# Avoid possible EBUSY error
 
 	if dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low"; then
 		tst_res TFAIL "lockdep BUG was found"
@@ -254,7 +254,7 @@ test5()
 	mount -t cgroup none cgroup 2> /dev/null
 	mkdir cgroup/0
 	rmdir cgroup/0
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error
 	check_kernel_bug
 }
 
@@ -290,7 +290,7 @@ test6()
 
 	mount -t cgroup -o ns xxx cgroup/ > /dev/null 2>&1
 	rmdir cgroup/[1-9]* > /dev/null 2>&1
-	umount cgroup/
+	tst_umount cgroup/		# Avoid possible EBUSY error
 	check_kernel_bug
 }
 
Signature · 1 line
2.17.0
#1 lore raw

PATCH v4 2/2 cgroup/cgroup_regression_test: Fix umount failure

Hi Leo,

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test3() · line 196

Quoted 12 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +2 -2
 	rmdir cgroup/0 cgroup/1
-	umount cgroup/
+	tst_umount cgroup/	# Avoid possible EBUSY error
 }
 
 #---------------------------------------------------------------------------
@@ -193,7 +193,7 @@ test3()
 	wait $pid2 2>/dev/null
 
 	rmdir $cpu_subsys_path/0 2> /dev/null
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error

I'd prefer: # keep "/" to avoid possible EBUSY error But that can be changed before merge.

More I'm interested if other maintainers agree with me about this approach. (keep / here instead of in tst_umount())

Quoted 13 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1 -1
 	check_kernel_bug
 }
 
@@ -222,7 +222,7 @@ test4()
 	mount -t cgroup -o none,name=foo cgroup cgroup/
 	mkdir cgroup/0
 	rmdir cgroup/0
-	umount cgroup/
+	tst_umount cgroup/		# Avoid possible EBUSY error
 
 	if dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low"; then
 		tst_res TFAIL "lockdep BUG was found"

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test5() · line 257

Quoted 5 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1 -1
@@ -254,7 +254,7 @@ test5()
 	mount -t cgroup none cgroup 2> /dev/null
 	mkdir cgroup/0
 	rmdir cgroup/0
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error

I'd drop stderr redirection here. It was here originally, but I suppose it's not needed when using tst_umount. But that can be done during merge.

...

Kind regards,
Petr

#2 lore raw

PATCH v4 2/2 cgroup/cgroup_regression_test: Fix umount failure

Hi,

Quoted 17 lines · Petr Vorel

Hi Leo,

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test3() · line 195

Quoted 10 lines

rmdir cgroup/0 cgroup/1

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +2 -2
-	umount cgroup/
+	tst_umount cgroup/	# Avoid possible EBUSY error
  }
  #---------------------------------------------------------------------------
@@ -193,7 +193,7 @@ test3()
  	wait $pid2 2>/dev/null
  	rmdir $cpu_subsys_path/0 2> /dev/null
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error

I'd prefer: # keep "/" to avoid possible EBUSY error But that can be changed before merge.

Quoted 2 lines

More I'm interested if other maintainers agree with me about this approach. (keep / here instead of in tst_umount())

I had a first look at this patches and was curious, what the reasoning behind the "/" is.
The comment you suggest is wrong. The / was introduced to prevent unmounting some other mountpoint,
where the device was cgroup.
Imho the approach of adding a / to the end was wrong and intransparent. I would rather use "./cgroup" or "$PWD/cgroup".
If possible, I'd actually change tst_umount, to always unmount the mountpoint and not the device, i.e. if the given path is not an absolute path, make it absolute (e.g. by prepending $PWD").
This way the check if the mountpoint exist wouldn't be the fuzzy thing it is right now.

As for the comment ("# Avoid possible EBUSY error"): Honestly I'd drop it and like in the c-api make using tst_umount instead of plain umount the default, for the same reasons.

Quoted 10 lines

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test5() · line 257

Quoted 8 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1 -1
  	if dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low"; then
  		tst_res TFAIL "lockdep BUG was found"
@@ -254,7 +254,7 @@ test5()
  	mount -t cgroup none cgroup 2> /dev/null
  	mkdir cgroup/0
  	rmdir cgroup/0
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error

I'd drop stderr redirection here. It was here originally, but I suppose it's not needed when using tst_umount. But that can be done during merge.

+1

Joerg

author
#9 lore raw

PATCH v4 2/2 cgroup/cgroup_regression_test: Fix umount failure

In reply to Petr Vorel

Hi Petr,

Quoted 32 lines · Petr Vorel

Hi Leo,

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test3() · line 196

Quoted 12 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +2 -2
 	rmdir cgroup/0 cgroup/1
-	umount cgroup/
+	tst_umount cgroup/	# Avoid possible EBUSY error
 }
 
 #---------------------------------------------------------------------------
@@ -193,7 +193,7 @@ test3()
 	wait $pid2 2>/dev/null
 
 	rmdir $cpu_subsys_path/0 2> /dev/null
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error

I'd prefer: # keep "/" to avoid possible EBUSY error But that can be changed before merge.

More I'm interested if other maintainers agree with me about this approach. (keep / here instead of in tst_umount())

Quoted 9 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1 -1
 	check_kernel_bug
 }
 
@@ -222,7 +222,7 @@ test4()
 	mount -t cgroup -o none,name=foo cgroup cgroup/
 	mkdir cgroup/0
 	rmdir cgroup/0
-	umount cgroup/
+	tst_umount cgroup/		# Avoid possible EBUSY error
Quoted 11 lines

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test5() · line 257

Quoted 8 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1 -1
 	if dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low"; then
 		tst_res TFAIL "lockdep BUG was found"
@@ -254,7 +254,7 @@ test5()
 	mount -t cgroup none cgroup 2> /dev/null
 	mkdir cgroup/0
 	rmdir cgroup/0
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error

I'd drop stderr redirection here. It was here originally, but I suppose it's not needed when using tst_umount. But that can be done during merge.

OK got it.
Thanks for the review!
Let's wait for other maintainer's comment on the aaproach for keeping '/' here or not.

Best regards,
Leo

Quoted 4 lines

...

Kind regards,
Petr

author
#3 lore raw

PATCH v4 2/2 cgroup/cgroup_regression_test: Fix umount failure

In reply to Joerg Vehlow

Hi Joerg,

Quoted 35 lines · Joerg Vehlow

Hi,

Quoted 17 lines · Petr Vorel

Hi Leo,

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test3() · line 195

Quoted 10 lines

rmdir cgroup/0 cgroup/1

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +2 -2
-	umount cgroup/
+	tst_umount cgroup/	# Avoid possible EBUSY error
  }
  #---------------------------------------------------------------------------
@@ -193,7 +193,7 @@ test3()
  	wait $pid2 2>/dev/null
  	rmdir $cpu_subsys_path/0 2> /dev/null
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error

I'd prefer: # keep "/" to avoid possible EBUSY error But that can be changed before merge.

Quoted 2 lines

More I'm interested if other maintainers agree with me about this approach. (keep / here instead of in tst_umount())

I had a first look at this patches and was curious, what the reasoning behind the "/" is.
The comment you suggest is wrong. The / was introduced to prevent unmounting some other mountpoint,
where the device was cgroup.
Imho the approach of adding a / to the end was wrong and intransparent. I would rather use "./cgroup" or "$PWD/cgroup".
If possible, I'd actually change tst_umount, to always unmount the mountpoint and not the device, i.e. if the given path is not an absolute path, make it absolute (e.g. by prepending $PWD").
This way the check if the mountpoint exist wouldn't be the fuzzy thing it is right now.

Quoted 3 lines

As for the comment ("# Avoid possible EBUSY error"): Honestly I'd drop it and like in the c-api make using tst_umount instead of plain umount the default, for the same reasons.

Got it!
Thanks for the detailed explanation!
I will send a v5 patch for this modification.
(making the path absolute inside tst_umount)

Quoted 11 lines
Quoted 11 lines

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test5() · line 257

Quoted 9 lines
testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +1 -1
  	if dmesg | grep -q "MAX_LOCKDEP_SUBCLASSES too low"; then
  		tst_res TFAIL "lockdep BUG was found"
@@ -254,7 +254,7 @@ test5()
  	mount -t cgroup none cgroup 2> /dev/null
  	mkdir cgroup/0
  	rmdir cgroup/0
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error

I'd drop stderr redirection here. It was here originally, but I suppose it's not needed when using tst_umount. But that can be done during merge.

Quoted 1 line

+1

This change will be included in the next patch as well. Thanks again!

Best regards,
Leo

Quoted 1 line

Joerg

#4 lore raw

PATCH v4 2/2 cgroup/cgroup_regression_test: Fix umount failure

Hi Leo,

Quoted 37 lines · Leo Liang

Hi Joerg,

Quoted 35 lines · Joerg Vehlow

Hi,

Quoted 17 lines · Petr Vorel

Hi Leo,

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test3() · line 195

Quoted 10 lines

rmdir cgroup/0 cgroup/1

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +2 -2
-	umount cgroup/
+	tst_umount cgroup/	# Avoid possible EBUSY error
   }
   #---------------------------------------------------------------------------
@@ -193,7 +193,7 @@ test3()
   	wait $pid2 2>/dev/null
   	rmdir $cpu_subsys_path/0 2> /dev/null
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error

I'd prefer: # keep "/" to avoid possible EBUSY error But that can be changed before merge.

Quoted 2 lines

More I'm interested if other maintainers agree with me about this approach. (keep / here instead of in tst_umount())

I had a first look at this patches and was curious, what the reasoning behind the "/" is.
The comment you suggest is wrong. The / was introduced to prevent unmounting some other mountpoint,
where the device was cgroup.
Imho the approach of adding a / to the end was wrong and intransparent. I would rather use "./cgroup" or "$PWD/cgroup".
If possible, I'd actually change tst_umount, to always unmount the mountpoint and not the device, i.e. if the given path is not an absolute path, make it absolute (e.g. by prepending $PWD").
This way the check if the mountpoint exist wouldn't be the fuzzy thing it is right now.

Quoted 7 lines
Quoted 3 lines

As for the comment ("# Avoid possible EBUSY error"): Honestly I'd drop it and like in the c-api make using tst_umount instead of plain umount the default, for the same reasons.

Got it!
Thanks for the detailed explanation!
I will send a v5 patch for this modification.
(making the path absolute inside tst_umount)

This was just my opinon. I am not in the place to say how it should be done. Maybe wait for replies from the maintainers.
Additionally, all usages of tst_umount have to be checked, to ensure they are passing a mountpoint and not a device, otherwise my proposal cannot be implemented in tst_umount.

Joerg

author
#5 lore raw

PATCH v4 2/2 cgroup/cgroup_regression_test: Fix umount failure

Hi Joerg,

Quoted 48 lines · Joerg Vehlow

Hi Leo,

Quoted 37 lines · Leo Liang

Hi Joerg,

Quoted 35 lines · Joerg Vehlow

Hi,

Quoted 17 lines · Petr Vorel

Hi Leo,

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh test3() · line 195

Quoted 10 lines

rmdir cgroup/0 cgroup/1

testcases/kernel/controllers/cgroup/cgroup_regression_test.sh +2 -2
-	umount cgroup/
+	tst_umount cgroup/	# Avoid possible EBUSY error
   }
   #---------------------------------------------------------------------------
@@ -193,7 +193,7 @@ test3()
   	wait $pid2 2>/dev/null
   	rmdir $cpu_subsys_path/0 2> /dev/null
-	umount cgroup/ 2> /dev/null
+	tst_umount cgroup/ 2> /dev/null		# Avoid possible EBUSY error

I'd prefer: # keep "/" to avoid possible EBUSY error But that can be changed before merge.

Quoted 2 lines

More I'm interested if other maintainers agree with me about this approach. (keep / here instead of in tst_umount())

I had a first look at this patches and was curious, what the reasoning behind the "/" is.
The comment you suggest is wrong. The / was introduced to prevent unmounting some other mountpoint,
where the device was cgroup.
Imho the approach of adding a / to the end was wrong and intransparent. I would rather use "./cgroup" or "$PWD/cgroup".
If possible, I'd actually change tst_umount, to always unmount the mountpoint and not the device, i.e. if the given path is not an absolute path, make it absolute (e.g. by prepending $PWD").
This way the check if the mountpoint exist wouldn't be the fuzzy thing it is right now.

Quoted 7 lines
Quoted 3 lines

As for the comment ("# Avoid possible EBUSY error"): Honestly I'd drop it and like in the c-api make using tst_umount instead of plain umount the default, for the same reasons.

Got it!
Thanks for the detailed explanation!
I will send a v5 patch for this modification.
(making the path absolute inside tst_umount)

Quoted 6 lines

This was just my opinon. I am not in the place to say how it should be done. Maybe wait for replies from the maintainers.
Additionally, all usages of tst_umount have to be checked, to ensure they are passing a mountpoint and not a device, otherwise my proposal cannot be implemented in tst_umount.

Understood! Thanks for the suggestion.
I think I will send a v5 that stays with the original change for this patchset. Then send a new RFC patchset to implement your suggestion and check for all uses of this API.

Best regards,
Leo

Quoted 1 line

Joerg

#6 lore raw

PATCH v4 2/2 cgroup/cgroup_regression_test: Fix umount failure

In reply to Joerg Vehlow

Hi!

Quoted 7 lines

I had a first look at this patches and was curious, what the reasoning behind the "/" is.
The comment you suggest is wrong. The / was introduced to prevent unmounting some other mountpoint,
where the device was cgroup.
Imho the approach of adding a / to the end was wrong and intransparent. I would rather use "./cgroup" or "$PWD/cgroup".

Passing full path to the cgroup directory sound much safer to me especially when the directory name is just 'cgroup', try it yourself:

device=cgroup/; grep "${device%/}" /proc/mounts

On my machine this yields 10 lines and 21 matches.

Quoted 5 lines

If possible, I'd actually change tst_umount, to always unmount the mountpoint and not the device, i.e. if the given path is not an absolute path, make it absolute (e.g. by prepending $PWD").
This way the check if the mountpoint exist wouldn't be the fuzzy thing it is right now.

Strongly agree here.

I would go even one step further and change the library so that it rejects anything that does not start with '/'.

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

PATCH v4 2/2 cgroup/cgroup_regression_test: Fix umount failure

Hi,

FYI this discussion is on v4, there is already v5 (marking it changes requested in patchwork) and obviously v6 will be needed. Leo, I suppose you'll implement everything mentioned here in v6.

Quoted 3 lines

Hi!

Quoted 2 lines

I had a first look at this patches and was curious, what the reasoning behind the "/" is.

+1 I should have ask myself as well :).

Quoted 6 lines
Quoted 5 lines

The comment you suggest is wrong. The / was introduced to prevent unmounting some other mountpoint,
where the device was cgroup.
Imho the approach of adding a / to the end was wrong and intransparent. I would rather use "./cgroup" or "$PWD/cgroup".

Quoted 12 lines

Passing full path to the cgroup directory sound much safer to me especially when the directory name is just 'cgroup', try it yourself:

device=cgroup/; grep "${device%/}" /proc/mounts

On my machine this yields 10 lines and 21 matches.

Quoted 5 lines

If possible, I'd actually change tst_umount, to always unmount the mountpoint and not the device, i.e. if the given path is not an absolute path, make it absolute (e.g. by prepending $PWD").
This way the check if the mountpoint exist wouldn't be the fuzzy thing it is right now.

+1

Quoted 4 lines

Strongly agree here.

I would go even one step further and change the library so that it rejects anything that does not start with '/'.

+1

Kind regards,
Petr

author
#8 lore raw

PATCH v4 2/2 cgroup/cgroup_regression_test: Fix umount failure

Hi,

Quoted 6 lines · Petr Vorel

Hi,

FYI this discussion is on v4, there is already v5 (marking it changes requested in patchwork) and obviously v6 will be needed. Leo, I suppose you'll implement everything mentioned here in v6.

No problem! Thanks for all the advice!
Will prepare a v6 soon!

Quoted 23 lines
Quoted 3 lines

Hi!

Quoted 2 lines

I had a first look at this patches and was curious, what the reasoning behind the "/" is.

+1 I should have ask myself as well :).

Quoted 6 lines
Quoted 5 lines

The comment you suggest is wrong. The / was introduced to prevent unmounting some other mountpoint,
where the device was cgroup.
Imho the approach of adding a / to the end was wrong and intransparent. I would rather use "./cgroup" or "$PWD/cgroup".

Quoted 12 lines

Passing full path to the cgroup directory sound much safer to me especially when the directory name is just 'cgroup', try it yourself:

device=cgroup/; grep "${device%/}" /proc/mounts

On my machine this yields 10 lines and 21 matches.

Quoted 5 lines

If possible, I'd actually change tst_umount, to always unmount the mountpoint and not the device, i.e. if the given path is not an absolute path, make it absolute (e.g. by prepending $PWD").
This way the check if the mountpoint exist wouldn't be the fuzzy thing it is right now.

Quoted 9 lines

+1

Quoted 4 lines

Strongly agree here.

I would go even one step further and change the library so that it rejects anything that does not start with '/'.

+1

Will include both points in v6 patch!

Quoted 2 lines

Kind regards,
Petr

Best regards,
Leo