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@xxxxxxxxx> --- tools/testing/selftests/resctrl/resctrlfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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"); + } } /* -- 2.19.1