Commit 6383851a authored by Ilpo Järvinen's avatar Ilpo Järvinen Committed by Shuah Khan

selftests/resctrl: Refactor remount_resctrl(bool mum_resctrlfs) to mount_resctrl()

Mount/umount of the resctrl FS is now paired nicely per test.

Rename remount_resctrl(bool mum_resctrlfs) to mount_resctrl(). Make
it unconditionally try to mount the resctrl FS and return error if
resctrl FS was mounted already.

While at it, group the mount/umount prototypes in the header.
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tested-by: default avatarBabu Moger <babu.moger@amd.com>
Tested-by: default avatarShaopeng Tan (Fujitsu) <tan.shaopeng@fujitsu.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent caddc0fb
...@@ -85,8 +85,8 @@ extern char llc_occup_path[1024]; ...@@ -85,8 +85,8 @@ extern char llc_occup_path[1024];
int get_vendor(void); int get_vendor(void);
bool check_resctrlfs_support(void); bool check_resctrlfs_support(void);
int filter_dmesg(void); int filter_dmesg(void);
int remount_resctrlfs(bool mum_resctrlfs);
int get_resource_id(int cpu_no, int *resource_id); int get_resource_id(int cpu_no, int *resource_id);
int mount_resctrlfs(void);
int umount_resctrlfs(void); int umount_resctrlfs(void);
int validate_bw_report_request(char *bw_report); int validate_bw_report_request(char *bw_report);
bool validate_resctrl_feature_request(const char *resctrl_val); bool validate_resctrl_feature_request(const char *resctrl_val);
......
...@@ -77,7 +77,7 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span, ...@@ -77,7 +77,7 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span,
ksft_print_msg("Starting MBM BW change ...\n"); ksft_print_msg("Starting MBM BW change ...\n");
res = remount_resctrlfs(true); res = mount_resctrlfs();
if (res) { if (res) {
ksft_exit_fail_msg("Failed to mount resctrl FS\n"); ksft_exit_fail_msg("Failed to mount resctrl FS\n");
return; return;
...@@ -106,7 +106,7 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span, ...@@ -106,7 +106,7 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span,
ksft_print_msg("Starting MBA Schemata change ...\n"); ksft_print_msg("Starting MBA Schemata change ...\n");
res = remount_resctrlfs(true); res = mount_resctrlfs();
if (res) { if (res) {
ksft_exit_fail_msg("Failed to mount resctrl FS\n"); ksft_exit_fail_msg("Failed to mount resctrl FS\n");
return; return;
...@@ -132,7 +132,7 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no) ...@@ -132,7 +132,7 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no)
ksft_print_msg("Starting CMT test ...\n"); ksft_print_msg("Starting CMT test ...\n");
res = remount_resctrlfs(true); res = mount_resctrlfs();
if (res) { if (res) {
ksft_exit_fail_msg("Failed to mount resctrl FS\n"); ksft_exit_fail_msg("Failed to mount resctrl FS\n");
return; return;
...@@ -160,7 +160,7 @@ static void run_cat_test(int cpu_no, int no_of_bits) ...@@ -160,7 +160,7 @@ static void run_cat_test(int cpu_no, int no_of_bits)
ksft_print_msg("Starting CAT test ...\n"); ksft_print_msg("Starting CAT test ...\n");
res = remount_resctrlfs(true); res = mount_resctrlfs();
if (res) { if (res) {
ksft_exit_fail_msg("Failed to mount resctrl FS\n"); ksft_exit_fail_msg("Failed to mount resctrl FS\n");
return; return;
......
...@@ -48,29 +48,20 @@ static int find_resctrl_mount(char *buffer) ...@@ -48,29 +48,20 @@ static int find_resctrl_mount(char *buffer)
} }
/* /*
* remount_resctrlfs - Remount resctrl FS at /sys/fs/resctrl * mount_resctrlfs - Mount resctrl FS at /sys/fs/resctrl
* @mum_resctrlfs: Should the resctrl FS be remounted?
* *
* If not mounted, mount it. * Mounts resctrl FS. Fails if resctrl FS is already mounted to avoid
* If mounted and mum_resctrlfs then remount resctrl FS. * pre-existing settings interfering with the test results.
* If mounted and !mum_resctrlfs then noop
* *
* Return: 0 on success, non-zero on failure * Return: 0 on success, non-zero on failure
*/ */
int remount_resctrlfs(bool mum_resctrlfs) int mount_resctrlfs(void)
{ {
char mountpoint[256];
int ret; int ret;
ret = find_resctrl_mount(mountpoint); ret = find_resctrl_mount(NULL);
if (ret) if (ret != -ENOENT)
strcpy(mountpoint, RESCTRL_PATH); return -1;
if (!ret && mum_resctrlfs && umount(mountpoint))
ksft_print_msg("Fail: unmounting \"%s\"\n", mountpoint);
if (!ret && !mum_resctrlfs)
return 0;
ksft_print_msg("Mounting resctrl to \"%s\"\n", RESCTRL_PATH); ksft_print_msg("Mounting resctrl to \"%s\"\n", RESCTRL_PATH);
ret = mount("resctrl", RESCTRL_PATH, "resctrl", 0, NULL); ret = mount("resctrl", RESCTRL_PATH, "resctrl", 0, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment