From: "Chen, Yu C" <yu.c.chen@intel.com>
To: Reinette Chatre <reinette.chatre@intel.com>
Cc: <x86@kernel.org>, <linux-kernel@vger.kernel.org>,
<tglx@kernel.org>, <bp@alien8.de>, <mingo@redhat.com>,
<dave.hansen@linux.intel.com>, <hpa@zytor.com>,
<dave.martin@arm.com>, <james.morse@arm.com>,
<fenghuay@nvidia.com>, <babu.moger@amd.com>,
<anil.keshavamurthy@broadcom.com>, <tony.luck@intel.com>,
<chen.yu@linux.dev>
Subject: Re: [PATCH v4 6/6] x86/resctrl: Add support for L3 occupancy monitoring via RMID MMIO read
Date: Wed, 24 Jun 2026 17:00:45 +0800 [thread overview]
Message-ID: <c28dbb49-8166-4931-a30e-85c551105fba@intel.com> (raw)
In-Reply-To: <1308bfd9-e2e8-4dc5-9847-fbb99f177477@intel.com>
Hi Reinette,
On 6/24/2026 12:48 AM, Reinette Chatre wrote:
> Hi Chenyu,
>
> On 6/22/26 10:00 PM, Chen, Yu C wrote:
>> Hi Reinette,
>>
>> On 6/23/2026 5:30 AM, Reinette Chatre wrote:
>>> Hi Chenyu,
>>>>>> diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h
>>>>>> index 97c2f6bc7a5f..9b3b03279dd8 100644
>>>>>> --- a/arch/x86/include/asm/resctrl.h
>>>>>> +++ b/arch/x86/include/asm/resctrl.h
>>>>>> @@ -41,6 +41,8 @@ struct resctrl_pqr_state {
>>>>>> };
>>>>>> bool erdt_enabled(void);
>>>>>> +struct rdt_domain_hdr;
>>>>>> +int erdt_mon_read(struct rdt_domain_hdr *hdr, int ev_id, int rmid, u64 *val);
>>>>>> DECLARE_PER_CPU(struct resctrl_pqr_state, pqr_state);
>>>>>> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
>>>>>> index 90730f0851fa..fe812f7190fc 100644
>>>>>> --- a/arch/x86/kernel/cpu/resctrl/core.c
>>>>>> +++ b/arch/x86/kernel/cpu/resctrl/core.c
>>>>>> @@ -965,7 +965,7 @@ static __init bool get_rdt_mon_resources(void)
>>>>>> bool ret = false;
>>>>>> if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) {
>>>>>> - resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, false, 0, NULL);
>>>>>> + resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID, erdt_enabled(), 0, NULL);
>>>>>> ret = true;
>>>>>> }
>>>>>> if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) {
>>>>>
>>>>> As mentioned in patch #1, when erdt_enabled() is true the enumeration still proceeds to
>>>>> enumerate the monitoring properties via CPUID to discover the number of RMIDs that the
>>>>> *MSR* supports and use it as the maximum RMID (and thus the maximum number of registers)
>>>>> that MMIO supports?
>>>>>
>>>>
>>>> OK, will switch to the maximum RMID exposed by ACPI table, if erdt_enabled() is true.
>>>
>>> I believe the issue is larger than just the RMID enumeration. The CPUID and ACPI enumeration
>>> appears to be fully intertwined. Taking a closer look at what above code does:
>>> it checks *CPUID* whether CMT is enabled and then enables the LLC occupancy event to blindly use
>>> MMIO if ERDT is enabled, irrespective of whether the ERDT tables include a cache monitoring table
>>> or not. How is it guaranteed that if ERDT is enabled that there is a cache monitoring table?
>>> Should it not be the existence of the ACPI cache monitoring table and its properties that
>>> determines whether the LLC occupancy counter using MMIO registers should be enabled?
>>>
>>
>> I see. How about replacing erdt_enabled() with fine-grained helper functions such as
>> erdt_has_cmrc(), erdt_has_mmrc(), and erdt_has_marc()? The latter two will be added
>> later for region-aware MBM/MBA. CMRC, MMRC and MARC are not guaranteed to coexist,
>> so splitting them into separate helpers would offer finer control.
> I am concerned where this is headed since it looks to me as though the plan is to
> sprinkle these finer grained checks throughout resctrl.
The erdt_has_* helper functions would ideally live under
arch/x86/kernel/cpu/resctrl/
rather than the generic fs/resctrl directory, as architecture-specific
code in the
former path is allow to see erdt logic I suppose? That said, since there
are a large
number of such routines, introduce a dedicated helper to handle this
uniformly would
be better(using arch_priv)
> To me this sounds complicated
> and error prone. Consider that resctrl_enable_mon_event() has an arch_priv parameter. To me
> this seems to be the appropriate place for the architecture to give itself the needed
> information about how to read the event.
>
OK, if I understand correctly, we can use the following logic to hide
erdt from monitor read:
/*
* helper to get the erdt's monitor arch_priv,
* defined in erdt.c, NULL in other place.
*
* caller doesn't know about CMRC
*/
void *get_evt_priv(enum resctrl_event_id eventid)
{
if (!erdt_enabled())
return NULL;
switch (eventid) {
case QOS_L3_OCCUP_EVENT_ID:
return cmrc_priv_valid ? &cmrc_priv : NULL;
default:
return NULL;
}
}
arch/x86/kernel/cpu/resctrl/core.c
get_rdt_mon_resources():
if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) {
void *priv = get_evt_priv(QOS_L3_OCCUP_EVENT_ID);
resctrl_enable_mon_event(QOS_L3_OCCUP_EVENT_ID,
priv != NULL, 0, priv);
}
arch/x86/kernel/cpu/resctrl/monitor.c
resctrl_arch_rmid_read():
if (arch_priv)
return erdt_mon_read(hdr, eventid, rmid, val);
return arch_l3_read_event(hdr, rmid, eventid, val, r);
So in this way, there is no event-type checks in the read
path. Adding MMRC later only extends the switch in get_evt_priv().
thanks,
Chenyu
next prev parent reply other threads:[~2026-06-24 9:01 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-13 7:56 [PATCH v4 0/6] Introduce MMIO-based CMT access for Enhanced RDT Chen Yu
2026-06-13 7:56 ` [PATCH v4 1/6] x86/resctrl: Parse ACPI ERDT table and map RMDD domains by L3 cache ID Chen Yu
2026-06-18 23:37 ` Reinette Chatre
2026-06-22 9:07 ` Chen, Yu C
2026-06-22 21:28 ` Reinette Chatre
2026-06-23 6:29 ` Chen, Yu C
2026-06-23 11:43 ` Chen, Yu C
2026-06-23 16:46 ` Reinette Chatre
2026-06-24 4:05 ` Chen, Yu C
2026-06-24 6:04 ` Chen, Yu C
2026-06-24 23:44 ` Reinette Chatre
2026-06-24 23:58 ` Luck, Tony
2026-06-25 0:24 ` Reinette Chatre
2026-06-25 14:59 ` Chen, Yu C
2026-06-25 14:33 ` Chen, Yu C
2026-06-25 15:54 ` Reinette Chatre
2026-06-13 7:57 ` [PATCH v4 2/6] x86/resctrl: Parse ACPI CMRC table Chen Yu
2026-06-13 7:57 ` [PATCH v4 3/6] x86/resctrl: Rename prev_msr to prev_mon_val Chen Yu
2026-06-18 23:39 ` Reinette Chatre
2026-06-22 12:42 ` Chen, Yu C
2026-06-22 21:29 ` Reinette Chatre
2026-06-23 7:48 ` Chen, Yu C
2026-06-23 16:47 ` Reinette Chatre
2026-06-24 6:16 ` Chen, Yu C
2026-06-13 7:57 ` [PATCH v4 4/6] x86/resctrl: Refactor the monitor read function Chen Yu
2026-06-13 7:57 ` [PATCH v4 5/6] fs/resctrl: Do not invoke smp_processor_id() in preemptible context Chen Yu
2026-06-13 7:57 ` [PATCH v4 6/6] x86/resctrl: Add support for L3 occupancy monitoring via RMID MMIO read Chen Yu
2026-06-18 23:40 ` Reinette Chatre
2026-06-22 14:09 ` Chen, Yu C
2026-06-22 21:30 ` Reinette Chatre
2026-06-23 5:00 ` Chen, Yu C
2026-06-23 16:48 ` Reinette Chatre
2026-06-24 9:00 ` Chen, Yu C [this message]
2026-06-24 23:44 ` Reinette Chatre
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=c28dbb49-8166-4931-a30e-85c551105fba@intel.com \
--to=yu.c.chen@intel.com \
--cc=anil.keshavamurthy@broadcom.com \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=chen.yu@linux.dev \
--cc=dave.hansen@linux.intel.com \
--cc=dave.martin@arm.com \
--cc=fenghuay@nvidia.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=reinette.chatre@intel.com \
--cc=tglx@kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/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