From: "Moger, Babu" <bmoger@amd.com>
To: Reinette Chatre <reinette.chatre@intel.com>,
Babu Moger <babu.moger@amd.com>,
fenghua.yu@intel.com, shuah@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
ilpo.jarvinen@linux.intel.com, maciej.wieczor-retman@intel.com,
peternewman@google.com, eranian@google.com
Subject: Re: [PATCH] selftests/resctrl: Fix noncont_cat_run_test for AMD
Date: Thu, 6 Jun 2024 18:09:24 -0500 [thread overview]
Message-ID: <3bd755d7-e5c7-3dc3-9875-4884c857e325@amd.com> (raw)
In-Reply-To: <9a7213d2-a782-4342-93f2-acf191c745fd@intel.com>
Hi Reinette,
On 6/6/2024 3:33 PM, Reinette Chatre wrote:
> Hi Babu,
>
> On 6/5/24 2:36 PM, Babu Moger wrote:
>> The selftest noncont_cat_run_test fails on AMD with the warnings. Reason
>> is, AMD supports non contiguous CBM masks but does not report it via
>> CPUID.
>>
>> Update noncont_cat_run_test to check for the vendor when verifying CPUID.
>>
>> Fixes: ae638551ab64 ("selftests/resctrl: Add non-contiguous CBMs CAT
>> test")
>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>> ---
>> 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 | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/resctrl/cat_test.c
>> b/tools/testing/selftests/resctrl/cat_test.c
>> index d4dffc934bc3..b2988888786e 100644
>> --- a/tools/testing/selftests/resctrl/cat_test.c
>> +++ b/tools/testing/selftests/resctrl/cat_test.c
>> @@ -308,7 +308,7 @@ static int noncont_cat_run_test(const struct
>> resctrl_test *test,
>> else
>> return -EINVAL;
>> - if (sparse_masks != ((ecx >> 3) & 1)) {
>> + if ((get_vendor() == ARCH_INTEL) && sparse_masks != ((ecx >> 3) &
>> 1)) {
>> ksft_print_msg("CPUID output doesn't match 'sparse_masks'
>> file content!\n");
>> return 1;
>> }
>
> Since AMD does not report this support via CPUID it does not seem
> appropriate to use CPUID at all on AMD when doing the hardware check.
> I think the above check makes it difficult to understand what is different
> on AMD.
>
> What if instead there is a new function, for example,
> "static bool arch_supports_noncont_cat(const struct resctrl_test *test)"
> that returns true if the hardware supports non-contiguous CBM?
Sure.
>
> The vendor check can be in there to make it obvious what is going on:
>
> /* AMD always supports non-contiguous CBM. */
> if (get_vendor() == AMD)
> return true;
>
> /* CPUID check for Intel here. */
>
> The "sparse_masks" from kernel can then be checked against
> hardware support with an appropriate (no mention of CPUID)
> error message if this fails.
>
Something like this?
diff --git a/tools/testing/selftests/resctrl/cat_test.c
b/tools/testing/selftests/resctrl/cat_test.c
index d4dffc934bc3..b75d220f29f6 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;
+ } else {
+ 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 does not support non-contiguous
CBM!\n");
return 1;
}
--
- Babu Moger
next prev parent reply other threads:[~2024-06-06 23:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 21:36 [PATCH] selftests/resctrl: Fix noncont_cat_run_test for AMD Babu Moger
2024-06-06 20:33 ` Reinette Chatre
2024-06-06 23:09 ` Moger, Babu [this message]
2024-06-06 23:58 ` Reinette Chatre
2024-06-07 18:16 ` Moger, Babu
2024-06-07 21:47 ` Reinette Chatre
2024-06-07 22:35 ` Moger, Babu
2024-06-07 10:21 ` Ilpo Järvinen
2024-06-10 16:00 ` [PATCH v2] " Babu Moger
2024-06-10 16:20 ` Ilpo Järvinen
2024-06-10 17:51 ` Moger, Babu
2024-06-10 21:28 ` Reinette Chatre
2024-06-11 6:50 ` Ilpo Järvinen
2024-06-10 21:32 ` Reinette Chatre
2024-06-10 23:11 ` Moger, Babu
2024-06-11 23:14 ` Reinette Chatre
2024-06-11 22:18 ` [PATCH v3] selftests/resctrl: Fix non-contiguous CBM " Babu Moger
2024-06-12 7:33 ` Ilpo Järvinen
2024-06-26 16:55 ` Reinette Chatre
2024-06-26 19:25 ` Shuah Khan
2024-06-26 20:44 ` Reinette Chatre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3bd755d7-e5c7-3dc3-9875-4884c857e325@amd.com \
--to=bmoger@amd.com \
--cc=babu.moger@amd.com \
--cc=eranian@google.com \
--cc=fenghua.yu@intel.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maciej.wieczor-retman@intel.com \
--cc=peternewman@google.com \
--cc=reinette.chatre@intel.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox