Re: [PATCH v1 09/20] x86/resctrl: Abstract and use supports_mba_mbps()

From: Reinette Chatre
Date: Wed Sep 01 2021 - 17:27:36 EST


Hi James,

On 7/29/2021 3:35 PM, James Morse wrote:
To determine whether the mba_mbps option to resctrl should be supported,

mba_mbps -> mba_MBps

resctrl tests the boot cpus' x86_vendor.

CPU


This isn't portable, and needs abstracting behind a helper so this check
can be part of the filesystem code that moves to /fs/.

Re-use the tests set_mba_sc() does to determine if the mba_sc is supported
on this system. An 'alloc_capable' test is added so that this property
isn't implied by 'linear'.

Why can linear not imply alloc_capable? It is a property of a MBA resource so if it is set then it has to be a MBA resource.


Signed-off-by: James Morse <james.morse@xxxxxxx>
---
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index e321ea5de562..4388685548a0 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -1888,17 +1888,26 @@ void rdt_domain_reconfigure_cdp(struct rdt_resource *r)
}
/*
- * Enable or disable the MBA software controller
- * which helps user specify bandwidth in MBps.
* MBA software controller is supported only if
* MBM is supported and MBA is in linear scale.
*/
+static bool supports_mba_mbps(void)
+{
+ struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl;
+
+ return (is_mbm_enabled() &&
+ r->alloc_capable && is_mba_linear());

As mentioned above I do not see need for the alloc_capable check since this is hardcoded to be a MBA resource for which delay_linear can only be set if alloc_capable is set.

+}
+
+/*
+ * Enable or disable the MBA software controller
+ * which helps user specify bandwidth in MBps.
+ */
static int set_mba_sc(bool mba_sc)
{
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl;
- if (!is_mbm_enabled() || !is_mba_linear() ||
- mba_sc == is_mba_sc(r))
+ if (!supports_mba_mbps() || mba_sc == is_mba_sc(r))
return -EINVAL;
r->membw.mba_sc = mba_sc;
@@ -2317,7 +2326,7 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param)
ctx->enable_cdpl2 = true;
return 0;
case Opt_mba_mbps:
- if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)

I am not familiar with the history but it looks like AMD does not support linear (based on __rdt_get_mem_config_amd()) which may be the reason for this test and thus moving it to a feature check is ok.

+ if (supports_mba_mbps())
return -EINVAL;
ctx->enable_mba_mbps = true;
return 0;


Reinette