]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/resctrl: Remove data_width and the tabular format
authorJames Morse <james.morse@arm.com>
Tue, 11 Mar 2025 18:36:51 +0000 (18:36 +0000)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 12 Mar 2025 11:22:36 +0000 (12:22 +0100)
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
arch/x86/kernel/cpu/resctrl/core.c
arch/x86/kernel/cpu/resctrl/ctrlmondata.c
arch/x86/kernel/cpu/resctrl/internal.h
arch/x86/kernel/cpu/resctrl/rdtgroup.c
include/linux/resctrl.h

index 542503a8c953db659612b4bed7c5ca8e30bdf89c..754fb65565ec984dc48c247f1a49cec57fdc7e9b 100644 (file)
@@ -43,12 +43,6 @@ static DEFINE_MUTEX(domain_list_lock);
  */
 DEFINE_PER_CPU(struct resctrl_pqr_state, pqr_state);
 
-/*
- * Used to store the max resource name width and max resource data width
- * to display the schemata in a tabular format
- */
-int max_name_width, max_data_width;
-
 /*
  * Global boolean for rdt_alloc which is true if any
  * resource allocation is enabled.
@@ -228,7 +222,6 @@ static __init bool __get_mem_config_intel(struct rdt_resource *r)
                        return false;
                r->membw.arch_needs_linear = false;
        }
-       r->data_width = 3;
 
        if (boot_cpu_has(X86_FEATURE_PER_THREAD_MBA))
                r->membw.throttle_mode = THREAD_THROTTLE_PER_THREAD;
@@ -269,8 +262,6 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_resource *r)
        r->membw.throttle_mode = THREAD_THROTTLE_UNDEFINED;
        r->membw.min_bw = 0;
        r->membw.bw_gran = 1;
-       /* Max value is 2048, Data width should be 4 in decimal */
-       r->data_width = 4;
 
        r->alloc_capable = true;
 
@@ -290,7 +281,6 @@ static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r)
        r->cache.cbm_len = eax.split.cbm_len + 1;
        r->default_ctrl = BIT_MASK(eax.split.cbm_len + 1) - 1;
        r->cache.shareable_bits = ebx & r->default_ctrl;
-       r->data_width = (r->cache.cbm_len + 3) / 4;
        if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
                r->cache.arch_has_sparse_bitmasks = ecx.split.noncont;
        r->alloc_capable = true;
@@ -786,20 +776,6 @@ static int resctrl_arch_offline_cpu(unsigned int cpu)
        return 0;
 }
 
-/*
- * Choose a width for the resource name and resource data based on the
- * resource that has widest name and cbm.
- */
-static __init void rdt_init_padding(void)
-{
-       struct rdt_resource *r;
-
-       for_each_alloc_capable_rdt_resource(r) {
-               if (r->data_width > max_data_width)
-                       max_data_width = r->data_width;
-       }
-}
-
 enum {
        RDT_FLAG_CMT,
        RDT_FLAG_MBM_TOTAL,
@@ -1102,8 +1078,6 @@ static int __init resctrl_late_init(void)
        if (!get_rdt_resources())
                return -ENODEV;
 
-       rdt_init_padding();
-
        state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
                                  "x86/resctrl/cat:online:",
                                  resctrl_arch_online_cpu,
index c763cb4fb1a887aa73436cc6a316f6009b3b7caa..59610b209b4e9d65f50d693050fb52704c9f2139 100644 (file)
@@ -487,8 +487,7 @@ static void show_doms(struct seq_file *s, struct resctrl_schema *schema, int clo
                        ctrl_val = resctrl_arch_get_config(r, dom, closid,
                                                           schema->conf_type);
 
-               seq_printf(s, schema->fmt_str, dom->hdr.id, max_data_width,
-                          ctrl_val);
+               seq_printf(s, schema->fmt_str, dom->hdr.id, ctrl_val);
                sep = true;
        }
        seq_puts(s, "\n");
index b5543bd506c3b9d91af1d08f87f49a1f5a3b04ad..f975cd6cfe619be0538c42336cec642a351e5bac 100644 (file)
@@ -326,7 +326,7 @@ struct rdtgroup {
 /* List of all resource groups */
 extern struct list_head rdt_all_groups;
 
-extern int max_name_width, max_data_width;
+extern int max_name_width;
 
 int __init rdtgroup_init(void);
 void __exit rdtgroup_exit(void);
index e7862d0936c94fc690ee79a51f304bb26bb12183..1e0bae1a9d9505278515542ba34f30fe4ad194a1 100644 (file)
@@ -57,6 +57,12 @@ static struct kernfs_node *kn_mongrp;
 /* Kernel fs node for "mon_data" directory under root */
 static struct kernfs_node *kn_mondata;
 
+/*
+ * Used to store the max resource name width to display the schemata names in
+ * a tabular format.
+ */
+int max_name_width;
+
 static struct seq_buf last_cmd_status;
 static char last_cmd_status_buf[512];
 
@@ -2613,10 +2619,10 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
 
        switch (r->schema_fmt) {
        case RESCTRL_SCHEMA_BITMAP:
-               s->fmt_str = "%d=%0*x";
+               s->fmt_str = "%d=%x";
                break;
        case RESCTRL_SCHEMA_RANGE:
-               s->fmt_str = "%d=%0*u";
+               s->fmt_str = "%d=%u";
                break;
        }
 
index 736b9a9a9464eee79f4d56fb7da1d631d4ae5f74..e1a982adef45a48a1e193b31a396bdf5868bc7e3 100644 (file)
@@ -214,7 +214,6 @@ enum resctrl_schema_fmt {
  * @ctrl_domains:      RCU list of all control domains for this resource
  * @mon_domains:       RCU list of all monitor domains for this resource
  * @name:              Name to use in "schemata" file.
- * @data_width:                Character width of data when displaying
  * @default_ctrl:      Specifies default cache cbm or memory B/W percent.
  * @schema_fmt:                Which format string and parser is used for this schema.
  * @evt_list:          List of monitoring events
@@ -232,7 +231,6 @@ struct rdt_resource {
        struct list_head        ctrl_domains;
        struct list_head        mon_domains;
        char                    *name;
-       int                     data_width;
        u32                     default_ctrl;
        enum resctrl_schema_fmt schema_fmt;
        struct list_head        evt_list;