Skip to content

Commit 43312b8

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Remove data_width and the tabular format
The resctrl architecture code provides a data_width for the controls of each resource. This is used to zero pad all control values in the schemata file so they appear in columns. The same is done with the resource names to complete the visual effect. e.g. | SMBA:0=2048 | L3:0=00ff AMD platforms discover their maximum bandwidth for the MB resource from firmware, but hard-code the data_width to 4. If the maximum bandwidth requires more digits - the tabular format is silently broken. This is also broken when the mba_MBps mount option is used as the field width isn't updated. If new schema are added resctrl will need to be able to determine the maximum width. The benefit of this pretty-printing is questionable. Instead of handling runtime discovery of the data_width for AMD platforms, remove the feature. These fields are always zero padded so should be harmless to remove if the whole field has been treated as a number. In the above example, this would now look like this: | SMBA:0=2048 | L3:0=ff 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: 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-7-james.morse@arm.com
1 parent bb9343c commit 43312b8

5 files changed

Lines changed: 10 additions & 33 deletions

File tree

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ static DEFINE_MUTEX(domain_list_lock);
4343
*/
4444
DEFINE_PER_CPU(struct resctrl_pqr_state, pqr_state);
4545

46-
/*
47-
* Used to store the max resource name width and max resource data width
48-
* to display the schemata in a tabular format
49-
*/
50-
int max_name_width, max_data_width;
51-
5246
/*
5347
* Global boolean for rdt_alloc which is true if any
5448
* resource allocation is enabled.
@@ -228,7 +222,6 @@ static __init bool __get_mem_config_intel(struct rdt_resource *r)
228222
return false;
229223
r->membw.arch_needs_linear = false;
230224
}
231-
r->data_width = 3;
232225

233226
if (boot_cpu_has(X86_FEATURE_PER_THREAD_MBA))
234227
r->membw.throttle_mode = THREAD_THROTTLE_PER_THREAD;
@@ -269,8 +262,6 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_resource *r)
269262
r->membw.throttle_mode = THREAD_THROTTLE_UNDEFINED;
270263
r->membw.min_bw = 0;
271264
r->membw.bw_gran = 1;
272-
/* Max value is 2048, Data width should be 4 in decimal */
273-
r->data_width = 4;
274265

275266
r->alloc_capable = true;
276267

@@ -290,7 +281,6 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r)
290281
r->cache.cbm_len = eax.split.cbm_len + 1;
291282
r->default_ctrl = BIT_MASK(eax.split.cbm_len + 1) - 1;
292283
r->cache.shareable_bits = ebx & r->default_ctrl;
293-
r->data_width = (r->cache.cbm_len + 3) / 4;
294284
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
295285
r->cache.arch_has_sparse_bitmasks = ecx.split.noncont;
296286
r->alloc_capable = true;
@@ -786,20 +776,6 @@ static int resctrl_arch_offline_cpu(unsigned int cpu)
786776
return 0;
787777
}
788778

789-
/*
790-
* Choose a width for the resource name and resource data based on the
791-
* resource that has widest name and cbm.
792-
*/
793-
static __init void rdt_init_padding(void)
794-
{
795-
struct rdt_resource *r;
796-
797-
for_each_alloc_capable_rdt_resource(r) {
798-
if (r->data_width > max_data_width)
799-
max_data_width = r->data_width;
800-
}
801-
}
802-
803779
enum {
804780
RDT_FLAG_CMT,
805781
RDT_FLAG_MBM_TOTAL,
@@ -1102,8 +1078,6 @@ static int __init resctrl_late_init(void)
11021078
if (!get_rdt_resources())
11031079
return -ENODEV;
11041080

1105-
rdt_init_padding();
1106-
11071081
state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
11081082
"x86/resctrl/cat:online:",
11091083
resctrl_arch_online_cpu,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,7 @@ static void show_doms(struct seq_file *s, struct resctrl_schema *schema, int clo
487487
ctrl_val = resctrl_arch_get_config(r, dom, closid,
488488
schema->conf_type);
489489

490-
seq_printf(s, schema->fmt_str, dom->hdr.id, max_data_width,
491-
ctrl_val);
490+
seq_printf(s, schema->fmt_str, dom->hdr.id, ctrl_val);
492491
sep = true;
493492
}
494493
seq_puts(s, "\n");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ struct rdtgroup {
326326
/* List of all resource groups */
327327
extern struct list_head rdt_all_groups;
328328

329-
extern int max_name_width, max_data_width;
329+
extern int max_name_width;
330330

331331
int __init rdtgroup_init(void);
332332
void __exit rdtgroup_exit(void);

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ static struct kernfs_node *kn_mongrp;
5757
/* Kernel fs node for "mon_data" directory under root */
5858
static struct kernfs_node *kn_mondata;
5959

60+
/*
61+
* Used to store the max resource name width to display the schemata names in
62+
* a tabular format.
63+
*/
64+
int max_name_width;
65+
6066
static struct seq_buf last_cmd_status;
6167
static char last_cmd_status_buf[512];
6268

@@ -2613,10 +2619,10 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
26132619

26142620
switch (r->schema_fmt) {
26152621
case RESCTRL_SCHEMA_BITMAP:
2616-
s->fmt_str = "%d=%0*x";
2622+
s->fmt_str = "%d=%x";
26172623
break;
26182624
case RESCTRL_SCHEMA_RANGE:
2619-
s->fmt_str = "%d=%0*u";
2625+
s->fmt_str = "%d=%u";
26202626
break;
26212627
}
26222628

include/linux/resctrl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ enum resctrl_schema_fmt {
214214
* @ctrl_domains: RCU list of all control domains for this resource
215215
* @mon_domains: RCU list of all monitor domains for this resource
216216
* @name: Name to use in "schemata" file.
217-
* @data_width: Character width of data when displaying
218217
* @default_ctrl: Specifies default cache cbm or memory B/W percent.
219218
* @schema_fmt: Which format string and parser is used for this schema.
220219
* @evt_list: List of monitoring events
@@ -232,7 +231,6 @@ struct rdt_resource {
232231
struct list_head ctrl_domains;
233232
struct list_head mon_domains;
234233
char *name;
235-
int data_width;
236234
u32 default_ctrl;
237235
enum resctrl_schema_fmt schema_fmt;
238236
struct list_head evt_list;

0 commit comments

Comments
 (0)