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

From: Reinette Chatre

Date: Wed Nov 25 2026 - 16:13:46 EST


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?

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.

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.

> + }
> +}
> +
> static int __cntr_id_read(u32 cntr_id, u64 *val)
> {
> struct msr msr_val = {

Reinette