Skip to content

Commit 634ebb9

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Add max_bw to struct resctrl_membw
__rdt_get_mem_config_amd() and __get_mem_config_intel() both use the default_ctrl property as a maximum value. This is because the MBA schema works differently between these platforms. Doing this complicates determining whether the default_ctrl property belongs to the arch code, or can be derived from the schema format. Deriving the maximum or default value from the schema format would avoid the architecture code having to tell resctrl such obvious things as the maximum percentage is 100, and the maximum bitmap is all ones. Maximum bandwidth is always going to vary per platform. Add max_bw as a special case. This is currently used for the maximum MBA percentage on Intel platforms, but can be removed from the architecture code if 'percentage' becomes a schema format resctrl supports directly. This value isn't needed for other schema formats. This will allow the default_ctrl to be generated from the schema properties when it is needed. Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Reviewed-by: Babu Moger <babu.moger@amd.com> Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64 Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Amit Singh Tomar <amitsinght@marvell.com> # arm64 Tested-by: Shanker Donthineni <sdonthineni@nvidia.com> # arm64 Tested-by: Babu Moger <babu.moger@amd.com> Link: https://lore.kernel.org/r/20250311183715.16445-8-james.morse@arm.com
1 parent 43312b8 commit 634ebb9

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ static __init bool __get_mem_config_intel(struct rdt_resource *r)
212212
hw_res->num_closid = edx.split.cos_max + 1;
213213
max_delay = eax.split.max_delay + 1;
214214
r->default_ctrl = MAX_MBA_BW;
215+
r->membw.max_bw = MAX_MBA_BW;
215216
r->membw.arch_needs_linear = true;
216217
if (ecx & MBA_IS_LINEAR) {
217218
r->membw.delay_linear = true;
@@ -250,6 +251,7 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_resource *r)
250251
cpuid_count(0x80000020, subleaf, &eax, &ebx, &ecx, &edx);
251252
hw_res->num_closid = edx + 1;
252253
r->default_ctrl = 1 << eax;
254+
r->membw.max_bw = 1 << eax;
253255

254256
/* AMD does not use delay */
255257
r->membw.delay_linear = false;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ static bool bw_validate(char *buf, u32 *data, struct rdt_resource *r)
6363
return true;
6464
}
6565

66-
if (bw < r->membw.min_bw || bw > r->default_ctrl) {
66+
if (bw < r->membw.min_bw || bw > r->membw.max_bw) {
6767
rdt_last_cmd_printf("MB value %u out of range [%d,%d]\n",
68-
bw, r->membw.min_bw, r->default_ctrl);
68+
bw, r->membw.min_bw, r->membw.max_bw);
6969
return false;
7070
}
7171

include/linux/resctrl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ enum membw_throttle_mode {
165165
/**
166166
* struct resctrl_membw - Memory bandwidth allocation related data
167167
* @min_bw: Minimum memory bandwidth percentage user can request
168+
* @max_bw: Maximum memory bandwidth value, used as the reset value
168169
* @bw_gran: Granularity at which the memory bandwidth is allocated
169170
* @delay_linear: True if memory B/W delay is in linear scale
170171
* @arch_needs_linear: True if we can't configure non-linear resources
@@ -175,6 +176,7 @@ enum membw_throttle_mode {
175176
*/
176177
struct resctrl_membw {
177178
u32 min_bw;
179+
u32 max_bw;
178180
u32 bw_gran;
179181
u32 delay_linear;
180182
bool arch_needs_linear;

0 commit comments

Comments
 (0)