[V2,16/19] selftests/resctrl: Umount resctrl FS only if mounted
diff mbox series

Message ID f65df6aa5dc5b66ac804389e7859a08101107285.1589835155.git.sai.praneeth.prakhya@intel.com
State New
Headers show
  • Miscellaneous fixes for resctrl selftests
Related show

Commit Message

Prakhya, Sai Praneeth May 18, 2020, 10:08 p.m. UTC
Currently, umount_resctrlfs() directly attempts to unmount resctrl FS
without checking if resctrl FS is already mounted or not. But, there
could be situations where-in the caller might not know if resctrl FS is
already mounted or not. The caller might want to unmount resctrl FS _only_
if it's already mounted.

Hence, change umount_resctrlfs() such that it now first checks if resctrl
FS is mounted or not and unmounts resctrl FS only if it's already mounted
and does nothing if it's not mounted.

Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
 tools/testing/selftests/resctrl/resctrlfs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff mbox series

diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c
index 83cd3b026c52..ebc8e3b4f7ff 100644
--- a/tools/testing/selftests/resctrl/resctrlfs.c
+++ b/tools/testing/selftests/resctrl/resctrlfs.c
@@ -92,8 +92,10 @@  int remount_resctrlfs(bool mum_resctrlfs)
 void umount_resctrlfs(void)
-	if (umount(RESCTRL_PATH))
-		perror("# Unable to umount resctrl");
+	if (!find_resctrl_mount(NULL)) {
+		if (umount(RESCTRL_PATH))
+			perror("# Unable to umount resctrl");
+	}