If a CPU isn't part of the class' affinity, skip onlining it. Otherwise, it
will try to allocate a domain for it that will fault.
An example is when there are 2 memory MSCs with affinities to the first
64 CPUs (32 CPUs for each memory MSC) and 1 L3 cache MSC with affinity
to the first 32 CPUs. When a call back to online CPU 63 for the second
memory MSC is triggered, the function will first check the caches, and
it will fault and return as CPU 63 is not part of the caches' affinity,
without trying to check for the memory MSC. Thus, only 1 memory MSC
will show up, even though there are 2 that could be managed.
Also skip when offlining a CPU that's not part of the class' affinity.
Signed-off-by: Hesham Almatary <hesham.almatary(a)huawei.com>
---
drivers/platform/mpam/mpam_resctrl.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c
index 471fb1a6c7e2..bfc25a8e4f03 100644
--- a/drivers/platform/mpam/mpam_resctrl.c
+++ b/drivers/platform/mpam/mpam_resctrl.c
@@ -1076,6 +1076,9 @@ int mpam_resctrl_online_cpu(unsigned int cpu)
if (!res->class)
continue; // dummy_resource;
+ if (!cpumask_test_cpu(cpu, &res->class->affinity))
+ continue; // This CPU isn't part of the class' affinity;
+
dom = mpam_get_domain_from_cpu(cpu, res);
if (dom) {
cpumask_set_cpu(cpu, &dom->resctrl_dom.cpu_mask);
@@ -1108,6 +1111,9 @@ int mpam_resctrl_offline_cpu(unsigned int cpu)
if (!res->class)
continue; // dummy resource
+ if (!cpumask_test_cpu(cpu, &res->class->affinity))
+ continue; // This CPU isn't part of the class' affinity;
+
d = resctrl_get_domain_from_cpu(cpu, &res->resctrl_res);
dom = container_of(d, struct mpam_resctrl_dom, resctrl_dom);
--
2.25.1