Move the names used for the schemata file out of the resource and
into struct resctrl_schema. This lets us give one resource two
different names, based on the other schema properties.

For now we copy the name, once we merge the L2/L2CODE/L2DATA
resources resctrl will generate it.

Remove the arch code's max_name_width, this is now resctrl's
problem.

Signed-off-by: James Morse <james.mo...@arm.com>
---
 arch/x86/kernel/cpu/intel_rdt.c             | 9 ++-------
 arch/x86/kernel/cpu/intel_rdt.h             | 2 +-
 arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 4 ++--
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c    | 4 +++-
 include/linux/resctrl.h                     | 7 +++++++
 5 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
index 6466c172c045..3a0d7de15afa 100644
--- a/arch/x86/kernel/cpu/intel_rdt.c
+++ b/arch/x86/kernel/cpu/intel_rdt.c
@@ -48,10 +48,10 @@ DEFINE_MUTEX(rdtgroup_mutex);
 DEFINE_PER_CPU(struct intel_pqr_state, pqr_state);
 
 /*
- * Used to store the max resource name width and max resource data width
+ * Used to store the max resource data width
  * to display the schemata in a tabular format
  */
-int max_name_width, max_data_width;
+int max_data_width;
 
 /*
  * Global boolean for rdt_alloc which is true if any
@@ -722,13 +722,8 @@ static int intel_rdt_offline_cpu(unsigned int cpu)
 static __init void rdt_init_padding(void)
 {
        struct rdt_resource *r;
-       int cl;
 
        for_each_alloc_capable_rdt_resource(r) {
-               cl = strlen(r->name);
-               if (cl > max_name_width)
-                       max_name_width = cl;
-
                if (r->data_width > max_data_width)
                        max_data_width = r->data_width;
        }
diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h
index cc8dea58b74f..b72448186532 100644
--- a/arch/x86/kernel/cpu/intel_rdt.h
+++ b/arch/x86/kernel/cpu/intel_rdt.h
@@ -146,7 +146,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_data_width;
 
 int __init rdtgroup_init(void);
 
diff --git a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c 
b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
index 3038ecfdeec0..e8264637a4d3 100644
--- a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
@@ -275,7 +275,7 @@ static int rdtgroup_parse_resource(char *resname, char 
*tok, int closid)
 
        list_for_each_entry(s, &resctrl_all_schema, list) {
                r = s->res;
-               if (!strcmp(resname, r->name) && closid < r->num_closid)
+               if (!strcmp(resname, s->name) && closid < r->num_closid)
                        return parse_line(tok, r, s->conf_type, closid);
        }
        rdt_last_cmd_printf("unknown/unsupported resource name '%s'\n", 
resname);
@@ -358,7 +358,7 @@ static void show_doms(struct seq_file *s, struct 
resctrl_schema *schema, int clo
        bool sep = false;
        u32 ctrl_val, hw_closid;
 
-       seq_printf(s, "%*s:", max_name_width, r->name);
+       seq_printf(s, "%*s:", sizeof(schema->name), schema->name);
        list_for_each_entry(dom, &r->domains, list) {
                if (sep)
                        seq_puts(s, ";");
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c 
b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index 0bd748defc73..b3d3acbb2ef7 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -932,7 +932,7 @@ static int rdtgroup_create_info_dir(struct kernfs_node 
*parent_kn)
        list_for_each_entry(s, &resctrl_all_schema, list) {
                r = s->res;
                fflags =  r->fflags | RF_CTRL_INFO;
-               ret = rdtgroup_mkdir_info_resdir(r, r->name, fflags);
+               ret = rdtgroup_mkdir_info_resdir(r, s->name, fflags);
                if (ret)
                        goto out_destroy;
        }
@@ -1306,6 +1306,8 @@ static int create_schemata_list(void)
                s->res = r;
                s->conf_type = resctrl_to_rdt(r)->cdp_type;
 
+               snprintf(s->name, sizeof(s->name), "%s", r->name);
+
                INIT_LIST_HEAD(&s->list);
                list_add(&s->list, &resctrl_all_schema);
        }
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 9ed0beb241d8..8b06ed8e7407 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -7,6 +7,11 @@
 #include <linux/list.h>
 #include <linux/kernel.h>
 
+/*
+ * The longest name we expect in the schemata file:
+ */
+#define RESCTRL_NAME_LEN       7
+
 enum resctrl_conf_type {
        CDP_BOTH = 0,
        CDP_CODE,
@@ -147,11 +152,13 @@ int resctrl_arch_set_cdp_enabled(bool enable);
 
 /**
  * @list:      Member of resctrl's schema list
+ * @name:      Name visible in the schemata file
  * @conf_type: Type of configuration, e.g. code/data/both
  * @res:       The rdt_resource for this entry
  */
 struct resctrl_schema {
        struct list_head                list;
+       char                            name[RESCTRL_NAME_LEN];
        enum resctrl_conf_type          conf_type;
        struct rdt_resource             *res;
 };
-- 
2.18.0

Reply via email to