Skip to content

Commit

Permalink
Merge tag 'linux_kselftest-fixes-6.10-rc7' of git://git.kernel.org/pu…
Browse files Browse the repository at this point in the history
…b/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
  • Loading branch information
torvalds committed Jul 2, 2024
2 parents dbd8132 + 4823696 commit e9d22f7
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions tools/testing/selftests/resctrl/cat_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,30 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param
return ret;
}

static bool arch_supports_noncont_cat(const struct resctrl_test *test)
{
unsigned int eax, ebx, ecx, edx;

/* AMD always supports non-contiguous CBM. */
if (get_vendor() == ARCH_AMD)
return true;

/* Intel support for non-contiguous CBM needs to be discovered. */
if (!strcmp(test->resource, "L3"))
__cpuid_count(0x10, 1, eax, ebx, ecx, edx);
else if (!strcmp(test->resource, "L2"))
__cpuid_count(0x10, 2, eax, ebx, ecx, edx);
else
return false;

return ((ecx >> 3) & 1);
}

static int noncont_cat_run_test(const struct resctrl_test *test,
const struct user_params *uparams)
{
unsigned long full_cache_mask, cont_mask, noncont_mask;
unsigned int eax, ebx, ecx, edx, sparse_masks;
unsigned int sparse_masks;
int bit_center, ret;
char schemata[64];

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

if (!strcmp(test->resource, "L3"))
__cpuid_count(0x10, 1, eax, ebx, ecx, edx);
else if (!strcmp(test->resource, "L2"))
__cpuid_count(0x10, 2, eax, ebx, ecx, edx);
else
return -EINVAL;

if (sparse_masks != ((ecx >> 3) & 1)) {
ksft_print_msg("CPUID output doesn't match 'sparse_masks' file content!\n");
if (arch_supports_noncont_cat(test) != sparse_masks) {
ksft_print_msg("Hardware and kernel differ on non-contiguous CBM support!\n");
return 1;
}

Expand Down

0 comments on commit e9d22f7

Please sign in to comment.