Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/resctrl: Skip the test if requested resctrl feature is not supported

There could be two reasons why a resctrl feature might not be enabled on
the platform
1. H/W might not support the feature
2. Even if the H/W supports it, the user might have disabled the feature
through kernel command line arguments

Hence, any resctrl unit test (like cmt, cat, mbm and mba) before starting
the test will first check if the feature is enabled on the platform or not.
If the feature isn't enabled, then the test returns with an error status.
For example, if MBA isn't supported on a platform and if the user tries to
run MBA, the output will look like this

ok mounting resctrl to "/sys/fs/resctrl"
not ok MBA: schemata change

But, not supporting a feature isn't a test failure. So, instead of treating
it as an error, use the SKIP directive of the TAP protocol. With the
change, the output will look as below

ok MBA # SKIP Hardware does not support MBA or MBA is disabled

Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Fenghua Yu and committed by
Shuah Khan
f1dd7198 c9fb4e7c

+23 -9
-3
tools/testing/selftests/resctrl/cat_test.c
··· 111 111 if (ret) 112 112 return ret; 113 113 114 - if (!validate_resctrl_feature_request("cat")) 115 - return -1; 116 - 117 114 /* Get default cbm mask for L3/L2 cache */ 118 115 ret = get_cbm_mask(cache_type, cbm_mask); 119 116 if (ret)
-3
tools/testing/selftests/resctrl/mba_test.c
··· 158 158 159 159 remove(RESULT_FILE_NAME); 160 160 161 - if (!validate_resctrl_feature_request("mba")) 162 - return -1; 163 - 164 161 ret = resctrl_val(benchmark_cmd, &param); 165 162 if (ret) 166 163 return ret;
-3
tools/testing/selftests/resctrl/mbm_test.c
··· 131 131 132 132 remove(RESULT_FILE_NAME); 133 133 134 - if (!validate_resctrl_feature_request("mbm")) 135 - return -1; 136 - 137 134 ret = resctrl_val(benchmark_cmd, &param); 138 135 if (ret) 139 136 return ret;
+23
tools/testing/selftests/resctrl/resctrl_tests.c
··· 60 60 int res; 61 61 62 62 ksft_print_msg("Starting MBM BW change ...\n"); 63 + 64 + if (!validate_resctrl_feature_request(MBM_STR)) { 65 + ksft_test_result_skip("Hardware does not support MBM or MBM is disabled\n"); 66 + return; 67 + } 68 + 63 69 if (!has_ben) 64 70 sprintf(benchmark_cmd[5], "%s", MBA_STR); 65 71 res = mbm_bw_change(span, cpu_no, bw_report, benchmark_cmd); ··· 79 73 int res; 80 74 81 75 ksft_print_msg("Starting MBA Schemata change ...\n"); 76 + 77 + if (!validate_resctrl_feature_request(MBA_STR)) { 78 + ksft_test_result_skip("Hardware does not support MBA or MBA is disabled\n"); 79 + return; 80 + } 81 + 82 82 if (!has_ben) 83 83 sprintf(benchmark_cmd[1], "%d", span); 84 84 res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd); ··· 97 85 int res; 98 86 99 87 ksft_print_msg("Starting CMT test ...\n"); 88 + if (!validate_resctrl_feature_request(CMT_STR)) { 89 + ksft_test_result_skip("Hardware does not support CMT or CMT is disabled\n"); 90 + return; 91 + } 92 + 100 93 if (!has_ben) 101 94 sprintf(benchmark_cmd[5], "%s", CMT_STR); 102 95 res = cmt_resctrl_val(cpu_no, 5, benchmark_cmd); ··· 114 97 int res; 115 98 116 99 ksft_print_msg("Starting CAT test ...\n"); 100 + 101 + if (!validate_resctrl_feature_request(CAT_STR)) { 102 + ksft_test_result_skip("Hardware does not support CAT or CAT is disabled\n"); 103 + return; 104 + } 105 + 117 106 res = cat_perf_miss_val(cpu_no, no_of_bits, "L3"); 118 107 ksft_test_result(!res, "CAT: test\n"); 119 108 cat_test_cleanup();