From: Vikas Shivappa <vikas.shivappa@linux.intel.com>
To: vikas.shivappa@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org
Cc: hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org,
peterz@infradead.org, ravi.v.shankar@intel.com,
tony.luck@intel.com, fenghua.yu@intel.com,
h.peter.anvin@intel.com
Subject: [PATCH 3/3] x86/intel_rdt: Update schemata read to show data in tabular format
Date: Mon, 3 Apr 2017 14:44:17 -0700 [thread overview]
Message-ID: <1491255857-17213-4-git-send-email-vikas.shivappa@linux.intel.com> (raw)
In-Reply-To: <1491255857-17213-1-git-send-email-vikas.shivappa@linux.intel.com>
The schemata file would display 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>
---
arch/x86/include/asm/intel_rdt.h | 4 ++++
arch/x86/kernel/cpu/intel_rdt.c | 30 ++++++++++++++++++++++++++++++
arch/x86/kernel/cpu/intel_rdt_schemata.c | 5 +++--
3 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/intel_rdt.h b/arch/x86/include/asm/intel_rdt.h
index d770527..3f31399 100644
--- a/arch/x86/include/asm/intel_rdt.h
+++ b/arch/x86/include/asm/intel_rdt.h
@@ -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;
diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
index 329b887..70a3307 100644
--- a/arch/x86/kernel/cpu/intel_rdt.c
+++ b/arch/x86/kernel/cpu/intel_rdt.c
@@ -39,6 +39,12 @@
#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;
}
diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
index 52e83ea..8594db4 100644
--- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
@@ -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");
--
1.9.1
next prev parent reply other threads:[~2017-04-03 21:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-03 21:44 [PATCH 0/3 V3] x86/intel_rdt: Improvements/Fixes to RDT framework Vikas Shivappa
2017-04-03 21:44 ` [PATCH 1/3] x86/intel_rdt: Fix issue when mkdir uses a freed CLOSid Vikas Shivappa
2017-04-05 15:20 ` Thomas Gleixner
2017-04-05 18:03 ` Shivappa Vikas
2017-04-05 18:07 ` Luck, Tony
2017-04-05 20:17 ` Fenghua Yu
2017-04-10 17:08 ` Thomas Gleixner
2017-04-11 18:51 ` Shivappa Vikas
2017-04-03 21:44 ` [PATCH 2/3] x86/intel_rdt: Implement "update" mode when writing schemata file Vikas Shivappa
2017-04-05 15:27 ` [tip:x86/cpu] " tip-bot for Tony Luck
2017-04-03 21:44 ` Vikas Shivappa [this message]
2017-04-05 15:28 ` [tip:x86/cpu] x86/intel_rdt: Update schemata read to show data in tabular format tip-bot for Vikas Shivappa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1491255857-17213-4-git-send-email-vikas.shivappa@linux.intel.com \
--to=vikas.shivappa@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=h.peter.anvin@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=ravi.v.shankar@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=vikas.shivappa@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox