From: Gavin Shan <gshan@redhat.com>
To: Andre Przywara <andre.przywara@arm.com>,
Ben Horgan <ben.horgan@arm.com>,
James Morse <james.morse@arm.com>
Cc: Reinette Chatre <reinette.chatre@intel.com>,
Fenghua Yu <fenghuay@nvidia.com>, Tony Luck <tony.luck@intel.com>,
Dave Martin <Dave.Martin@arm.com>,
Yin Li <yin.li@oss.qualcomm.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm_mpam: resctrl: Catch and propagate error from get_cpu_cacheinfo_id()
Date: Thu, 17 Sep 2026 15:56:24 +1000 [thread overview]
Message-ID: <dc160a37-5413-4dc0-bda9-ce75c388f665@redhat.com> (raw)
In-Reply-To: <4f35abf6-6dac-4c60-9ece-c1af02a98c9c@arm.com>
On 9/16/26 11:34 PM, Andre Przywara wrote:
> On 9/16/26 11:49, Ben Horgan wrote:
>> On 07/09/2026 13:59, Ben Horgan wrote:
>>> 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.
>
I guess we also can exploit CACHE_ID flag in struct cacheinfo::attributes.
struct cacheinfo::id is valid only when CACHE_ID flag is set. So we would
introduce our own helper as below, where an extra return value to indicate
the (returned) cached ID is valid or not.
In drivers/resctrl/mpam_internal.h:
/* NULL is returned if struct cacheinfo::attributes don't have CACHE_ID set */
static inline bool mpam_cpu_cache_id(int cpu, int level, unsigned int *id)
{
struct cacheinfo *ci = get_cpu_cacheinfo_level(cpu, level);
if (!ci)
return false;
if (id)
*id = ci->id;
return true;
}
Thanks,
Gavin
next prev parent reply other threads:[~2026-09-17 5:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 14:37 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-17 5:56 ` Gavin Shan [this message]
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
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=dc160a37-5413-4dc0-bda9-ce75c388f665@redhat.com \
--to=gshan@redhat.com \
--cc=Dave.Martin@arm.com \
--cc=andre.przywara@arm.com \
--cc=ben.horgan@arm.com \
--cc=fenghuay@nvidia.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=reinette.chatre@intel.com \
--cc=tony.luck@intel.com \
--cc=yin.li@oss.qualcomm.com \
/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
all inboxes | Powered by JetHome®