From: "Luck, Tony" <tony.luck@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>,
linux-kernel@vger.kernel.org, Boris Petkov <bp@suse.de>,
Fenghua Yu <fenghua.yu@intel.com>,
Reinette Chatre <reinette.chatre@intel.com>,
Steven Rostedt <rostedt@goodmis.org>,
Vikas Shivappa <vikas.shivappa@intel.com>
Subject: [PATCH 2/5] x86/intel_rdt: Add diagnostics when writing the schemata file
Date: Mon, 18 Sep 2017 15:18:40 -0700 [thread overview]
Message-ID: <29bafcfe886a22c6b9b68868f021193e55e5bcf2.1505771973.git.tony.luck@intel.com> (raw)
In-Reply-To: <cover.1505771973.git.tony.luck@intel.com>
In-Reply-To: <cover.1505771973.git.tony.luck@intel.com>
From: Tony Luck <tony.luck@intel.com>
Save helpful descriptions of what went wrong when writing a
schemata file.
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 61 +++++++++++++++++++++++------
1 file changed, 50 insertions(+), 11 deletions(-)
diff --git a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
index f6ea94f8954a..d87a060ab0db 100644
--- a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
@@ -42,15 +42,25 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
/*
* Only linear delay values is supported for current Intel SKUs.
*/
- if (!r->membw.delay_linear)
+ if (!r->membw.delay_linear) {
+ seq_buf_puts(&last_cmd_status,
+ "No support for non-linear MB domains\n");
return false;
+ }
ret = kstrtoul(buf, 10, &bw);
- if (ret)
+ if (ret) {
+ seq_buf_printf(&last_cmd_status,
+ "Non-decimal digit in MB value %s\n", buf);
return false;
+ }
- if (bw < r->membw.min_bw || bw > r->default_ctrl)
+ if (bw < r->membw.min_bw || bw > r->default_ctrl) {
+ seq_buf_printf(&last_cmd_status,
+ "MB value %ld out of range [%d,%d]\n", bw,
+ r->membw.min_bw, r->default_ctrl);
return false;
+ }
*data = roundup(bw, (unsigned long)r->membw.bw_gran);
return true;
@@ -60,8 +70,11 @@ int parse_bw(char *buf, struct rdt_resource *r, struct rdt_domain *d)
{
unsigned long data;
- if (d->have_new_ctrl)
+ if (d->have_new_ctrl) {
+ seq_buf_printf(&last_cmd_status, "duplicate domain %d\n",
+ d->id);
return -EINVAL;
+ }
if (!bw_validate(buf, &data, r))
return -EINVAL;
@@ -84,20 +97,32 @@ static bool cbm_validate(char *buf, unsigned long *data, struct rdt_resource *r)
int ret;
ret = kstrtoul(buf, 16, &val);
- if (ret)
+ if (ret) {
+ seq_buf_printf(&last_cmd_status,
+ "non-hex character in mask %s\n", buf);
return false;
+ }
- if (val == 0 || val > r->default_ctrl)
+ if (val == 0 || val > r->default_ctrl) {
+ seq_buf_puts(&last_cmd_status, "mask out of range\n");
return false;
+ }
first_bit = find_first_bit(&val, cbm_len);
zero_bit = find_next_zero_bit(&val, cbm_len, first_bit);
- if (find_next_bit(&val, cbm_len, zero_bit) < cbm_len)
+ if (find_next_bit(&val, cbm_len, zero_bit) < cbm_len) {
+ seq_buf_printf(&last_cmd_status,
+ "mask %lx has non-consecutive 1-bits\n", val);
return false;
+ }
- if ((zero_bit - first_bit) < r->cache.min_cbm_bits)
+ if ((zero_bit - first_bit) < r->cache.min_cbm_bits) {
+ seq_buf_printf(&last_cmd_status,
+ "Need at least %d bits in mask\n",
+ r->cache.min_cbm_bits);
return false;
+ }
*data = val;
return true;
@@ -111,8 +136,11 @@ int parse_cbm(char *buf, struct rdt_resource *r, struct rdt_domain *d)
{
unsigned long data;
- if (d->have_new_ctrl)
+ if (d->have_new_ctrl) {
+ seq_buf_printf(&last_cmd_status, "duplicate domain %d\n",
+ d->id);
return -EINVAL;
+ }
if(!cbm_validate(buf, &data, r))
return -EINVAL;
@@ -139,8 +167,11 @@ static int parse_line(char *line, struct rdt_resource *r)
return 0;
dom = strsep(&line, ";");
id = strsep(&dom, "=");
- if (!dom || kstrtoul(id, 10, &dom_id))
+ if (!dom || kstrtoul(id, 10, &dom_id)) {
+ seq_buf_puts(&last_cmd_status,
+ "Missing '=' or non-numeric domain\n");
return -EINVAL;
+ }
dom = strim(dom);
list_for_each_entry(d, &r->domains, list) {
if (d->id == dom_id) {
@@ -196,6 +227,8 @@ static int rdtgroup_parse_resource(char *resname, char *tok, int closid)
if (!strcmp(resname, r->name) && closid < r->num_closid)
return parse_line(tok, r);
}
+ seq_buf_printf(&last_cmd_status,
+ "unknown/unsupported resource name '%s'\n", resname);
return -EINVAL;
}
@@ -208,14 +241,19 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
char *tok, *resname;
int closid, ret = 0;
+ seq_buf_clear(&last_cmd_status);
+
/* Valid input requires a trailing newline */
- if (nbytes == 0 || buf[nbytes - 1] != '\n')
+ if (nbytes == 0 || buf[nbytes - 1] != '\n') {
+ seq_buf_puts(&last_cmd_status, "no trailing newline\n");
return -EINVAL;
+ }
buf[nbytes - 1] = '\0';
rdtgrp = rdtgroup_kn_lock_live(of->kn);
if (!rdtgrp) {
rdtgroup_kn_unlock(of->kn);
+ seq_buf_puts(&last_cmd_status, "directory was removed\n");
return -ENOENT;
}
@@ -229,6 +267,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
while ((tok = strsep(&buf, "\n")) != NULL) {
resname = strim(strsep(&tok, ":"));
if (!tok) {
+ seq_buf_puts(&last_cmd_status, "Missing ':'\n");
ret = -EINVAL;
goto out;
}
--
2.11.0
next prev parent reply other threads:[~2017-09-18 22:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-18 22:18 [RFC 0/5] x86/intel_rdt: Better diagnostics Luck, Tony
2017-09-18 22:18 ` [PATCH 1/5] x86/intel_rdt: Add framework for better RDT UI diagnostics Luck, Tony
2017-09-18 22:18 ` Luck, Tony [this message]
2017-09-25 14:04 ` [PATCH 2/5] x86/intel_rdt: Add diagnostics when writing the schemata file Thomas Gleixner
2017-09-25 21:38 ` Luck, Tony
2017-09-25 22:12 ` Thomas Gleixner
2017-09-25 22:18 ` Luck, Tony
2017-09-18 22:18 ` [PATCH 3/5] x86/intel_rdt: Add diagnostics when writing the tasks file Luck, Tony
2017-09-18 22:18 ` [PATCH 4/5] x86/intel_rdt: Add diagnostics when writing the cpus file Luck, Tony
2017-09-18 22:18 ` [PATCH 5/5] x86/intel_rdt: Add diagnostics when making directories Luck, Tony
2017-09-19 1:10 ` [RFC 0/5] x86/intel_rdt: Better diagnostics Steven Rostedt
2017-09-19 23:11 ` [PATCH 6/5] x86/intel_rdt: Add documentation for "info/last_cmd_status" Luck, Tony
2017-09-21 12:08 ` [RFC 0/5] x86/intel_rdt: Better diagnostics Borislav Petkov
2017-09-30 8:27 ` Borislav Petkov
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=29bafcfe886a22c6b9b68868f021193e55e5bcf2.1505771973.git.tony.luck@intel.com \
--to=tony.luck@intel.com \
--cc=bp@suse.de \
--cc=fenghua.yu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=reinette.chatre@intel.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=vikas.shivappa@intel.com \
/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
all inboxes | Powered by JetHome®