[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201130202010.178373-16-fenghua.yu@intel.com>
Date: Mon, 30 Nov 2020 20:20:08 +0000
From: Fenghua Yu <fenghua.yu@...el.com>
To: "Shuah Khan" <shuah@...nel.org>, "Tony Luck" <tony.luck@...el.com>,
"Reinette Chatre" <reinette.chatre@...el.com>,
"David Binderman" <dcb314@...mail.com>,
"Babu Moger" <babu.moger@....com>,
"James Morse" <james.morse@....com>,
"Ravi V Shankar" <ravi.v.shankar@...el.com>
Cc: "linux-kernel" <linux-kernel@...r.kernel.org>,
Fenghua Yu <fenghua.yu@...el.com>
Subject: [PATCH v4 15/17] selftests/resctrl: Fix unmount resctrl FS
umount_resctrlfs() directly attempts to unmount resctrl file system without
checking if resctrl FS is already mounted or not. It returns 0 on success
and on failure it prints an error message and returns an error status.
Calling umount_resctrlfs() when resctrl FS isn't mounted will return an
error status.
There could be situations where-in the caller might not know if resctrl
FS is already mounted or not and the caller might still want to unmount
resctrl FS if it's already mounted (For example during teardown).
To support above use cases, change umount_resctrlfs() such that it now
first checks if resctrl FS is already mounted or not and unmounts resctrl
FS only if it's already mounted.
unmount resctrl FS upon exit. For example, running only mba test on a
Broadwell (BDW) machine (MBA isn't supported on BDW CPU).
This happens because validate_resctrl_feature_request() would mount resctrl
FS to check if mba is enabled on the platform or not and finds that the H/W
doesn't support mba and hence will return false to run_mba_test(). This in
turn makes the main() function return without unmounting resctrl FS.
Signed-off-by: Fenghua Yu <fenghua.yu@...el.com>
---
tools/testing/selftests/resctrl/resctrl_tests.c | 1 +
tools/testing/selftests/resctrl/resctrlfs.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
index 63400a51cbd8..7a63d5fcf4e0 100644
--- a/tools/testing/selftests/resctrl/resctrl_tests.c
+++ b/tools/testing/selftests/resctrl/resctrl_tests.c
@@ -257,6 +257,7 @@ int main(int argc, char **argv)
run_cat_test(cpu_no, no_of_bits);
out:
+ umount_resctrlfs();
printf("1..%d\n", tests_run);
return 0;
diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c
index 3f43bcf0b8d5..868f6f186e98 100644
--- a/tools/testing/selftests/resctrl/resctrlfs.c
+++ b/tools/testing/selftests/resctrl/resctrlfs.c
@@ -90,6 +90,9 @@ int remount_resctrlfs(bool mum_resctrlfs)
int umount_resctrlfs(void)
{
+ if (find_resctrl_mount(NULL))
+ return 0;
+
if (umount(RESCTRL_PATH)) {
perror("# Unable to umount resctrl");
--
2.29.2
Powered by blists - more mailing lists