Skip to content

Commit 41215b7

Browse files
James Morsesuryasaimadhu
authored andcommitted
x86/resctrl: Add struct rdt_membw::arch_needs_linear to explain AMD/Intel MBA difference
The configuration values user-space provides to the resctrl filesystem are ABI. To make this work on another architecture, all the ABI bits should be moved out of /arch/x86 and under /fs. To do this, the differences between AMD and Intel CPUs needs to be explained to resctrl via resource properties, instead of function pointers that let the arch code accept subtly different values on different platforms/architectures. For MBA, Intel CPUs reject configuration attempts for non-linear resources, whereas AMD ignore this field as its MBA resource is never linear. To merge the parse/validate functions, this difference needs to be explained. Add struct rdt_membw::arch_needs_linear to indicate the arch code needs the linear property to be true to configure this resource. AMD can set this and delay_linear to false. Intel can set arch_needs_linear to true to keep the existing "No support for non-linear MB domains" error message for affected platforms. [ bp: convert "we" etc to passive voice. ] Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Babu Moger <babu.moger@amd.com> Link: https://lkml.kernel.org/r/20200708163929.2783-8-james.morse@arm.com
1 parent e6b2fac commit 41215b7

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

arch/x86/kernel/cpu/resctrl/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,15 @@ static bool __get_mem_config_intel(struct rdt_resource *r)
260260
r->num_closid = edx.split.cos_max + 1;
261261
max_delay = eax.split.max_delay + 1;
262262
r->default_ctrl = MAX_MBA_BW;
263+
r->membw.arch_needs_linear = true;
263264
if (ecx & MBA_IS_LINEAR) {
264265
r->membw.delay_linear = true;
265266
r->membw.min_bw = MAX_MBA_BW - max_delay;
266267
r->membw.bw_gran = MAX_MBA_BW - max_delay;
267268
} else {
268269
if (!rdt_get_mb_table(r))
269270
return false;
271+
r->membw.arch_needs_linear = false;
270272
}
271273
r->data_width = 3;
272274

@@ -288,6 +290,7 @@ static bool __rdt_get_mem_config_amd(struct rdt_resource *r)
288290

289291
/* AMD does not use delay */
290292
r->membw.delay_linear = false;
293+
r->membw.arch_needs_linear = false;
291294

292295
r->membw.min_bw = 0;
293296
r->membw.bw_gran = 1;

arch/x86/kernel/cpu/resctrl/ctrlmondata.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ static bool bw_validate_amd(char *buf, unsigned long *data,
3333
unsigned long bw;
3434
int ret;
3535

36+
/* temporary: always false on AMD */
37+
if (!r->membw.delay_linear && r->membw.arch_needs_linear) {
38+
rdt_last_cmd_puts("No support for non-linear MB domains\n");
39+
return false;
40+
}
41+
3642
ret = kstrtoul(buf, 10, &bw);
3743
if (ret) {
3844
rdt_last_cmd_printf("Non-decimal digit in MB value %s\n", buf);
@@ -82,7 +88,7 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
8288
/*
8389
* Only linear delay values is supported for current Intel SKUs.
8490
*/
85-
if (!r->membw.delay_linear) {
91+
if (!r->membw.delay_linear && r->membw.arch_needs_linear) {
8692
rdt_last_cmd_puts("No support for non-linear MB domains\n");
8793
return false;
8894
}

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,15 @@ struct rdt_cache {
372372
* @min_bw: Minimum memory bandwidth percentage user can request
373373
* @bw_gran: Granularity at which the memory bandwidth is allocated
374374
* @delay_linear: True if memory B/W delay is in linear scale
375+
* @arch_needs_linear: True if we can't configure non-linear resources
375376
* @mba_sc: True if MBA software controller(mba_sc) is enabled
376377
* @mb_map: Mapping of memory B/W percentage to memory B/W delay
377378
*/
378379
struct rdt_membw {
379380
u32 min_bw;
380381
u32 bw_gran;
381382
u32 delay_linear;
383+
bool arch_needs_linear;
382384
bool mba_sc;
383385
u32 *mb_map;
384386
};

0 commit comments

Comments
 (0)