Re: [PATCH v10 08/12] x86/resctrl: Refactor the monitor read function
From: Chen Yu
Date: Sun Nov 29 2026 - 05:23:52 EST
Hi Reinette,
On Wed, Nov 25, 2026 at 11:11:41AM -0800, Reinette Chatre wrote:
>
> Hi Chenyu,
>
> Could you please move this patch to be right before #12 "x86/resctrl: Add MMIO-based
> LLC occupancy monitoring support", the consumer of the refactor?
>
OK, let me move it in next version.
> 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;
> 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.
thanks,
Chenyu
> > + }
> > +}
> > +
> > static int __cntr_id_read(u32 cntr_id, u64 *val)
> > {
> > struct msr msr_val = {
>
> Reinette