On Thu, 13 Jul 2023, Reinette Chatre wrote:
> Hi Ilpo,
>
> On 7/13/2023 6:19 AM, Ilpo Järvinen wrote:
> > A few places currently lack umounting resctrl FS on error paths:
> > - cmt_resctrl_val() has multiple error paths with direct return.
> > - cat_perf_miss_val() has multiple error paths with direct return.
> > In addition, validate_resctrl_feature_request() is called by
> > run_mbm_test() and run_mba_test(). Neither MBA nor MBM test tries to
> > umount resctrl FS.
> >
> > Each and every test does require resctrl FS to be present already for
> > feature check. Thus, it makes sense to just mount it on higher level in
> > resctrl_tests.c and properly pair it with umount.
> >
> > Move resctrl FS (re)mount/unmount into each test function in
> > resctrl_tests.c. Make feature validation to simply check that resctrl
> > FS is mounted.
> >
> > Fixes: 91db4fd9019a ("selftests/resctrl: Remove duplicate codes that clear each test result file")
>
> Could you please elaborate how this commit is the culprit?
Of course it isn't. I'm pretty sure I had some idea when that was added
but it was before the patches were rearranged/modified, maybe I
incorrectly thought that the cleanup functions do umount (but they don't).
I'll changed it to these:
Fixes: f1dd71982d19 ("selftests/resctrl: Skip the test if requested resctrl feature is not supported")
Fixes: 01fee6b4d1f9 ("selftests/resctrl: Add MBA test")
Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test")
Fixes: 790bf585b0ee ("selftests/resctrl: Add Cache Allocation Technology (CAT) selftest")
Fixes: 78941183d1b1 ("selftests/resctrl: Add Cache QoS Monitoring (CQM) selftest")
...however, I was also considering dropping Fixes completely because
main() has the final umount() at the end so no lingering resctrl FS after
tests, and inter-test issues are hard to track due to how complicated the
code is so I'm not entirely sure if there are real issues under any
combination of tests and all the mounting/unmounting going on).
Hi Ilpo,
On 7/14/2023 4:31 AM, Ilpo Järvinen wrote:
> On Thu, 13 Jul 2023, Reinette Chatre wrote:
>
>> Hi Ilpo,
>>
>> On 7/13/2023 6:19 AM, Ilpo Järvinen wrote:
>>> A few places currently lack umounting resctrl FS on error paths:
>>> - cmt_resctrl_val() has multiple error paths with direct return.
>>> - cat_perf_miss_val() has multiple error paths with direct return.
>>> In addition, validate_resctrl_feature_request() is called by
>>> run_mbm_test() and run_mba_test(). Neither MBA nor MBM test tries to
>>> umount resctrl FS.
>>>
>>> Each and every test does require resctrl FS to be present already for
>>> feature check. Thus, it makes sense to just mount it on higher level in
>>> resctrl_tests.c and properly pair it with umount.
>>>
>>> Move resctrl FS (re)mount/unmount into each test function in
>>> resctrl_tests.c. Make feature validation to simply check that resctrl
>>> FS is mounted.
>>>
>>> Fixes: 91db4fd9019a ("selftests/resctrl: Remove duplicate codes that clear each test result file")
>>
>> Could you please elaborate how this commit is the culprit?
>
> Of course it isn't. I'm pretty sure I had some idea when that was added
> but it was before the patches were rearranged/modified, maybe I
> incorrectly thought that the cleanup functions do umount (but they don't).
>
> I'll changed it to these:
> Fixes: f1dd71982d19 ("selftests/resctrl: Skip the test if requested resctrl feature is not supported")
> Fixes: 01fee6b4d1f9 ("selftests/resctrl: Add MBA test")
> Fixes: ecdbb911f22d ("selftests/resctrl: Add MBM test")
> Fixes: 790bf585b0ee ("selftests/resctrl: Add Cache Allocation Technology (CAT) selftest")
> Fixes: 78941183d1b1 ("selftests/resctrl: Add Cache QoS Monitoring (CQM) selftest")
>
> ...however, I was also considering dropping Fixes completely because
> main() has the final umount() at the end so no lingering resctrl FS after
> tests, and inter-test issues are hard to track due to how complicated the
> code is so I'm not entirely sure if there are real issues under any
> combination of tests and all the mounting/unmounting going on).
>
Indeed. The problem statement is that some places lack
unmounting resctrl FS on error paths. This may create impression
that there are scenarios where resctrl is left mounted on failure.
As you indicate this is not the case. I agree that the "Fixes" tag
can be dropped with this categorized as code refactor instead.
Reinette
@@ -106,10 +106,6 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
cache_size = 0;
- ret = remount_resctrlfs(true);
- if (ret)
- return ret;
-
/* Get default cbm mask for L3/L2 cache */
ret = get_cbm_mask(cache_type, cbm_mask);
if (ret)
@@ -227,8 +223,6 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)
out:
cat_test_cleanup();
- if (bm_pid)
- umount_resctrlfs();
return ret;
}
@@ -86,10 +86,6 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd)
cache_size = 0;
- ret = remount_resctrlfs(true);
- if (ret)
- return ret;
-
if (!validate_resctrl_feature_request(CMT_STR))
return -1;
@@ -77,9 +77,15 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span,
ksft_print_msg("Starting MBM BW change ...\n");
+ res = remount_resctrlfs(true);
+ if (res) {
+ ksft_exit_fail_msg("Failed to mount resctrl FS\n");
+ return;
+ }
+
if (!validate_resctrl_feature_request(MBM_STR) || (get_vendor() != ARCH_INTEL)) {
ksft_test_result_skip("Hardware does not support MBM or MBM is disabled\n");
- return;
+ goto umount;
}
if (!has_ben)
@@ -88,6 +94,9 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span,
ksft_test_result(!res, "MBM: bw change\n");
if ((get_vendor() == ARCH_INTEL) && res)
ksft_print_msg("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
+
+umount:
+ umount_resctrlfs();
}
static void run_mba_test(bool has_ben, char **benchmark_cmd, int span,
@@ -97,15 +106,24 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span,
ksft_print_msg("Starting MBA Schemata change ...\n");
+ res = remount_resctrlfs(true);
+ if (res) {
+ ksft_exit_fail_msg("Failed to mount resctrl FS\n");
+ return;
+ }
+
if (!validate_resctrl_feature_request(MBA_STR) || (get_vendor() != ARCH_INTEL)) {
ksft_test_result_skip("Hardware does not support MBA or MBA is disabled\n");
- return;
+ goto umount;
}
if (!has_ben)
sprintf(benchmark_cmd[1], "%d", span);
res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd);
ksft_test_result(!res, "MBA: schemata change\n");
+
+umount:
+ umount_resctrlfs();
}
static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no)
@@ -113,9 +131,16 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no)
int res;
ksft_print_msg("Starting CMT test ...\n");
+
+ res = remount_resctrlfs(true);
+ if (res) {
+ ksft_exit_fail_msg("Failed to mount resctrl FS\n");
+ return;
+ }
+
if (!validate_resctrl_feature_request(CMT_STR)) {
ksft_test_result_skip("Hardware does not support CMT or CMT is disabled\n");
- return;
+ goto umount;
}
if (!has_ben)
@@ -124,6 +149,9 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no)
ksft_test_result(!res, "CMT: test\n");
if ((get_vendor() == ARCH_INTEL) && res)
ksft_print_msg("Intel CMT may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
+
+umount:
+ umount_resctrlfs();
}
static void run_cat_test(int cpu_no, int no_of_bits)
@@ -132,13 +160,22 @@ static void run_cat_test(int cpu_no, int no_of_bits)
ksft_print_msg("Starting CAT test ...\n");
+ res = remount_resctrlfs(true);
+ if (res) {
+ ksft_exit_fail_msg("Failed to mount resctrl FS\n");
+ return;
+ }
+
if (!validate_resctrl_feature_request(CAT_STR)) {
ksft_test_result_skip("Hardware does not support CAT or CAT is disabled\n");
- return;
+ goto umount;
}
res = cat_perf_miss_val(cpu_no, no_of_bits, "L3");
ksft_test_result(!res, "CAT: test\n");
+
+umount:
+ umount_resctrlfs();
}
int main(int argc, char **argv)
@@ -268,7 +305,5 @@ int main(int argc, char **argv)
if (cat_test)
run_cat_test(cpu_no, no_of_bits);
- umount_resctrlfs();
-
ksft_finished();
}
@@ -648,10 +648,6 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param)
return ret;
}
- ret = remount_resctrlfs(param->mum_resctrlfs);
- if (ret)
- return ret;
-
/*
* If benchmark wasn't successfully started by child, then child should
* kill parent, so save parent's pid
@@ -788,7 +784,6 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param)
signal_handler_unregister();
out:
kill(bm_pid, SIGKILL);
- umount_resctrlfs();
return ret;
}
@@ -613,7 +613,8 @@ char *fgrep(FILE *inf, const char *str)
* validate_resctrl_feature_request - Check if requested feature is valid.
* @resctrl_val: Requested feature
*
- * Return: True if the feature is supported, else false
+ * Return: True if the feature is supported, else false. False is also
+ * returned if resctrl FS is not mounted.
*/
bool validate_resctrl_feature_request(const char *resctrl_val)
{
@@ -621,11 +622,13 @@ bool validate_resctrl_feature_request(const char *resctrl_val)
bool found = false;
char *res;
FILE *inf;
+ int ret;
if (!resctrl_val)
return false;
- if (remount_resctrlfs(false))
+ ret = find_resctrl_mount(NULL);
+ if (ret)
return false;
if (!strncmp(resctrl_val, CAT_STR, sizeof(CAT_STR))) {