Skip to content

Commit 67bf649

Browse files
babumogersuryasaimadhu
authored andcommitted
x86/resctrl: Fix min_cbm_bits for AMD
AMD systems support zero CBM (capacity bit mask) for cache allocation. That is reflected in rdt_init_res_defs_amd() by: r->cache.arch_has_empty_bitmaps = true; However given the unified code in cbm_validate(), checking for: val == 0 && !arch_has_empty_bitmaps is not enough because of another check in cbm_validate(): if ((zero_bit - first_bit) < r->cache.min_cbm_bits) The default value of r->cache.min_cbm_bits = 1. Leading to: $ cd /sys/fs/resctrl $ mkdir foo $ cd foo $ echo L3:0=0 > schemata -bash: echo: write error: Invalid argument $ cat /sys/fs/resctrl/info/last_cmd_status Need at least 1 bits in the mask Initialize the min_cbm_bits to 0 for AMD. Also, remove the default setting of min_cbm_bits and initialize it separately. After the fix: $ cd /sys/fs/resctrl $ mkdir foo $ cd foo $ echo L3:0=0 > schemata $ cat /sys/fs/resctrl/info/last_cmd_status ok Fixes: 316e7f9 ("x86/resctrl: Add struct rdt_cache::arch_has_{sparse, empty}_bitmaps") Co-developed-by: Stephane Eranian <[email protected]> Signed-off-by: Stephane Eranian <[email protected]> Signed-off-by: Babu Moger <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> Reviewed-by: James Morse <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Reviewed-by: Fenghua Yu <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]
1 parent e7ad18d commit 67bf649

File tree

1 file changed

+2
-6
lines changed
  • arch/x86/kernel/cpu/resctrl

1 file changed

+2
-6
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ struct rdt_hw_resource rdt_resources_all[] = {
6666
.rid = RDT_RESOURCE_L3,
6767
.name = "L3",
6868
.cache_level = 3,
69-
.cache = {
70-
.min_cbm_bits = 1,
71-
},
7269
.domains = domain_init(RDT_RESOURCE_L3),
7370
.parse_ctrlval = parse_cbm,
7471
.format_str = "%d=%0*x",
@@ -83,9 +80,6 @@ struct rdt_hw_resource rdt_resources_all[] = {
8380
.rid = RDT_RESOURCE_L2,
8481
.name = "L2",
8582
.cache_level = 2,
86-
.cache = {
87-
.min_cbm_bits = 1,
88-
},
8983
.domains = domain_init(RDT_RESOURCE_L2),
9084
.parse_ctrlval = parse_cbm,
9185
.format_str = "%d=%0*x",
@@ -836,6 +830,7 @@ static __init void rdt_init_res_defs_intel(void)
836830
r->cache.arch_has_sparse_bitmaps = false;
837831
r->cache.arch_has_empty_bitmaps = false;
838832
r->cache.arch_has_per_cpu_cfg = false;
833+
r->cache.min_cbm_bits = 1;
839834
} else if (r->rid == RDT_RESOURCE_MBA) {
840835
hw_res->msr_base = MSR_IA32_MBA_THRTL_BASE;
841836
hw_res->msr_update = mba_wrmsr_intel;
@@ -856,6 +851,7 @@ static __init void rdt_init_res_defs_amd(void)
856851
r->cache.arch_has_sparse_bitmaps = true;
857852
r->cache.arch_has_empty_bitmaps = true;
858853
r->cache.arch_has_per_cpu_cfg = true;
854+
r->cache.min_cbm_bits = 0;
859855
} else if (r->rid == RDT_RESOURCE_MBA) {
860856
hw_res->msr_base = MSR_IA32_MBA_BW_BASE;
861857
hw_res->msr_update = mba_wrmsr_amd;

0 commit comments

Comments
 (0)