selftests/resctrl: Unmount resctrl FS before starting the first test

Resctrl FS mount/remount/umount code is hard to track. Better approach
is to use mount/umount pair for each test but that assumes resctrl FS
is not mounted beforehand.

Change umount_resctrlfs() so that it can unmount resctrl FS from any
path, and enable further simplifications into mount/remount/umount
logic by unmounting resctrl FS at the start if a pre-existing
mountpoint is found.

Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Tested-by: Shaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
Ilpo Järvinen 2023-07-17 16:14:53 +03:00 committed by Shuah Khan
parent 51a0c3b7f0
commit ede1300848
2 changed files with 12 additions and 3 deletions

View File

@ -250,6 +250,9 @@ int main(int argc, char **argv)
if (!check_resctrlfs_support())
return ksft_exit_skip("resctrl FS does not exist. Enable X86_CPU_RESCTRL config option.\n");
if (umount_resctrlfs())
return ksft_exit_skip("resctrl FS unmount failed.\n");
filter_dmesg();
ksft_set_plan(tests ? : 4);

View File

@ -82,10 +82,16 @@ int remount_resctrlfs(bool mum_resctrlfs)
int umount_resctrlfs(void)
{
if (find_resctrl_mount(NULL))
return 0;
char mountpoint[256];
int ret;
if (umount(RESCTRL_PATH)) {
ret = find_resctrl_mount(mountpoint);
if (ret == -ENOENT)
return 0;
if (ret)
return ret;
if (umount(mountpoint)) {
perror("# Unable to umount resctrl");
return errno;