[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ba1e8bc8-a3b3-411a-85b9-c20cc23d8adb@intel.com>
Date: Fri, 3 Oct 2025 16:56:10 -0700
From: Reinette Chatre <reinette.chatre@...el.com>
To: Tony Luck <tony.luck@...el.com>, Fenghua Yu <fenghuay@...dia.com>, "Maciej
Wieczor-Retman" <maciej.wieczor-retman@...el.com>, Peter Newman
<peternewman@...gle.com>, James Morse <james.morse@....com>, Babu Moger
<babu.moger@....com>, Drew Fustini <dfustini@...libre.com>, Dave Martin
<Dave.Martin@....com>, Chen Yu <yu.c.chen@...el.com>
CC: <x86@...nel.org>, <linux-kernel@...r.kernel.org>,
<patches@...ts.linux.dev>
Subject: Re: [PATCH v11 18/31] fs/resctrl: Refactor L3 specific parts of
__mon_event_count()
Hi Tony,
On 9/25/25 1:03 PM, Tony Luck wrote:
> The "MBM counter assignment" and "reset counter on first read" features
> are only applicable to the RDT_RESOURCE_L3 resource.
>
> Add a check for the RDT_RESOURCE_L3 resource.
Why?
"Add a check for the RDT_RESOURCE_L3 resource" can be seen from code.
>
> Signed-off-by: Tony Luck <tony.luck@...el.com>
> ---
> fs/resctrl/monitor.c | 38 ++++++++++++++++++++------------------
> 1 file changed, 20 insertions(+), 18 deletions(-)
>
> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
> index 1eb054749d20..d484983c0f02 100644
> --- a/fs/resctrl/monitor.c
> +++ b/fs/resctrl/monitor.c
> @@ -453,27 +453,29 @@ static int __mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read *rr)
> if (!cpu_on_correct_domain(rr))
> return -EINVAL;
>
> - if (!domain_header_is_valid(rr->hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3))
> - return -EINVAL;
> - d = container_of(rr->hdr, struct rdt_l3_mon_domain, hdr);
> -
> - if (rr->is_mbm_cntr) {
> - cntr_id = mbm_cntr_get(rr->r, d, rdtgrp, rr->evt->evtid);
> - if (cntr_id < 0) {
> - rr->err = -ENOENT;
> + if (rr->r->rid == RDT_RESOURCE_L3) {
> + if (!domain_header_is_valid(rr->hdr, RESCTRL_MON_DOMAIN, RDT_RESOURCE_L3))
> return -EINVAL;
This snippet keeps moving around but it remains problematic from what I can tell since rr->hdr
can still be NULL here.
> + d = container_of(rr->hdr, struct rdt_l3_mon_domain, hdr);
> +
> + if (rr->is_mbm_cntr) {
> + cntr_id = mbm_cntr_get(rr->r, d, rdtgrp, rr->evt->evtid);
> + if (cntr_id < 0) {
> + rr->err = -ENOENT;
> + return -EINVAL;
> + }
> }
> - }
>
> - if (rr->first) {
> - if (rr->is_mbm_cntr)
> - resctrl_arch_reset_cntr(rr->r, d, closid, rmid, cntr_id, rr->evt->evtid);
> - else
> - resctrl_arch_reset_rmid(rr->r, d, closid, rmid, rr->evt->evtid);
> - m = get_mbm_state(d, closid, rmid, rr->evt->evtid);
> - if (m)
> - memset(m, 0, sizeof(struct mbm_state));
> - return 0;
> + if (rr->first) {
> + if (rr->is_mbm_cntr)
> + resctrl_arch_reset_cntr(rr->r, d, closid, rmid, cntr_id, rr->evt->evtid);
> + else
> + resctrl_arch_reset_rmid(rr->r, d, closid, rmid, rr->evt->evtid);
> + m = get_mbm_state(d, closid, rmid, rr->evt->evtid);
> + if (m)
> + memset(m, 0, sizeof(struct mbm_state));
> + return 0;
> + }
> }
__mon_event_count() is now unreasonably complicated. One motivation from changelog is because
"MBM counter assignment is only applicable to RDT_RESOURCE_L3" but then the change proceeds
to only add a RDT_RESOURCE_L3 check in some parts of __mon_event_count() that deals
with counter assignment and leaves other parts to rely on rmid_read properties. It also
fails to mention or make explicit that all the special SNC handling is only applicable to
L3 and leaves that code to seemingly be generic and reader needs to be very familiar with
the code to know differently. I find SNC already a challenge and find this to increase that
complexity unnecessarily.
PERF_PKG only needs to reach a handful of lines in __mon_event_count() to read a counter.
I thus think the best way forward is to split __mon_event_count() and move all the L3 code
into its own function.
Reinette
Powered by blists - more mailing lists