Re: [PATCH v10 08/12] x86/resctrl: Refactor the monitor read function

From: Reinette Chatre

Date: Wed Dec 02 2026 - 14:47:10 EST


Hi Chenyu,

On 11/29/26 2:25 AM, Chen Yu wrote:
> On Wed, Nov 25, 2026 at 11:11:41AM -0800, Reinette Chatre wrote:
>> On 11/5/26 2:09 AM, Chen Yu wrote:

...

>>> @@ -279,6 +273,22 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr,
>>> return ret;
>>> }
>>>
>>> +int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain_hdr *hdr,
>>> + u32 unused, u32 rmid, enum resctrl_event_id eventid,
>>> + void *arch_priv, u64 *val, void *ignored)
>>> +{
>>> + resctrl_arch_rmid_read_context_check();
>>> +
>>> + switch (r->rid) {
>>> + case RDT_RESOURCE_L3:
>>> + return arch_l3_read_event(r, hdr, rmid, eventid, val);
>>> + case RDT_RESOURCE_PERF_PKG:
>>> + return intel_aet_read_event(hdr->id, rmid, arch_priv, val);
>>> + default:
>>> + return -EINVAL;
>>
>> An invalid resource is a driver bug and a permanent failure. The return value
>> here is translated to a text string displayed to user space: -EINVAL is translated
>> to "Unavailable" while -EIO is translated to "Error". Since this is a permanent
>> failure, -EIO looks more appropriate. Since it is a driver bug a WARN_ON_ONCE()
>> also looks appropriate.
>>
>
> OK, let me change it to
> default:
> WARN_ON_ONCE(ret);
> return -EIO;

I am not able to follow where "ret" comes from, but that is the idea, yes.

>
>> This highlights an inconsistency between fs and arch here. The domain_header_is_valid()
>> check in earlier hunk returns -EINVAL, when it should really be -EIO. Fortunately
>> the fs __l3_mon_event_count() does the same check and returns -EIO correctly. The
>> return when domain_header_is_valid() fails could be changed to -EIO as part of this
>> to make it all consistent but is not required.
>>
>
> Do you mean the following:
> if (!domain_header_is_valid(rr->hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3)) {
> rr->err = -EIO;
> return -EINVAL;
> }
>
> The error message displayed to userspace is EIO, and here it should also return -EIO for consistency.
> Let me change it in the next version.
Thank you very much.

Reinette