From: Reinette Chatre <reinette.chatre@intel.com>
To: Barret Rhoden <brho@google.com>, Tony Luck <tony.luck@intel.com>
Cc: Dave Martin <Dave.Martin@arm.com>,
James Morse <james.morse@arm.com>, <linux-kernel@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH] x86/resctrl: avoid divide by 0 num_rmid
Date: Tue, 22 Jul 2025 11:19:58 -0700 [thread overview]
Message-ID: <c4518fe2-dce3-46d1-8d79-cd63377bdcad@intel.com> (raw)
In-Reply-To: <20250721180051.3645697-1-brho@google.com>
Hi Barret,
On 7/21/25 11:00 AM, Barret Rhoden wrote:
> x86_cache_max_rmid's default is -1. If the hardware or VM doesn't set
> the right cpuid bits, num_rmid can be 0.
>
> Signed-off-by: Barret Rhoden <brho@google.com>
>
> ---
> I ran into this on a VM on granite rapids. I guess the VMM told the
> kernel it was a GNR, but didn't set all the cache/rsctl bits.
>
The -1 default of x86_cache_max_rmid is assigned if the hardware does not
support *any* L3 monitoring. Specifically:
resctrl_cpu_detect():
if (!cpu_has(c, X86_FEATURE_CQM_LLC)) {
c->x86_cache_max_rmid = -1;
...
}
The function modified by this patch, rdt_get_mon_l3_config() only runs if
the hardware supports one or more of the L3 monitoring sub-features
(X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_TOTAL, or
X86_FEATURE_CQM_MBM_LOCAL) that depend on X86_FEATURE_CQM_LLC per cpuid_deps[].
I tried to reproduce the issue on real hardware by using clearcpuid to
disable X86_FEATURE_CQM_LLC and the CPUID dependencies did the right thing
by automatically disabling X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_MBM_TOTAL,
X86_FEATURE_CQM_MBM_LOCAL, not running rdt_get_mon_l3_config() at all, and
not even attempt to enumerate any of the L3 monitoring details.
What are the symptoms when you encounter this issue?
Would it be possible to send me the CPUID flags of leaf 7, subleaf 0 as
well as all sub-leaves of leaf 0xF?
Could you please also elaborate what the impact of this issue is? Is this
a VM that has been released with many users impacted or something encountered
during development of this VM?
> arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
> index c261558276cd..226dee05f96e 100644
> --- a/arch/x86/kernel/cpu/resctrl/monitor.c
> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c
> @@ -359,6 +359,12 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)
> else if (mbm_offset > MBM_CNTR_WIDTH_OFFSET_MAX)
> pr_warn("Ignoring impossible MBM counter offset\n");
>
> + if (r->num_rmid < 1) {
> + pr_warn("Invalid num_rmid %d, cach_max_rmid was %d\n",
> + r->num_rmid, boot_cpu_data.x86_cache_max_rmid);
> + r->num_rmid = 1;
I do not think enumeration of this feature should proceed/succeed if there clearly
is a configuration issue.
> + }
> +
> /*
> * A reasonable upper limit on the max threshold is the number
> * of lines tagged per RMID if all RMIDs have the same number of
Reinette
next prev parent reply other threads:[~2025-07-22 18:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-21 18:00 [PATCH] x86/resctrl: avoid divide by 0 num_rmid Barret Rhoden
2025-07-22 18:19 ` Reinette Chatre [this message]
2025-07-22 18:51 ` Barret Rhoden
2025-07-22 21:16 ` Reinette Chatre
2025-07-22 21:33 ` 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=c4518fe2-dce3-46d1-8d79-cd63377bdcad@intel.com \
--to=reinette.chatre@intel.com \
--cc=Dave.Martin@arm.com \
--cc=brho@google.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.