Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 4823696

Browse files
babumogershuahkh
authored andcommitted
selftests/resctrl: Fix non-contiguous CBM for AMD
The non-contiguous CBM test fails on AMD with: Starting L3_NONCONT_CAT test ... Mounting resctrl to "/sys/fs/resctrl" CPUID output doesn't match 'sparse_masks' file content! not ok 5 L3_NONCONT_CAT: test AMD always supports non-contiguous CBM but does not report it via CPUID. Fix the non-contiguous CBM test to use CPUID to discover non-contiguous CBM support only on Intel. Fixes: ae63855 ("selftests/resctrl: Add non-contiguous CBMs CAT test") Signed-off-by: Babu Moger <babu.moger@amd.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent ed3994a commit 4823696

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

tools/testing/selftests/resctrl/cat_test.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,30 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param
291291
return ret;
292292
}
293293

294+
static bool arch_supports_noncont_cat(const struct resctrl_test *test)
295+
{
296+
unsigned int eax, ebx, ecx, edx;
297+
298+
/* AMD always supports non-contiguous CBM. */
299+
if (get_vendor() == ARCH_AMD)
300+
return true;
301+
302+
/* Intel support for non-contiguous CBM needs to be discovered. */
303+
if (!strcmp(test->resource, "L3"))
304+
__cpuid_count(0x10, 1, eax, ebx, ecx, edx);
305+
else if (!strcmp(test->resource, "L2"))
306+
__cpuid_count(0x10, 2, eax, ebx, ecx, edx);
307+
else
308+
return false;
309+
310+
return ((ecx >> 3) & 1);
311+
}
312+
294313
static int noncont_cat_run_test(const struct resctrl_test *test,
295314
const struct user_params *uparams)
296315
{
297316
unsigned long full_cache_mask, cont_mask, noncont_mask;
298-
unsigned int eax, ebx, ecx, edx, sparse_masks;
317+
unsigned int sparse_masks;
299318
int bit_center, ret;
300319
char schemata[64];
301320

@@ -304,15 +323,8 @@ static int noncont_cat_run_test(const struct resctrl_test *test,
304323
if (ret)
305324
return ret;
306325

307-
if (!strcmp(test->resource, "L3"))
308-
__cpuid_count(0x10, 1, eax, ebx, ecx, edx);
309-
else if (!strcmp(test->resource, "L2"))
310-
__cpuid_count(0x10, 2, eax, ebx, ecx, edx);
311-
else
312-
return -EINVAL;
313-
314-
if (sparse_masks != ((ecx >> 3) & 1)) {
315-
ksft_print_msg("CPUID output doesn't match 'sparse_masks' file content!\n");
326+
if (arch_supports_noncont_cat(test) != sparse_masks) {
327+
ksft_print_msg("Hardware and kernel differ on non-contiguous CBM support!\n");
316328
return 1;
317329
}
318330

0 commit comments

Comments
 (0)