Skip to content

Commit e9d22f7

Browse files
committed
Merge tag 'linux_kselftest-fixes-6.10-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest fixes from Shuah Khan: "One single patch to fix the non-contiguous CBM resctrl: - AMD supports non-contiguous CBM but does not report it via CPUID. This test should not use CPUID on AMD to detect non-contiguous CBM support. Fix the problem so the test uses CPUID to discover non-contiguous CBM support only on Intel" * tag 'linux_kselftest-fixes-6.10-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: selftests/resctrl: Fix non-contiguous CBM for AMD
2 parents dbd8132 + 4823696 commit e9d22f7

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

tools/testing/selftests/resctrl/cat_test.c

+22-10
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)