[PATCH v2 3/3] selftests/resctrl: Fix non-contiguous CBM check for Hygon

Xiaochen Shen posted 3 patches 2 weeks ago
There is a newer version of this series
[PATCH v2 3/3] selftests/resctrl: Fix non-contiguous CBM check for Hygon
Posted by Xiaochen Shen 2 weeks ago
The resctrl selftest currently fails on Hygon CPUs that always supports
non-contiguous CBM, printing the error:

  "# Hardware and kernel differ on non-contiguous CBM support!"

This occurs because the arch_supports_noncont_cat() function lacks
vendor detection for Hygon CPUs, preventing proper identification of
their non-contiguous CBM capability.

Fix this by adding Hygon vendor ID detection to
arch_supports_noncont_cat().

Signed-off-by: Xiaochen Shen <shenxiaochen@open-hieco.net>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
Maintainer note:
Even though this is a fix it is not a candidate for backport since it is
based on another patch series (x86/resctrl: Fix Platform QoS issues for
Hygon) which is in process of being added to resctrl.

 tools/testing/selftests/resctrl/cat_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
index 94cfdba5308d..59a0f80fdc5a 100644
--- a/tools/testing/selftests/resctrl/cat_test.c
+++ b/tools/testing/selftests/resctrl/cat_test.c
@@ -290,8 +290,8 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param
 
 static bool arch_supports_noncont_cat(const struct resctrl_test *test)
 {
-	/* AMD always supports non-contiguous CBM. */
-	if (get_vendor() == ARCH_AMD)
+	/* AMD and Hygon always supports non-contiguous CBM. */
+	if (get_vendor() == ARCH_AMD || get_vendor() == ARCH_HYGON)
 		return true;
 
 #if defined(__i386__) || defined(__x86_64__) /* arch */
-- 
2.47.3
Re: [PATCH v2 3/3] selftests/resctrl: Fix non-contiguous CBM check for Hygon
Posted by Fenghua Yu 1 week, 6 days ago

On 12/5/25 01:25, Xiaochen Shen wrote:
> The resctrl selftest currently fails on Hygon CPUs that always supports
> non-contiguous CBM, printing the error:
> 
>    "# Hardware and kernel differ on non-contiguous CBM support!"
> 
> This occurs because the arch_supports_noncont_cat() function lacks
> vendor detection for Hygon CPUs, preventing proper identification of
> their non-contiguous CBM capability.
> 
> Fix this by adding Hygon vendor ID detection to
> arch_supports_noncont_cat().
> 
> Signed-off-by: Xiaochen Shen <shenxiaochen@open-hieco.net>
> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
> Maintainer note:
> Even though this is a fix it is not a candidate for backport since it is
> based on another patch series (x86/resctrl: Fix Platform QoS issues for
> Hygon) which is in process of being added to resctrl.
> 
>   tools/testing/selftests/resctrl/cat_test.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
> index 94cfdba5308d..59a0f80fdc5a 100644
> --- a/tools/testing/selftests/resctrl/cat_test.c
> +++ b/tools/testing/selftests/resctrl/cat_test.c
> @@ -290,8 +290,8 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param
>   
>   static bool arch_supports_noncont_cat(const struct resctrl_test *test)
>   {
> -	/* AMD always supports non-contiguous CBM. */
> -	if (get_vendor() == ARCH_AMD)
> +	/* AMD and Hygon always supports non-contiguous CBM. */
> +	if (get_vendor() == ARCH_AMD || get_vendor() == ARCH_HYGON)

nit. Better to avoid call get_vendor() twice (or even more in the future)?

unsigned int vendor_id = get_vendor();

if (vendor_id == ARCH_AMD || vendor_id == ARCH_HYGON)


>   		return true;
>   
>   #if defined(__i386__) || defined(__x86_64__) /* arch */
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>

Thanks.

-Fenghua
Re: [PATCH v2 3/3] selftests/resctrl: Fix non-contiguous CBM check for Hygon
Posted by Xiaochen Shen 1 week, 4 days ago
Hi Fenghua,

On 12/6/2025 3:39 AM, Fenghua Yu wrote:
>>     static bool arch_supports_noncont_cat(const struct resctrl_test *test)
>>   {
>> -    /* AMD always supports non-contiguous CBM. */
>> -    if (get_vendor() == ARCH_AMD)
>> +    /* AMD and Hygon always supports non-contiguous CBM. */
>> +    if (get_vendor() == ARCH_AMD || get_vendor() == ARCH_HYGON)
> 
> nit. Better to avoid call get_vendor() twice (or even more in the future)?
> 
> unsigned int vendor_id = get_vendor();
> 
> if (vendor_id == ARCH_AMD || vendor_id == ARCH_HYGON)

Thank you! I will update the code as you suggested.

> 
> 
>>           return true;
>>     #if defined(__i386__) || defined(__x86_64__) /* arch */
> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>

Thank you!


> 
> Thanks.
> 
> -Fenghua


Best regards,
Xiaochen Shen
Re: [PATCH v2 3/3] selftests/resctrl: Fix non-contiguous CBM check for Hygon
Posted by Reinette Chatre 1 week, 6 days ago
Hi Fenghua,

On 12/5/25 11:39 AM, Fenghua Yu wrote:
> 
> 
> On 12/5/25 01:25, Xiaochen Shen wrote:
>> The resctrl selftest currently fails on Hygon CPUs that always supports
>> non-contiguous CBM, printing the error:
>>
>>    "# Hardware and kernel differ on non-contiguous CBM support!"
>>
>> This occurs because the arch_supports_noncont_cat() function lacks
>> vendor detection for Hygon CPUs, preventing proper identification of
>> their non-contiguous CBM capability.
>>
>> Fix this by adding Hygon vendor ID detection to
>> arch_supports_noncont_cat().
>>
>> Signed-off-by: Xiaochen Shen <shenxiaochen@open-hieco.net>
>> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
>> ---
>> Maintainer note:
>> Even though this is a fix it is not a candidate for backport since it is
>> based on another patch series (x86/resctrl: Fix Platform QoS issues for
>> Hygon) which is in process of being added to resctrl.
>>
>>   tools/testing/selftests/resctrl/cat_test.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
>> index 94cfdba5308d..59a0f80fdc5a 100644
>> --- a/tools/testing/selftests/resctrl/cat_test.c
>> +++ b/tools/testing/selftests/resctrl/cat_test.c
>> @@ -290,8 +290,8 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param
>>     static bool arch_supports_noncont_cat(const struct resctrl_test *test)
>>   {
>> -    /* AMD always supports non-contiguous CBM. */
>> -    if (get_vendor() == ARCH_AMD)
>> +    /* AMD and Hygon always supports non-contiguous CBM. */
>> +    if (get_vendor() == ARCH_AMD || get_vendor() == ARCH_HYGON)
> 
> nit. Better to avoid call get_vendor() twice (or even more in the future)?

Are you perhaps referring to detect_vendor()? detect_vendor() does the actual digging to
determine the vendor ID and is indeed called just once by get_vendor(). In subsequent calls 
get_vendor() just returns the static ID.

Reinette
Re: [PATCH v2 3/3] selftests/resctrl: Fix non-contiguous CBM check for Hygon
Posted by Fenghua Yu 1 week, 6 days ago
Hi, Reinette,

On 12/5/25 13:30, Reinette Chatre wrote:
> Hi Fenghua,
> 
> On 12/5/25 11:39 AM, Fenghua Yu wrote:
>>
>>
>> On 12/5/25 01:25, Xiaochen Shen wrote:
>>> The resctrl selftest currently fails on Hygon CPUs that always supports
>>> non-contiguous CBM, printing the error:
>>>
>>>     "# Hardware and kernel differ on non-contiguous CBM support!"
>>>
>>> This occurs because the arch_supports_noncont_cat() function lacks
>>> vendor detection for Hygon CPUs, preventing proper identification of
>>> their non-contiguous CBM capability.
>>>
>>> Fix this by adding Hygon vendor ID detection to
>>> arch_supports_noncont_cat().
>>>
>>> Signed-off-by: Xiaochen Shen <shenxiaochen@open-hieco.net>
>>> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
>>> ---
>>> Maintainer note:
>>> Even though this is a fix it is not a candidate for backport since it is
>>> based on another patch series (x86/resctrl: Fix Platform QoS issues for
>>> Hygon) which is in process of being added to resctrl.
>>>
>>>    tools/testing/selftests/resctrl/cat_test.c | 4 ++--
>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
>>> index 94cfdba5308d..59a0f80fdc5a 100644
>>> --- a/tools/testing/selftests/resctrl/cat_test.c
>>> +++ b/tools/testing/selftests/resctrl/cat_test.c
>>> @@ -290,8 +290,8 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param
>>>      static bool arch_supports_noncont_cat(const struct resctrl_test *test)
>>>    {
>>> -    /* AMD always supports non-contiguous CBM. */
>>> -    if (get_vendor() == ARCH_AMD)
>>> +    /* AMD and Hygon always supports non-contiguous CBM. */
>>> +    if (get_vendor() == ARCH_AMD || get_vendor() == ARCH_HYGON)
>>
>> nit. Better to avoid call get_vendor() twice (or even more in the future)?
> 
> Are you perhaps referring to detect_vendor()? detect_vendor() does the actual digging to
> determine the vendor ID and is indeed called just once by get_vendor(). In subsequent calls
> get_vendor() just returns the static ID.

There is still cost to call get_vendor() (call, push, cmp, pop, ret, 
etc) in subsequent calls. I just feel it's redundant to call it multiple 
times in just one sentence.

Thanks.

-Fenghua