[RFC PATCH 10/20] x86/intel_rdt: Let resctrl change the resources's num_closid
From: James Morse
Date: Fri Aug 24 2018 - 06:46:23 EST
Today we switch between different alloc_enabled resources which
have differing preset num_closid to account for CDP.
We want to merge these illusionary caches together, at which
point something needs to change the resctrl's view of num_closid.
The arch code now has its own idea of how many closids there are,
and as the two configurations for one rdtgroup is part of resctrl's
ABI we should get resctrl to change it.
We change the num_closid on the l2/l3 resources, which aren't
yet in use when cdp is enabled, then change them back afterwards.
Once we merge illusionary caches, resctrl will see the value it
changed here.
Signed-off-by: James Morse <james.morse@xxxxxxx>
---
arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index 58dceaad6863..e2a9202674f3 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -1149,16 +1149,36 @@ int resctrl_arch_set_cdp_enabled(bool enable)
static int try_to_enable_cdp(int level)
{
+ int ret;
struct rdt_resource *r = &rdt_resources_all[level].resctrl;
+ struct rdt_resource *l3 = &rdt_resources_all[RDT_RESOURCE_L3].resctrl;
+ struct rdt_resource *l2 = &rdt_resources_all[RDT_RESOURCE_L2].resctrl;
if (!r->cdp_capable)
return -EINVAL;
+ if (r->cdp_enabled)
+ return 0;
- return resctrl_arch_set_cdp_enabled(true);
+ ret = resctrl_arch_set_cdp_enabled(true);
+ if (!ret) {
+ if (l2->cdp_enabled)
+ l2->num_closid /= 2;
+ if (l3->cdp_enabled)
+ l3->num_closid /= 2;
+ }
+
+ return ret;
}
static void cdp_disable_all(void)
{
+ struct rdt_resource *l2 = &rdt_resources_all[RDT_RESOURCE_L2].resctrl;
+ struct rdt_resource *l3 = &rdt_resources_all[RDT_RESOURCE_L3].resctrl;
+
+ if (l2->cdp_enabled)
+ l2->num_closid *= 2;
+ if (l3->cdp_enabled)
+ l3->num_closid *= 2;
resctrl_arch_set_cdp_enabled(false);
}
--
2.18.0