The current code will only allocate/online a domain for only one component in a class but not the remaining ones. For example, in a system that has 4 MSCs, each of which controls a memory controller, only one memory controller will appear in the resctrl schemata instead of 4.
This commit iterates over all the components per class (e.g., all MBA MSCs per a memory class) and creates/onlines a domain for each. resctrl will properly show 4 MBAs consequently.
Signed-off-by: Hesham Almatary hesham.almatary@huawei.com --- drivers/platform/mpam/mpam_resctrl.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 6d35b3aea828..9ac256c073e7 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -996,19 +996,9 @@ void resctrl_arch_reset_resources(void) }
static struct mpam_resctrl_dom * -mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res) +mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res, struct mpam_component *comp) { struct mpam_resctrl_dom *dom; - struct mpam_class *class = res->class; - struct mpam_component *comp_iter, *comp; - - comp = NULL; - list_for_each_entry(comp_iter, &class->components, class_list) { - if (cpumask_test_cpu(cpu, &comp_iter->affinity)) { - comp = comp_iter; - break; - } - }
/* cpu with unknown exported component? */ if (WARN_ON_ONCE(!comp)) @@ -1069,6 +1059,7 @@ int mpam_resctrl_online_cpu(unsigned int cpu) int i, err; struct mpam_resctrl_dom *dom; struct mpam_resctrl_res *res; + struct mpam_component *comp_iter;
for (i = 0; i < RDT_NUM_RESOURCES; i++) { res = &mpam_resctrl_exports[i]; @@ -1082,12 +1073,19 @@ int mpam_resctrl_online_cpu(unsigned int cpu) continue; }
- dom = mpam_resctrl_alloc_domain(cpu, res); - if (IS_ERR(dom)) + list_for_each_entry(comp_iter, &res->class->components, class_list) { + + if (!cpumask_test_cpu(cpu, &comp_iter->affinity)) + continue; + + dom = mpam_resctrl_alloc_domain(cpu, res, comp_iter); + if (IS_ERR(dom)) return PTR_ERR(dom); - err = resctrl_online_domain(&res->resctrl_res, &dom->resctrl_dom); - if (err) + + err = resctrl_online_domain(&res->resctrl_res, &dom->resctrl_dom); + if (err) return err; + } }
return resctrl_online_cpu(cpu);