diff mbox series

selftests/resctrl: Fix noncont_cat_run_test for AMD

Message ID 3a6c9dd9dc6bda6e2582db049bfe853cd836139f.1717622080.git.babu.moger@amd.com (mailing list archive)
State New
Headers show
Series selftests/resctrl: Fix noncont_cat_run_test for AMD | expand

Commit Message

Moger, Babu June 5, 2024, 9:36 p.m. UTC
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(-)

Comments

Reinette Chatre June 6, 2024, 8:33 p.m. UTC | #1
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?

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.

Reinette
Moger, Babu June 6, 2024, 11:09 p.m. UTC | #2
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;
         }
Reinette Chatre June 6, 2024, 11:58 p.m. UTC | #3
Hi Babu,

On 6/6/24 4:09 PM, Moger, Babu wrote:
> 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 {

The else can be dropped since it follows a return.
The rest of the code can be prefixed with a matching
comment like:
	/* Intel support for non-contiguous CBM needs to be discovered. */

(please feel free to improve)

> +               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");

Please fix the test as well as the message. It is not an error if hardware does
not support non-contiguous CBM. It is an error if the hardware and kernel disagrees whether
non-contiguous CBM is supported.

Reinette
Ilpo Järvinen June 7, 2024, 10:21 a.m. UTC | #4
On Wed, 5 Jun 2024, 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;
>  	}
> 

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Moger, Babu June 7, 2024, 6:16 p.m. UTC | #5
Hi Reinette,

On 6/6/2024 6:58 PM, Reinette Chatre wrote:
> Hi Babu,
> 
> On 6/6/24 4:09 PM, Moger, Babu wrote:
>> 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 {
> 
> The else can be dropped since it follows a return.
Sure

> The rest of the code can be prefixed with a matching
> comment like:
>      /* Intel support for non-contiguous CBM needs to be discovered. */

Sure
> 
> (please feel free to improve)
> 
>> +               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");
> 
> Please fix the test as well as the message. It is not an error if 
> hardware does
> not support non-contiguous CBM. It is an error if the hardware and 
> kernel disagrees whether
> non-contiguous CBM is supported.

Not sure about this comment.

Did you mean?

  if (!arch_supports_noncont_cat(test)) {
                 ksft_print_msg("Hardware does not support 
non-contiguous CBM!\n");
                 return 0;
          } else if (arch_supports_noncont_cat(test) && !sparse_masks)) {
                 ksft_print_msg("Hardware and kernel support for 
non-contiguous CBM does not match!\n");
                 return 1;
         }
Reinette Chatre June 7, 2024, 9:47 p.m. UTC | #6
Hi Babu,

On 6/7/24 11:16 AM, Moger, Babu wrote:
> On 6/6/2024 6:58 PM, Reinette Chatre wrote:
>> On 6/6/24 4:09 PM, Moger, Babu wrote:

>>> @@ -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");
>>
>> Please fix the test as well as the message. It is not an error if hardware does
>> not support non-contiguous CBM. It is an error if the hardware and kernel disagrees whether
>> non-contiguous CBM is supported.
> 
> Not sure about this comment.
> 
> Did you mean?
> 
>   if (!arch_supports_noncont_cat(test)) {
>                  ksft_print_msg("Hardware does not support non-contiguous CBM!\n");
>                  return 0;

The above changes whether support for non-contiguous CBM is treated as an error but the
test should still proceed since the test goes on to write different CBM to the system
and verifies results are as expected based on what hardware supports.

>           } else if (arch_supports_noncont_cat(test) && !sparse_masks)) {
>                  ksft_print_msg("Hardware and kernel support for non-contiguous CBM does not match!\n");
>                  return 1;

I can see how this will work for AMD for the scenario being checked but not for
the different Intel variants.

I think this can all be simplified with something like:
	if (arch_supports_noncont_cat(test) != sparse_masks)) {
		ksft_print_msg("Hardware and kernel differ on non-contiguous CBM support!\n");
		return 1;
	}

I modified the message slightly since non-contiguous CBM does not actually require kernel
support.

What do you think?

Reinette
Moger, Babu June 7, 2024, 10:35 p.m. UTC | #7
Hi Reinette,

On 6/7/2024 4:47 PM, Reinette Chatre wrote:
> Hi Babu,
> 
> On 6/7/24 11:16 AM, Moger, Babu wrote:
>> On 6/6/2024 6:58 PM, Reinette Chatre wrote:
>>> On 6/6/24 4:09 PM, Moger, Babu wrote:
> 
>>>> @@ -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");
>>>
>>> Please fix the test as well as the message. It is not an error if 
>>> hardware does
>>> not support non-contiguous CBM. It is an error if the hardware and 
>>> kernel disagrees whether
>>> non-contiguous CBM is supported.
>>
>> Not sure about this comment.
>>
>> Did you mean?
>>
>>   if (!arch_supports_noncont_cat(test)) {
>>                  ksft_print_msg("Hardware does not support 
>> non-contiguous CBM!\n");
>>                  return 0;
> 
> The above changes whether support for non-contiguous CBM is treated as 
> an error but the
> test should still proceed since the test goes on to write different CBM 
> to the system
> and verifies results are as expected based on what hardware supports.
> 
>>           } else if (arch_supports_noncont_cat(test) && !sparse_masks)) {
>>                  ksft_print_msg("Hardware and kernel support for 
>> non-contiguous CBM does not match!\n");
>>                  return 1;
> 
> I can see how this will work for AMD for the scenario being checked but 
> not for
> the different Intel variants.
> 
> I think this can all be simplified with something like:
>      if (arch_supports_noncont_cat(test) != sparse_masks)) {
>          ksft_print_msg("Hardware and kernel differ on non-contiguous 
> CBM support!\n");
>          return 1;
>      }
> 
> I modified the message slightly since non-contiguous CBM does not 
> actually require kernel
> support.
> 
> What do you think?

Yes. That is fine.
Thank you
- Babu Moger
diff mbox series

Patch

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;
 	}