]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86/intel_rdt: Update schemata read to show data in tabular format
authorVikas Shivappa <vikas.shivappa@linux.intel.com>
Mon, 3 Apr 2017 21:44:17 +0000 (14:44 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 5 Apr 2017 15:22:31 +0000 (17:22 +0200)
The schemata file displays data from different resources on all
domains. Its cumbersome to read since they are not tabular and data/names
could be of different widths.  Make the schemata file to display data in a
tabular format thereby making it nice and simple to read.

Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Cc: ravi.v.shankar@intel.com
Cc: tony.luck@intel.com
Cc: fenghua.yu@intel.com
Cc: peterz@infradead.org
Cc: vikas.shivappa@intel.com
Cc: h.peter.anvin@intel.com
Link: http://lkml.kernel.org/r/1491255857-17213-4-git-send-email-vikas.shivappa@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/include/asm/intel_rdt.h
arch/x86/kernel/cpu/intel_rdt.c
arch/x86/kernel/cpu/intel_rdt_schemata.c

index d7705270c4010504d900ffb2723bb8de71bb6309..3f313991c0b3025b649acae393182063464eb032 100644 (file)
@@ -40,6 +40,8 @@ struct rdtgroup {
 /* List of all resource groups */
 extern struct list_head rdt_all_groups;
 
+extern int max_name_width, max_data_width;
+
 int __init rdtgroup_init(void);
 
 /**
@@ -73,6 +75,7 @@ struct rftype {
  * @name:                      Name to use in "schemata" file
  * @num_closid:                        Number of CLOSIDs available
  * @max_cbm:                   Largest Cache Bit Mask allowed
+ * @data_width:                Character width of data when displaying
  * @min_cbm_bits:              Minimum number of consecutive bits to be set
  *                             in a cache bit mask
  * @domains:                   All domains for this resource
@@ -90,6 +93,7 @@ struct rdt_resource {
        int                     cbm_len;
        int                     min_cbm_bits;
        u32                     max_cbm;
+       int                     data_width;
        struct list_head        domains;
        int                     msr_base;
        int                     cache_level;
index 329b8876b984b0deeee11a0e48609e761487bb6d..70a3307fd592b69d46c1006df641d292c9c65910 100644 (file)
@@ -39,6 +39,12 @@ DEFINE_PER_CPU_READ_MOSTLY(int, cpu_closid);
 
 #define domain_init(id) LIST_HEAD_INIT(rdt_resources_all[id].domains)
 
+/*
+ * 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;
+
 struct rdt_resource rdt_resources_all[] = {
        {
                .name           = "L3",
@@ -140,6 +146,7 @@ static void rdt_get_config(int idx, struct rdt_resource *r)
        r->num_closid = edx.split.cos_max + 1;
        r->cbm_len = eax.split.cbm_len + 1;
        r->max_cbm = BIT_MASK(eax.split.cbm_len + 1) - 1;
+       r->data_width = (r->cbm_len + 3) / 4;
        r->capable = true;
        r->enabled = true;
 }
@@ -152,6 +159,7 @@ static void rdt_get_cdp_l3_config(int type)
        r->num_closid = r_l3->num_closid / 2;
        r->cbm_len = r_l3->cbm_len;
        r->max_cbm = r_l3->max_cbm;
+       r->data_width = (r->cbm_len + 3) / 4;
        r->capable = true;
        /*
         * By default, CDP is disabled. CDP can be enabled by mount parameter
@@ -160,6 +168,26 @@ static void rdt_get_cdp_l3_config(int type)
        r->enabled = false;
 }
 
+/**
+ * Choose a width for the resource name
+ * and resource data based on the resource that has
+ * widest name and cbm.
+ */
+static void rdt_init_padding(void)
+{
+       struct rdt_resource *r;
+       int cl;
+
+       for_each_enabled_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;
+       }
+}
+
 static inline bool get_rdt_resources(void)
 {
        bool ret = false;
@@ -184,6 +212,8 @@ static inline bool get_rdt_resources(void)
                ret = true;
        }
 
+       rdt_init_padding();
+
        return ret;
 }
 
index 52e83eabd9b721e475045e2402253a69a2e40177..8594db455aa1b18a462949e006eb6b6fe76d8429 100644 (file)
@@ -203,11 +203,12 @@ static void show_doms(struct seq_file *s, struct rdt_resource *r, int closid)
        struct rdt_domain *dom;
        bool sep = false;
 
-       seq_printf(s, "%s:", r->name);
+       seq_printf(s, "%*s:", max_name_width, r->name);
        list_for_each_entry(dom, &r->domains, list) {
                if (sep)
                        seq_puts(s, ";");
-               seq_printf(s, "%d=%x", dom->id, dom->cbm[closid]);
+               seq_printf(s, "%d=%0*x", dom->id, max_data_width,
+                          dom->cbm[closid]);
                sep = true;
        }
        seq_puts(s, "\n");