From: Reinette Chatre <reinette.chatre@intel.com>
To: Chen Yu <yu.c.chen@intel.com>, <tony.luck@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>,
<fenghuay@nvidia.com>, <babu.moger@amd.com>,
<anil.keshavamurthy@broadcom.com>, <chen.yu@linux.dev>
Subject: Re: [PATCH v5 10/10] x86/resctrl: Enable read L3 occupancy via MMIO
Date: Fri, 10 Jul 2026 16:55:31 -0700 [thread overview]
Message-ID: <a34d5b7a-f378-466a-96fc-eddb5d6919c9@intel.com> (raw)
In-Reply-To: <f8c8b8e193ab594da9bb6275cc1e1fe462040082.1782866200.git.yu.c.chen@intel.com>
Hi Chenyu,
On 7/1/26 6:47 AM, Chen Yu wrote:
> Implement the erdt_mon_read().
>
> Use the CMRC (Cache Monitoring Registers for CPU Agents Description)
> ACPI sub-table to read LLC occupancy counters for each RMID via MMIO
> when ERDT is enabled. This CMRC information is stored in the
> rdt_hw_l3_mon_domain, which could be accessed directly.
>
> Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> ---
> v4->v5:
> Split into a smaller patch; no functional code changes in the low level
> implementation, but read from the CMRC information stored per domain .
> ---
> arch/x86/kernel/cpu/resctrl/erdt.c | 63 ++++++++++++++++++++++++++++++
> 1 file changed, 63 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/erdt.c b/arch/x86/kernel/cpu/resctrl/erdt.c
> index 1114ad4e3b42..f897c7e247bb 100644
> --- a/arch/x86/kernel/cpu/resctrl/erdt.c
> +++ b/arch/x86/kernel/cpu/resctrl/erdt.c
> @@ -36,6 +36,9 @@ static u32 valid_subtbl_mask;
>
> bool erdt_support_features(int flag)
> {
> + if (flag == X86_FEATURE_CQM_OCCUP_LLC)
> + return valid_subtbl_mask & BIT(ACPI_ERDT_TYPE_CMRC);
> +
> return false;
> }
>
> @@ -57,8 +60,68 @@ int erdt_get_max_rmid(int cpu)
> return -1;
> }
>
> +static void __iomem *cmrc_index_function_1(struct erdt_domain_info *d,
> + struct acpi_erdt_cmrc *cmrc, int rmid)
> +{
> + u16 clump_size, stride_size;
> + void __iomem *vaddr;
> +
> + clump_size = cmrc->clump_size;
> + stride_size = cmrc->clump_stride;
> +
> + /*
> + * MMIO_ADDRESS_for_RMID# = CMRC Base +
> + * (RMID / ClumpSize) * Stride +
> + * (RMID % ClumpSize) * 8
> + */
> + vaddr = d->base[ERDT_MMIO_CMRC_BASE] +
> + (rmid / clump_size) * stride_size +
> + (rmid % clump_size) * 8;
> +
> + return vaddr;
> +}
> +
> +static int erdt_read_l3_occupancy(struct erdt_domain_info *d, int rmid, u64 *val)
> +{
> + struct acpi_erdt_cmrc *cmrc;
> + void __iomem *vaddr;
> + u64 l3_cmt_count;
> + u32 offset;
> +
> + cmrc = d->cmrc;
> + if (!cmrc)
> + return -EIO;
> +
> + offset = (rmid / cmrc->clump_size) * cmrc->clump_stride +
> + (rmid % cmrc->clump_size) * 8;
This is the same function open coded in cmrc_index_function_1() - can it just be coded once
and then re-used?
> + /* Overflow of cmt_reg_size * SZ_4K already validated in erdt_ioremap(). */
> + if (offset + sizeof(u64) > (u32)cmrc->cmt_reg_size * SZ_4K)
> + return -EINVAL;
> +
> + vaddr = cmrc_index_function_1(d, cmrc, rmid);
> +
> + l3_cmt_count = readq(vaddr);
> + if (l3_cmt_count & UNAVAILABLE_COUNTER)
> + return -EINVAL;
> +
> + *val = l3_cmt_count * cmrc->up_scale;
> +
> + return 0;
> +}
> +
Reinette
prev parent reply other threads:[~2026-07-10 23:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 13:44 [PATCH v5 00/10] Introduce MMIO-based CMT access for Enhanced RDT Chen Yu
2026-07-01 13:45 ` [PATCH v5 01/10] x86/resctrl: Require 64-bit x86 for resctrl support Chen Yu
2026-07-01 13:45 ` [PATCH v5 02/10] x86/topology: Export topo_lookup_cpuid() for resctrl use Chen Yu
2026-07-10 23:35 ` Reinette Chatre
2026-07-14 15:45 ` Chen, Yu C
2026-07-01 13:45 ` [PATCH v5 03/10] x86/resctrl: Parse ACPI ERDT table and save CACD cpumask for RMDD domains Chen Yu
2026-07-10 23:42 ` Reinette Chatre
2026-07-14 15:19 ` Chen, Yu C
2026-07-14 16:13 ` Reinette Chatre
2026-07-14 16:33 ` Chen, Yu C
2026-07-01 13:45 ` [PATCH v5 04/10] x86/resctrl: Attach ACPI ERDT information to L3 mon domain on CPU online Chen Yu
2026-07-10 23:45 ` Reinette Chatre
2026-07-14 8:51 ` Chen, Yu C
2026-07-14 16:13 ` Reinette Chatre
2026-07-14 16:24 ` Chen, Yu C
2026-07-01 13:46 ` [PATCH v5 05/10] x86/resctrl: Parse ACPI CMRC table Chen Yu
2026-07-10 23:46 ` Reinette Chatre
2026-07-14 16:27 ` Chen, Yu C
2026-07-01 13:46 ` [PATCH v5 06/10] x86/resctrl: Replace "msr" in monitoring data identifiers Chen Yu
2026-07-10 23:47 ` Reinette Chatre
2026-07-01 13:46 ` [PATCH v5 07/10] x86/resctrl: Refactor the monitor read function Chen Yu
2026-07-01 13:47 ` [PATCH v5 08/10] fs/resctrl: Do not invoke smp_processor_id() in preemptible context Chen Yu
2026-07-10 23:48 ` Reinette Chatre
2026-07-01 13:47 ` [PATCH v5 09/10] x86/resctrl: Introduce helpers to read L3 occupancy via MMIO Chen Yu
2026-07-10 23:53 ` Reinette Chatre
2026-07-01 13:47 ` [PATCH v5 10/10] x86/resctrl: Enable " Chen Yu
2026-07-10 23:55 ` Reinette Chatre [this message]
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=a34d5b7a-f378-466a-96fc-eddb5d6919c9@intel.com \
--to=reinette.chatre@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=fenghuay@nvidia.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
--cc=yu.c.chen@intel.com \
/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