Message ID | 96d276c11e69cfb1e29d50a12c8043555c06b404.1718144237.git.babu.moger@amd.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [v3] selftests/resctrl: Fix non-contiguous CBM for AMD | expand |
On Tue, 11 Jun 2024, Babu Moger wrote: > 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: ae638551ab64 ("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> Thanks. Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Hi Shuah, Could you please consider this fix for inclusion into kselftests? Thank you very much. Reinette On 6/11/24 3:18 PM, Babu Moger wrote: > 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: ae638551ab64 ("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> > --- > v3: Reworked changelong. > > v2: Moved the non-contiguous CBM verification to a new function > arch_supports_noncont_cat. > > v1: This was part of the series > https://lore.kernel.org/lkml/cover.1708637563.git.babu.moger@amd.com/ > Sending this as a separate fix per review comments. > --- > tools/testing/selftests/resctrl/cat_test.c | 32 +++++++++++++++------- > 1 file changed, 22 insertions(+), 10 deletions(-) > > diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c > index d4dffc934bc3..742782438ca3 100644 > --- a/tools/testing/selftests/resctrl/cat_test.c > +++ b/tools/testing/selftests/resctrl/cat_test.c > @@ -288,11 +288,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]; > > @@ -301,15 +320,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; > } >
On 6/26/24 10:55, Reinette Chatre wrote: > Hi Shuah, > > Could you please consider this fix for inclusion into kselftests? > > Thank you very much. > > Reinette > > On 6/11/24 3:18 PM, Babu Moger wrote: >> 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: ae638551ab64 ("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> >> --- >> v3: Reworked changelong. >> >> v2: Moved the non-contiguous CBM verification to a new function >> arch_supports_noncont_cat. >> >> v1: This was part of the series >> https://lore.kernel.org/lkml/cover.1708637563.git.babu.moger@amd.com/ >> Sending this as a separate fix per review comments. >> --- >> tools/testing/selftests/resctrl/cat_test.c | 32 +++++++++++++++------- >> 1 file changed, 22 insertions(+), 10 deletions(-) >> Applied to linux-kselftest fixes branch for 6.10-rc6 thanks, -- Shuah
On 6/26/24 12:25 PM, Shuah Khan wrote: > > Applied to linux-kselftest fixes branch for 6.10-rc6 > Thank you very much Shuah. Reinette
diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index d4dffc934bc3..742782438ca3 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -288,11 +288,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]; @@ -301,15 +320,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; }