* [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
@ 2026-09-02 14:37 Andre Przywara
2026-09-07 12:59 ` Ben Horgan
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Andre Przywara @ 2026-09-02 14:37 UTC (permalink / raw)
To: James Morse, Ben Horgan
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
get_cpu_cacheinfo_id() can fail, in which case it returns a negative
error value.
Check the returned value for this error condition, before passing the
value on to other code, which would hide the negative number in some high
value in the unsigned type.
Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
drivers/resctrl/mpam_resctrl.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 9d223057953ab..a5e661eff86d7 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
/* Find the L3 cache that has affinity with this CPU */
static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
{
- u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
+ int cache_id = get_cpu_cacheinfo_id(cpu, 3);
+
+ if (cache_id < 0)
+ return -ENOENT;
lockdep_assert_cpus_held();
--
2.43.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-02 14:37 [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id() Andre Przywara
@ 2026-09-07 12:59 ` Ben Horgan
2026-09-07 13:14 ` Andre Przywara
2026-09-16 9:49 ` Ben Horgan
2026-09-14 5:50 ` Yin Li
2026-09-14 6:14 ` Gavin Shan
2 siblings, 2 replies; 12+ messages in thread
From: Ben Horgan @ 2026-09-07 12:59 UTC (permalink / raw)
To: Andre Przywara, James Morse
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
Hi Andre,
On 02/09/2026 15:37, Andre Przywara wrote:
> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
> error value.
>
> Check the returned value for this error condition, before passing the
> value on to other code, which would hide the negative number in some high
> value in the unsigned type.
>
> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
This looks good to me. Out of interest what led you to find this?
Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Thanks,
Ben
> ---
> drivers/resctrl/mpam_resctrl.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index 9d223057953ab..a5e661eff86d7 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
> /* Find the L3 cache that has affinity with this CPU */
> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
> {
> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
> +
> + if (cache_id < 0)
> + return -ENOENT;
>
> lockdep_assert_cpus_held();
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-07 12:59 ` Ben Horgan
@ 2026-09-07 13:14 ` Andre Przywara
2026-09-16 9:49 ` Ben Horgan
1 sibling, 0 replies; 12+ messages in thread
From: Andre Przywara @ 2026-09-07 13:14 UTC (permalink / raw)
To: Ben Horgan, James Morse
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
Hi Ben,
thanks for having a look!
On 9/7/26 14:59, Ben Horgan wrote:
> Hi Andre,
>
> On 02/09/2026 15:37, Andre Przywara wrote:
>> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
>> error value.
>>
>> Check the returned value for this error condition, before passing the
>> value on to other code, which would hide the negative number in some high
>> value in the unsigned type.
>>
>> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>
> This looks good to me. Out of interest what led you to find this?
For Yin Li's RFC patch [06/15], I was looking around to find the proper
type for cache-id, and stumbled upon this.
> Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Thanks!
Cheers,
Andre
>
> Thanks,
>
> Ben
>
>> ---
>> drivers/resctrl/mpam_resctrl.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
>> index 9d223057953ab..a5e661eff86d7 100644
>> --- a/drivers/resctrl/mpam_resctrl.c
>> +++ b/drivers/resctrl/mpam_resctrl.c
>> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
>> /* Find the L3 cache that has affinity with this CPU */
>> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
>> {
>> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
>> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
>> +
>> + if (cache_id < 0)
>> + return -ENOENT;
>>
>> lockdep_assert_cpus_held();
>>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-02 14:37 [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id() Andre Przywara
2026-09-07 12:59 ` Ben Horgan
@ 2026-09-14 5:50 ` Yin Li
2026-09-14 6:14 ` Gavin Shan
2 siblings, 0 replies; 12+ messages in thread
From: Yin Li @ 2026-09-14 5:50 UTC (permalink / raw)
To: Andre Przywara, James Morse, Ben Horgan
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin,
linux-arm-kernel, linux-kernel
On 9/2/2026 10:37 PM, Andre Przywara wrote:
> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
> error value.
>
> Check the returned value for this error condition, before passing the
> value on to other code, which would hide the negative number in some high
> value in the unsigned type.
>
> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
> drivers/resctrl/mpam_resctrl.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index 9d223057953ab..a5e661eff86d7 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
> /* Find the L3 cache that has affinity with this CPU */
> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
> {
> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
> +
> + if (cache_id < 0)
> + return -ENOENT;
>
> lockdep_assert_cpus_held();
>
Hi Andre
This looks good to me.
Reviewed-by: Yin Li<yin.li@oss.qualcomm.com>
--
Thx and BRs,
Yin
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-02 14:37 [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id() Andre Przywara
2026-09-07 12:59 ` Ben Horgan
2026-09-14 5:50 ` Yin Li
@ 2026-09-14 6:14 ` Gavin Shan
2026-09-14 6:25 ` Yin Li
2 siblings, 1 reply; 12+ messages in thread
From: Gavin Shan @ 2026-09-14 6:14 UTC (permalink / raw)
To: Andre Przywara, James Morse, Ben Horgan
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
On 9/3/26 12:37 AM, Andre Przywara wrote:
> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
> error value.
>
> Check the returned value for this error condition, before passing the
> value on to other code, which would hide the negative number in some high
> value in the unsigned type.
>
> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
> drivers/resctrl/mpam_resctrl.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
Reviewed-by: Gavin Shan <gshan@redhat.com>
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index 9d223057953ab..a5e661eff86d7 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
> /* Find the L3 cache that has affinity with this CPU */
> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
> {
> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
> +
> + if (cache_id < 0)
> + return -ENOENT;
>
> lockdep_assert_cpus_held();
>
find_l3_equivalent_bitmask() passes @cache_id to find_l3_equivalent_bitmask() as
a 'unsigned long' argument. Actually, it can be 'u32'. It's not directly related
to this patch though.
int mpam_get_cpumask_from_cache_id(unsigned long cache_id, ...);
can be:
int mpam_get_cpumask_from_cache_id(u32 cache_id, ...);
Thanks,
Gavin
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-14 6:14 ` Gavin Shan
@ 2026-09-14 6:25 ` Yin Li
2026-09-14 6:35 ` Gavin Shan
0 siblings, 1 reply; 12+ messages in thread
From: Yin Li @ 2026-09-14 6:25 UTC (permalink / raw)
To: Gavin Shan, Andre Przywara, James Morse, Ben Horgan
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin,
linux-arm-kernel, linux-kernel
On 9/14/2026 2:14 PM, Gavin Shan wrote:
> On 9/3/26 12:37 AM, Andre Przywara wrote:
>> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
>> error value.
>>
>> Check the returned value for this error condition, before passing the
>> value on to other code, which would hide the negative number in some high
>> value in the unsigned type.
>>
>> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>> ---
>> drivers/resctrl/mpam_resctrl.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>
> Reviewed-by: Gavin Shan <gshan@redhat.com>
>
>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/
>> mpam_resctrl.c
>> index 9d223057953ab..a5e661eff86d7 100644
>> --- a/drivers/resctrl/mpam_resctrl.c
>> +++ b/drivers/resctrl/mpam_resctrl.c
>> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
>> /* Find the L3 cache that has affinity with this CPU */
>> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t
>> tmp_cpumask)
>> {
>> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
>> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
>> +
>> + if (cache_id < 0)
>> + return -ENOENT;
>> lockdep_assert_cpus_held();
>
> find_l3_equivalent_bitmask() passes @cache_id to
> find_l3_equivalent_bitmask() as
> a 'unsigned long' argument. Actually, it can be 'u32'. It's not directly
> related
> to this patch though.
>
> int mpam_get_cpumask_from_cache_id(unsigned long cache_id, ...);
>
> can be:
>
> int mpam_get_cpumask_from_cache_id(u32 cache_id, ...);
>
Hi Gavin,
Thanks for pointing this out. I've made exactly this change in my MPAM
DT series (v2, in preparation) — mpam_get_cpumask_from_cache_id() is
changed from unsigned long to u32 there, along with the related cache-id
variables.
https://lore.kernel.org/all/20260811-mpam-resctrl-dt-knp-support-v1-6-ea6397bead59@oss.qualcomm.com/
I'm about to post v2 of that series and will make sure you're on Cc, in
case you'd like to take a look.
Thanks,
Yin
> Thanks,
> Gavin
>
--
Thx and BRs,
Yin
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-14 6:25 ` Yin Li
@ 2026-09-14 6:35 ` Gavin Shan
2026-09-14 6:45 ` Yin Li
0 siblings, 1 reply; 12+ messages in thread
From: Gavin Shan @ 2026-09-14 6:35 UTC (permalink / raw)
To: Yin Li, Andre Przywara, James Morse, Ben Horgan
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin,
linux-arm-kernel, linux-kernel
Hi Yin,
On 9/14/26 4:25 PM, Yin Li wrote:
> On 9/14/2026 2:14 PM, Gavin Shan wrote:
>> On 9/3/26 12:37 AM, Andre Przywara wrote:
>>> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
>>> error value.
>>>
>>> Check the returned value for this error condition, before passing the
>>> value on to other code, which would hide the negative number in some high
>>> value in the unsigned type.
>>>
>>> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
>>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>>> ---
>>> drivers/resctrl/mpam_resctrl.c | 5 ++++-
>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>
>> Reviewed-by: Gavin Shan <gshan@redhat.com>
>>
>>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/ mpam_resctrl.c
>>> index 9d223057953ab..a5e661eff86d7 100644
>>> --- a/drivers/resctrl/mpam_resctrl.c
>>> +++ b/drivers/resctrl/mpam_resctrl.c
>>> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
>>> /* Find the L3 cache that has affinity with this CPU */
>>> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
>>> {
>>> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
>>> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
>>> +
>>> + if (cache_id < 0)
>>> + return -ENOENT;
>>> lockdep_assert_cpus_held();
>>
>> find_l3_equivalent_bitmask() passes @cache_id to find_l3_equivalent_bitmask() as
>> a 'unsigned long' argument. Actually, it can be 'u32'. It's not directly related
>> to this patch though.
>>
>> int mpam_get_cpumask_from_cache_id(unsigned long cache_id, ...);
>>
>> can be:
>>
>> int mpam_get_cpumask_from_cache_id(u32 cache_id, ...);
>>
>
> Hi Gavin,
>
> Thanks for pointing this out. I've made exactly this change in my MPAM
> DT series (v2, in preparation) — mpam_get_cpumask_from_cache_id() is
> changed from unsigned long to u32 there, along with the related cache-id
> variables.
> https://lore.kernel.org/all/20260811-mpam-resctrl-dt-knp-support-v1-6-ea6397bead59@oss.qualcomm.com/
>
> I'm about to post v2 of that series and will make sure you're on Cc, in
> case you'd like to take a look.
>
Thanks for head-up, please keep me on the cc list. I would like to review
if I get bandwidth, but no promise :)
I noticed RFCv1 series of DT support for MPAM was posted to linux-kernel@vger.kernel.org
instead of linux-arm-kernel@lists.infradead.org. Since MPAM is a arm64 feature, it's
reasonable to post the patches to linux-arm-kernel@lists.infradead.org at the same time.
MAINTAINERS doesn't indicates a maillist for MPAM patches in section "MPAM DRIVER". I guess it
would be something worthy to be added.
Thanks,
Gavin
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-14 6:35 ` Gavin Shan
@ 2026-09-14 6:45 ` Yin Li
0 siblings, 0 replies; 12+ messages in thread
From: Yin Li @ 2026-09-14 6:45 UTC (permalink / raw)
To: Gavin Shan, Andre Przywara, James Morse, Ben Horgan
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin,
linux-arm-kernel, linux-kernel
On 9/14/2026 2:35 PM, Gavin Shan wrote:
> Hi Yin,
>
> On 9/14/26 4:25 PM, Yin Li wrote:
>> On 9/14/2026 2:14 PM, Gavin Shan wrote:
>>> On 9/3/26 12:37 AM, Andre Przywara wrote:
>>>> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
>>>> error value.
>>>>
>>>> Check the returned value for this error condition, before passing the
>>>> value on to other code, which would hide the negative number in some
>>>> high
>>>> value in the unsigned type.
>>>>
>>>> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB'
>>>> resource")
>>>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>>>> ---
>>>> drivers/resctrl/mpam_resctrl.c | 5 ++++-
>>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>>>
>>>
>>> Reviewed-by: Gavin Shan <gshan@redhat.com>
>>>
>>>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/
>>>> mpam_resctrl.c
>>>> index 9d223057953ab..a5e661eff86d7 100644
>>>> --- a/drivers/resctrl/mpam_resctrl.c
>>>> +++ b/drivers/resctrl/mpam_resctrl.c
>>>> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
>>>> /* Find the L3 cache that has affinity with this CPU */
>>>> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t
>>>> tmp_cpumask)
>>>> {
>>>> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
>>>> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
>>>> +
>>>> + if (cache_id < 0)
>>>> + return -ENOENT;
>>>> lockdep_assert_cpus_held();
>>>
>>> find_l3_equivalent_bitmask() passes @cache_id to
>>> find_l3_equivalent_bitmask() as
>>> a 'unsigned long' argument. Actually, it can be 'u32'. It's not
>>> directly related
>>> to this patch though.
>>>
>>> int mpam_get_cpumask_from_cache_id(unsigned long cache_id, ...);
>>>
>>> can be:
>>>
>>> int mpam_get_cpumask_from_cache_id(u32 cache_id, ...);
>>>
>>
>> Hi Gavin,
>>
>> Thanks for pointing this out. I've made exactly this change in my MPAM
>> DT series (v2, in preparation) — mpam_get_cpumask_from_cache_id() is
>> changed from unsigned long to u32 there, along with the related cache-id
>> variables.
>> https://lore.kernel.org/all/20260811-mpam-resctrl-dt-knp-support-v1-6-
>> ea6397bead59@oss.qualcomm.com/
>>
>> I'm about to post v2 of that series and will make sure you're on Cc, in
>> case you'd like to take a look.
>>
>
> Thanks for head-up, please keep me on the cc list. I would like to review
> if I get bandwidth, but no promise :)
>
Hi Gavin,
Thanks, will keep you on Cc for v2.
> I noticed RFCv1 series of DT support for MPAM was posted to linux-
> kernel@vger.kernel.org
> instead of linux-arm-kernel@lists.infradead.org. Since MPAM is a arm64
> feature, it's
> reasonable to post the patches to linux-arm-kernel@lists.infradead.org
> at the same time.
>
Good point on linux-arm-kernel — I'll make sure v2 goes to
linux-arm-kernel@lists.infradead.org as well.
> MAINTAINERS doesn't indicates a maillist for MPAM patches in section
> "MPAM DRIVER". I guess it
> would be something worthy to be added.
>
And agreed that the MPAM DRIVER entry in MAINTAINERS is missing an "L:"
mailing list, which is likely why get_maintainer.pl didn't pick up
linux-arm-kernel. I'll note this in the v2 cover letter so the MPAM
maintainers can decide whether to add it.
Thx and BRs,
Yin
> Thanks,
> Gavin
>
>
--
Thx and BRs,
Yin
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-07 12:59 ` Ben Horgan
2026-09-07 13:14 ` Andre Przywara
@ 2026-09-16 9:49 ` Ben Horgan
2026-09-16 11:24 ` Gavin Shan
2026-09-16 13:34 ` Andre Przywara
1 sibling, 2 replies; 12+ messages in thread
From: Ben Horgan @ 2026-09-16 9:49 UTC (permalink / raw)
To: Andre Przywara, James Morse
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
Hi Andre,
On 07/09/2026 13:59, Ben Horgan wrote:
> Hi Andre,
>
> On 02/09/2026 15:37, Andre Przywara wrote:
>> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
>> error value.
>>
>> Check the returned value for this error condition, before passing the
>> value on to other code, which would hide the negative number in some high
>> value in the unsigned type.
>>
>> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>
> This looks good to me. Out of interest what led you to find this?
>
> Reviewed-by: Ben Horgan <ben.horgan@arm.com>
I seem to have been a bit hasty here.
Sashiko points out at [1] that 0xFFFFFFFF is the only value we were previously considering invalid
and that the value coming from dt or acpi can provid other valid values that would after this patch
be considered invalid.
[1] https://sashiko.dev/#/patchset/20260902143757.3469690-1-andre.przywara%40arm.com
Thanks,
Ben>
> Thanks,
>
> Ben
>
>> ---
>> drivers/resctrl/mpam_resctrl.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
>> index 9d223057953ab..a5e661eff86d7 100644
>> --- a/drivers/resctrl/mpam_resctrl.c
>> +++ b/drivers/resctrl/mpam_resctrl.c
>> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
>> /* Find the L3 cache that has affinity with this CPU */
>> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
>> {
>> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
>> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
>> +
>> + if (cache_id < 0)
>> + return -ENOENT;
>>
>> lockdep_assert_cpus_held();
>>
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-16 9:49 ` Ben Horgan
@ 2026-09-16 11:24 ` Gavin Shan
2026-09-16 13:34 ` Andre Przywara
1 sibling, 0 replies; 12+ messages in thread
From: Gavin Shan @ 2026-09-16 11:24 UTC (permalink / raw)
To: Ben Horgan, Andre Przywara, James Morse
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
On 9/16/26 7:49 PM, Ben Horgan wrote:
> Hi Andre,
>
> On 07/09/2026 13:59, Ben Horgan wrote:
>> Hi Andre,
>>
>> On 02/09/2026 15:37, Andre Przywara wrote:
>>> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
>>> error value.
>>>
>>> Check the returned value for this error condition, before passing the
>>> value on to other code, which would hide the negative number in some high
>>> value in the unsigned type.
>>>
>>> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
>>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>>
>> This looks good to me. Out of interest what led you to find this?
>>
>> Reviewed-by: Ben Horgan <ben.horgan@arm.com>
>
> I seem to have been a bit hasty here.
>
> Sashiko points out at [1] that 0xFFFFFFFF is the only value we were previously considering invalid
> and that the value coming from dt or acpi can provid other valid values that would after this patch
> be considered invalid.
>
> [1] https://sashiko.dev/#/patchset/20260902143757.3469690-1-andre.przywara%40arm.com
>
I think Sashiko is correct that the check 'if (cache_id < 0) return -ENOENT' is incorrect
because only -1 is a invalid ID. The correct check would be:
u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
if (cache_id = UINT_MAX)
return -ENOENT;
Or
int cache_id = get_cpu_cacheinfo_id(cpu, 3);
if (cache_id == -1)
return -ENOENT;
Thanks,
Gavin
> Thanks,
>
> Ben>
>> Thanks,
>>
>> Ben
>>
>>> ---
>>> drivers/resctrl/mpam_resctrl.c | 5 ++++-
>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
>>> index 9d223057953ab..a5e661eff86d7 100644
>>> --- a/drivers/resctrl/mpam_resctrl.c
>>> +++ b/drivers/resctrl/mpam_resctrl.c
>>> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
>>> /* Find the L3 cache that has affinity with this CPU */
>>> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
>>> {
>>> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
>>> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
>>> +
>>> + if (cache_id < 0)
>>> + return -ENOENT;
>>>
>>> lockdep_assert_cpus_held();
>>>
>>
>>
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-16 9:49 ` Ben Horgan
2026-09-16 11:24 ` Gavin Shan
@ 2026-09-16 13:34 ` Andre Przywara
2026-09-16 14:59 ` Ben Horgan
1 sibling, 1 reply; 12+ messages in thread
From: Andre Przywara @ 2026-09-16 13:34 UTC (permalink / raw)
To: Ben Horgan, James Morse
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
Hi,
On 9/16/26 11:49, Ben Horgan wrote:
> Hi Andre,
>
> On 07/09/2026 13:59, Ben Horgan wrote:
>> Hi Andre,
>>
>> On 02/09/2026 15:37, Andre Przywara wrote:
>>> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
>>> error value.
>>>
>>> Check the returned value for this error condition, before passing the
>>> value on to other code, which would hide the negative number in some high
>>> value in the unsigned type.
>>>
>>> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
>>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>>
>> This looks good to me. Out of interest what led you to find this?
>>
>> Reviewed-by: Ben Horgan <ben.horgan@arm.com>
>
> I seem to have been a bit hasty here.
>
> Sashiko points out at [1] that 0xFFFFFFFF is the only value we were previously considering invalid
> and that the value coming from dt or acpi can provid other valid values that would after this patch
> be considered invalid.
Fair, and I can easily change the check to only check explicitly for -1.
But this is somewhat broken already, right? I mean the return type for
the existing get_cpu_cacheinfo_id() has always been "int". It looks like
this comes from the x86 world, where the cache IDs never get that large?
I can have a deeper look, but my gut feeling is that this is practically
irrelevant, since we barely see Aff3 at all, not to mention high values
of it.
Cheers,
Andre
>
> [1] https://sashiko.dev/#/patchset/20260902143757.3469690-1-andre.przywara%40arm.com
>
> Thanks,
>
> Ben>
>> Thanks,
>>
>> Ben
>>
>>> ---
>>> drivers/resctrl/mpam_resctrl.c | 5 ++++-
>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
>>> index 9d223057953ab..a5e661eff86d7 100644
>>> --- a/drivers/resctrl/mpam_resctrl.c
>>> +++ b/drivers/resctrl/mpam_resctrl.c
>>> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
>>> /* Find the L3 cache that has affinity with this CPU */
>>> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
>>> {
>>> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
>>> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
>>> +
>>> + if (cache_id < 0)
>>> + return -ENOENT;
>>>
>>> lockdep_assert_cpus_held();
>>>
>>
>>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
2026-09-16 13:34 ` Andre Przywara
@ 2026-09-16 14:59 ` Ben Horgan
0 siblings, 0 replies; 12+ messages in thread
From: Ben Horgan @ 2026-09-16 14:59 UTC (permalink / raw)
To: Andre Przywara, James Morse
Cc: Reinette Chatre, Fenghua Yu, Tony Luck, Dave Martin, Yin Li,
linux-arm-kernel, linux-kernel
Hi Andre,
On 16/09/2026 14:34, Andre Przywara wrote:
> Hi,
>
> On 9/16/26 11:49, Ben Horgan wrote:
>> Hi Andre,
>>
>> On 07/09/2026 13:59, Ben Horgan wrote:
>>> Hi Andre,
>>>
>>> On 02/09/2026 15:37, Andre Przywara wrote:
>>>> get_cpu_cacheinfo_id() can fail, in which case it returns a negative
>>>> error value.
>>>>
>>>> Check the returned value for this error condition, before passing the
>>>> value on to other code, which would hide the negative number in some high
>>>> value in the unsigned type.
>>>>
>>>> Fixes: 36528c7681b8 ("arm_mpam: resctrl: Add support for 'MB' resource")
>>>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>>>
>>> This looks good to me. Out of interest what led you to find this?
>>>
>>> Reviewed-by: Ben Horgan <ben.horgan@arm.com>
>>
>> I seem to have been a bit hasty here.
>>
>> Sashiko points out at [1] that 0xFFFFFFFF is the only value we were previously considering invalid
>> and that the value coming from dt or acpi can provid other valid values that would after this patch
>> be considered invalid.
>
> Fair, and I can easily change the check to only check explicitly for -1.
>
> But this is somewhat broken already, right? I mean the return type for the existing
> get_cpu_cacheinfo_id() has always been "int". It looks like this comes from the x86 world, where the
> cache IDs never get that large? I can have a deeper look, but my gut feeling is that this is
The cache_id being in the PPTT table is a fairly new addition introduced for PPTT table version 3
and introduced to drivers/acpi/pptt.c as part of the preparations for the MPAM driver at the end of
2025. At this point, it seems I neglected to consider any potential effect on
get_cpu_cacheinfo_id(). The pptt cacheid takes any u32 value apart from 0. I haven't joined all the
dots but I expect there might be some tidying up needed in this area.
> practically irrelevant, since we barely see Aff3 at all, not to mention high values of it.
Does Aff3 effect the cache id on acpi systems?
Thanks,
Ben>
> Cheers,
> Andre
>
>>
>> [1] https://sashiko.dev/#/patchset/20260902143757.3469690-1-andre.przywara%40arm.com
>>
>> Thanks,
>>
>> Ben>
>>> Thanks,
>>>
>>> Ben
>>>
>>>> ---
>>>> drivers/resctrl/mpam_resctrl.c | 5 ++++-
>>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
>>>> index 9d223057953ab..a5e661eff86d7 100644
>>>> --- a/drivers/resctrl/mpam_resctrl.c
>>>> +++ b/drivers/resctrl/mpam_resctrl.c
>>>> @@ -786,7 +786,10 @@ static u32 get_mba_min(struct mpam_props *cprops)
>>>> /* Find the L3 cache that has affinity with this CPU */
>>>> static int find_l3_equivalent_bitmask(int cpu, cpumask_var_t tmp_cpumask)
>>>> {
>>>> - u32 cache_id = get_cpu_cacheinfo_id(cpu, 3);
>>>> + int cache_id = get_cpu_cacheinfo_id(cpu, 3);
>>>> +
>>>> + if (cache_id < 0)
>>>> + return -ENOENT;
>>>> lockdep_assert_cpus_held();
>>>>
>>>
>>>
>>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-09-16 14:59 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-02 14:37 [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id() Andre Przywara
2026-09-07 12:59 ` Ben Horgan
2026-09-07 13:14 ` Andre Przywara
2026-09-16 9:49 ` Ben Horgan
2026-09-16 11:24 ` Gavin Shan
2026-09-16 13:34 ` Andre Przywara
2026-09-16 14:59 ` Ben Horgan
2026-09-14 5:50 ` Yin Li
2026-09-14 6:14 ` Gavin Shan
2026-09-14 6:25 ` Yin Li
2026-09-14 6:35 ` Gavin Shan
2026-09-14 6:45 ` Yin Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®