[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240528222006.58283-18-tony.luck@intel.com>
Date: Tue, 28 May 2024 15:20:02 -0700
From: Tony Luck <tony.luck@...el.com>
To: Fenghua Yu <fenghua.yu@...el.com>,
Reinette Chatre <reinette.chatre@...el.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>
Cc: x86@...nel.org,
linux-kernel@...r.kernel.org,
patches@...ts.linux.dev,
Tony Luck <tony.luck@...el.com>
Subject: [PATCH v19 17/20] x86/resctrl: Update CPU sanity checks when reading RMID counters
When reading from a single domain the existing check that current CPU is
in the domain is accurate.
But when summing across multiple domains that share an L3 cache instance
it is sufficient to run on any CPU in the shared_map for that cache.
Split the check into the two separate cases.
Signed-off-by: Tony Luck <tony.luck@...el.com>
---
arch/x86/kernel/cpu/resctrl/monitor.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index c9dd6ec68fcd..e7a8e96821e5 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -308,9 +308,6 @@ static int resctrl_arch_rmid_read_one(struct rdt_resource *r, struct rdt_mon_dom
resctrl_arch_rmid_read_context_check();
- if (!cpumask_test_cpu(smp_processor_id(), &d->hdr.cpu_mask))
- return -EINVAL;
-
ret = __rmid_read(cpu, rmid, eventid, &msr_val);
if (ret)
return ret;
@@ -338,8 +335,15 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d,
int ret;
*val = 0;
- if (!sum)
+ if (!sum) {
+ if (!cpumask_test_cpu(cpu, &d->hdr.cpu_mask))
+ return -EINVAL;
+
return resctrl_arch_rmid_read_one(r, d, cpu, rmid, eventid, val);
+ }
+
+ if (!cpumask_test_cpu(cpu, &ci->shared_cpu_map))
+ return -EINVAL;
list_for_each_entry(d, &r->mon_domains, hdr.list) {
if (d->ci->id != ci->id)
--
2.45.0
Powered by blists - more mailing lists