Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1626881 > unrolled thread

[PATCH 0/3] x86/intel_rdt: Fixes for schemata parsing issues

Started byVikas Shivappa <vikas.shivappa@linux.intel.com>
First post2017-04-20 01:50 +0200
Last post2017-04-20 16:10 +0200
Articles 13 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/3] x86/intel_rdt: Fixes for schemata parsing issues Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-04-20 01:50 +0200
    [PATCH 3/3] x86/intel_rdt: Return error for incorrect resource names in schemata Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-04-20 01:50 +0200
      Re: [PATCH 3/3] x86/intel_rdt: Return error for incorrect resource  names in schemata Thomas Gleixner <tglx@linutronix.de> - 2017-04-20 15:50 +0200
        Re: [PATCH 3/3] x86/intel_rdt: Return error for incorrect resource  names in schemata Shivappa Vikas <vikas.shivappa@intel.com> - 2017-04-20 21:00 +0200
      [tip:x86/cpu] x86/intel_rdt: Return error for incorrect resource  names in schemata tip-bot for Vikas Shivappa <tipbot@zytor.com> - 2017-04-20 16:10 +0200
    [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-04-20 02:00 +0200
      Re: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata  input Thomas Gleixner <tglx@linutronix.de> - 2017-04-20 16:00 +0200
        Re: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata  input Thomas Gleixner <tglx@linutronix.de> - 2017-04-20 20:00 +0200
          Re: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata  input Shivappa Vikas <vikas.shivappa@intel.com> - 2017-04-20 23:20 +0200
        Re: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata  input Shivappa Vikas <vikas.shivappa@intel.com> - 2017-04-20 20:00 +0200
      [tip:x86/cpu] x86/intel_rdt: Trim whitespace while parsing schemata  input tip-bot for Vikas Shivappa <tipbot@zytor.com> - 2017-04-20 16:10 +0200
    [PATCH 1/3] x86/intel_rdt: Fix padding when resource is enabled via mount Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-04-20 02:00 +0200
      [tip:x86/cpu] x86/intel_rdt: Fix padding when resource is enabled  via mount tip-bot for Vikas Shivappa <tipbot@zytor.com> - 2017-04-20 16:10 +0200

#1626881 — [PATCH 0/3] x86/intel_rdt: Fixes for schemata parsing issues

FromVikas Shivappa <vikas.shivappa@linux.intel.com>
Date2017-04-20 01:50 +0200
Subject[PATCH 0/3] x86/intel_rdt: Fixes for schemata parsing issues
Message-ID<ty7wd-1ki-9@gated-at.bofh.it>
This series includes some minor fixes to RDT parsing of the schemata.
Patches are based on tip x86/cpu/

[PATCH 1/3] x86/intel_rdt: Fix padding when resource is enabled via
mount
[PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata
[PATCH 3/3] x86/intel_rdt: Return error for incorrect resource names

[toc] | [next] | [standalone]


#1626882 — [PATCH 3/3] x86/intel_rdt: Return error for incorrect resource names in schemata

FromVikas Shivappa <vikas.shivappa@linux.intel.com>
Date2017-04-20 01:50 +0200
Subject[PATCH 3/3] x86/intel_rdt: Return error for incorrect resource names in schemata
Message-ID<ty7wd-1ki-11@gated-at.bofh.it>
In reply to#1626881
When schemata parses the resource names, currently it may not return
error for incorrect resource names and fail quietly without updating the
control values.

This is because for_each_enabled_rdt_resource(r) leaves "r" pointing
beyond the end of the rdt_resources_all[] array, and we check for
!r->name which results in an out of bounds access and also may not be
NULL, hence we may not detect that we did not find the name user
supplied.

Update this to check (r == (rdt_resources_all + RDT_NUM_RESOURCES))
instead.

Reported-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Tested-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
---
 arch/x86/kernel/cpu/intel_rdt_schemata.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
index 3cfa1ca..bb99bd8 100644
--- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
@@ -228,7 +228,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 				break;
 			}
 		}
-		if (!r->name) {
+		if (r == (rdt_resources_all + RDT_NUM_RESOURCES)) {
 			ret = -EINVAL;
 			goto out;
 		}
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1627466 — Re: [PATCH 3/3] x86/intel_rdt: Return error for incorrect resource names in schemata

FromThomas Gleixner <tglx@linutronix.de>
Date2017-04-20 15:50 +0200
SubjectRe: [PATCH 3/3] x86/intel_rdt: Return error for incorrect resource names in schemata
Message-ID<tykD7-18r-13@gated-at.bofh.it>
In reply to#1626882
On Wed, 19 Apr 2017, Vikas Shivappa wrote:

> When schemata parses the resource names, currently it may not return
> error for incorrect resource names and fail quietly without updating the
> control values.
> 
> This is because for_each_enabled_rdt_resource(r) leaves "r" pointing
> beyond the end of the rdt_resources_all[] array, and we check for
> !r->name which results in an out of bounds access and also may not be
> NULL, hence we may not detect that we did not find the name user
> supplied.
> 
> Update this to check (r == (rdt_resources_all + RDT_NUM_RESOURCES))
> instead.
> 
> Reported-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
> Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
> Tested-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
> ---
>  arch/x86/kernel/cpu/intel_rdt_schemata.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
> index 3cfa1ca..bb99bd8 100644
> --- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
> +++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
> @@ -228,7 +228,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
>  				break;
>  			}
>  		}
> -		if (!r->name) {
> +		if (r == (rdt_resources_all + RDT_NUM_RESOURCES)) {
>  			ret = -EINVAL;
>  			goto out;
>  		}

The resulting loop is just horrible to read. We can do better than
that. Patch below.

Thanks,

	tglx
8<-------------

--- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
@@ -187,6 +187,17 @@ static int update_domains(struct rdt_res
 	return 0;
 }
 
+static int rdtgroup_parse_resource(char *resname, char *tok, int closid)
+{
+	struct rdt_resource *r;
+
+	for_each_enabled_rdt_resource(r) {
+		if (!strcmp(resname, r->name) && closid < r->num_closid)
+			return parse_line(tok, r);
+	}
+	return -EINVAL;
+}
+
 ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 				char *buf, size_t nbytes, loff_t off)
 {
@@ -209,9 +220,10 @@ ssize_t rdtgroup_schemata_write(struct k
 
 	closid = rdtgrp->closid;
 
-	for_each_enabled_rdt_resource(r)
+	for_each_enabled_rdt_resource(r) {
 		list_for_each_entry(dom, &r->domains, list)
 			dom->have_new_ctrl = false;
+	}
 
 	while ((tok = strsep(&buf, "\n")) != NULL) {
 		resname = strsep(&tok, ":");
@@ -219,19 +231,9 @@ ssize_t rdtgroup_schemata_write(struct k
 			ret = -EINVAL;
 			goto out;
 		}
-		for_each_enabled_rdt_resource(r) {
-			if (!strcmp(strim(resname), r->name) &&
-			    closid < r->num_closid) {
-				ret = parse_line(tok, r);
-				if (ret)
-					goto out;
-				break;
-			}
-		}
-		if (!r->name) {
-			ret = -EINVAL;
+		ret = rdtgroup_parse_resource(strim(resname), tok, closid);
+		if (ret)
 			goto out;
-		}
 	}
 
 	for_each_enabled_rdt_resource(r) {

[toc] | [prev] | [next] | [standalone]


#1627745 — Re: [PATCH 3/3] x86/intel_rdt: Return error for incorrect resource names in schemata

FromShivappa Vikas <vikas.shivappa@intel.com>
Date2017-04-20 21:00 +0200
SubjectRe: [PATCH 3/3] x86/intel_rdt: Return error for incorrect resource names in schemata
Message-ID<typt8-45C-15@gated-at.bofh.it>
In reply to#1627466

On Thu, 20 Apr 2017, Thomas Gleixner wrote:

> On Wed, 19 Apr 2017, Vikas Shivappa wrote:
>
>>  		}
>
> The resulting loop is just horrible to read. We can do better than
> that. Patch below.
>
> Thanks,
>
> 	tglx
> 8<-------------
>
> --- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
> +++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
> @@ -187,6 +187,17 @@ static int update_domains(struct rdt_res
> 	return 0;
> }
>
> +static int rdtgroup_parse_resource(char *resname, char *tok, int closid)
> +{
> +	struct rdt_resource *r;
> +
> +	for_each_enabled_rdt_resource(r) {
> +		if (!strcmp(resname, r->name) && closid < r->num_closid)
> +			return parse_line(tok, r);
> +	}
> +	return -EINVAL;
> +}
> +
> ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
> 				char *buf, size_t nbytes, loff_t off)
> {
> @@ -209,9 +220,10 @@ ssize_t rdtgroup_schemata_write(struct k
>
> 	closid = rdtgrp->closid;
>
> -	for_each_enabled_rdt_resource(r)
> +	for_each_enabled_rdt_resource(r) {
> 		list_for_each_entry(dom, &r->domains, list)
> 			dom->have_new_ctrl = false;
> +	}
>
> 	while ((tok = strsep(&buf, "\n")) != NULL) {
> 		resname = strsep(&tok, ":");
> @@ -219,19 +231,9 @@ ssize_t rdtgroup_schemata_write(struct k
> 			ret = -EINVAL;
> 			goto out;
> 		}
> -		for_each_enabled_rdt_resource(r) {
> -			if (!strcmp(strim(resname), r->name) &&
> -			    closid < r->num_closid) {
> -				ret = parse_line(tok, r);
> -				if (ret)
> -					goto out;
> -				break;
> -			}
> -		}
> -		if (!r->name) {
> -			ret = -EINVAL;
> +		ret = rdtgroup_parse_resource(strim(resname), tok, closid);
> +		if (ret)
> 			goto out;
> -		}
> 	}

Ok agree its better way. I was trying to add a NULL which Tony already said was 
Nacked, did not really want to use a pointer which may be out of bounds 
although we dont check the contents.

Thanks,
Vikas

[toc] | [prev] | [next] | [standalone]


#1627489 — [tip:x86/cpu] x86/intel_rdt: Return error for incorrect resource names in schemata

Fromtip-bot for Vikas Shivappa <tipbot@zytor.com>
Date2017-04-20 16:10 +0200
Subject[tip:x86/cpu] x86/intel_rdt: Return error for incorrect resource names in schemata
Message-ID<tykWu-1uY-15@gated-at.bofh.it>
In reply to#1626882
Commit-ID:  4797b7dfdfcf457075c36743d71e2b0feeaaa20f
Gitweb:     http://git.kernel.org/tip/4797b7dfdfcf457075c36743d71e2b0feeaaa20f
Author:     Vikas Shivappa <vikas.shivappa@linux.intel.com>
AuthorDate: Wed, 19 Apr 2017 16:50:04 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 20 Apr 2017 15:57:59 +0200

x86/intel_rdt: Return error for incorrect resource names in schemata

When schemata parses the resource names it does not return an error if it
detects incorrect resource names and fails quietly.

This happens because for_each_enabled_rdt_resource(r) leaves "r" pointing
beyond the end of the rdt_resources_all[] array, and the check for !r->name
results in an out of bounds access.

Split the resource parsing part into a helper function to avoid the issue.

[ tglx: Made it readable by splitting the parser loop out into a function ]

Reported-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Tested-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
Cc: fenghua.yu@intel.com
Cc: tony.luck@intel.com
Cc: ravi.v.shankar@intel.com
Cc: vikas.shivappa@intel.com
Link: http://lkml.kernel.org/r/1492645804-17465-4-git-send-email-vikas.shivappa@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/cpu/intel_rdt_schemata.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
index e64b2cf..406d7a6 100644
--- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
@@ -188,6 +188,17 @@ done:
 	return 0;
 }
 
+static int rdtgroup_parse_resource(char *resname, char *tok, int closid)
+{
+	struct rdt_resource *r;
+
+	for_each_enabled_rdt_resource(r) {
+		if (!strcmp(resname, r->name) && closid < r->num_closid)
+			return parse_line(tok, r);
+	}
+	return -EINVAL;
+}
+
 ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 				char *buf, size_t nbytes, loff_t off)
 {
@@ -210,9 +221,10 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 
 	closid = rdtgrp->closid;
 
-	for_each_enabled_rdt_resource(r)
+	for_each_enabled_rdt_resource(r) {
 		list_for_each_entry(dom, &r->domains, list)
 			dom->have_new_ctrl = false;
+	}
 
 	while ((tok = strsep(&buf, "\n")) != NULL) {
 		resname = strim(strsep(&tok, ":"));
@@ -220,19 +232,9 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 			ret = -EINVAL;
 			goto out;
 		}
-		for_each_enabled_rdt_resource(r) {
-			if (!strcmp(resname, r->name) &&
-			    closid < r->num_closid) {
-				ret = parse_line(tok, r);
-				if (ret)
-					goto out;
-				break;
-			}
-		}
-		if (!r->name) {
-			ret = -EINVAL;
+		ret = rdtgroup_parse_resource(resname, tok, closid);
+		if (ret)
 			goto out;
-		}
 	}
 
 	for_each_enabled_rdt_resource(r) {

[toc] | [prev] | [next] | [standalone]


#1626887 — [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input

FromVikas Shivappa <vikas.shivappa@linux.intel.com>
Date2017-04-20 02:00 +0200
Subject[PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input
Message-ID<ty7FT-1nw-1@gated-at.bofh.it>
In reply to#1626881
Schemata is displayed in tabular format which introduces some whitespace
to show data in a tabular format. If user wants to input the same data
that is displayed, the parsing fails. Trim the leading and trailing
whitespace to help parse such data.

Reported-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Tested-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
---
 arch/x86/kernel/cpu/intel_rdt_schemata.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
index 9467a00..3cfa1ca 100644
--- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
@@ -143,7 +143,7 @@ static int parse_line(char *line, struct rdt_resource *r)
 		return -EINVAL;
 	list_for_each_entry(d, &r->domains, list) {
 		if (d->id == dom_id) {
-			if (r->parse_ctrlval(dom, r, d))
+			if (r->parse_ctrlval(strim(dom), r, d))
 				return -EINVAL;
 			goto next;
 		}
@@ -220,7 +220,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 			goto out;
 		}
 		for_each_enabled_rdt_resource(r) {
-			if (!strcmp(resname, r->name) &&
+			if (!strcmp(strim(resname), r->name) &&
 			    closid < r->num_closid) {
 				ret = parse_line(tok, r);
 				if (ret)
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1627485 — Re: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input

FromThomas Gleixner <tglx@linutronix.de>
Date2017-04-20 16:00 +0200
SubjectRe: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input
Message-ID<tykMP-1ck-41@gated-at.bofh.it>
In reply to#1626887
On Wed, 19 Apr 2017, Vikas Shivappa wrote:

> Schemata is displayed in tabular format which introduces some whitespace
> to show data in a tabular format. If user wants to input the same data
> that is displayed, the parsing fails. Trim the leading and trailing
> whitespace to help parse such data.
> 
> Reported-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
> Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
> Tested-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
> ---
>  arch/x86/kernel/cpu/intel_rdt_schemata.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
> index 9467a00..3cfa1ca 100644
> --- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
> +++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
> @@ -143,7 +143,7 @@ static int parse_line(char *line, struct rdt_resource *r)
>  		return -EINVAL;
>  	list_for_each_entry(d, &r->domains, list) {
>  		if (d->id == dom_id) {
> -			if (r->parse_ctrlval(dom, r, d))
> +			if (r->parse_ctrlval(strim(dom), r, d))
>  				return -EINVAL;
>  			goto next;
>  		}
> @@ -220,7 +220,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
>  			goto out;
>  		}
>  		for_each_enabled_rdt_resource(r) {
> -			if (!strcmp(resname, r->name) &&
> +			if (!strcmp(strim(resname), r->name) &&

Both strims() invocations are just silly. They can be done before the loop
once instead of doing them over and over again.

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1627718 — Re: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input

FromThomas Gleixner <tglx@linutronix.de>
Date2017-04-20 20:00 +0200
SubjectRe: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input
Message-ID<tyox3-3vH-9@gated-at.bofh.it>
In reply to#1627485
On Thu, 20 Apr 2017, Shivappa Vikas wrote:
> Will fix. I went overboard not wanting to add a line

Finish reading the thread before you start :)

[toc] | [prev] | [next] | [standalone]


#1627836 — Re: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input

FromShivappa Vikas <vikas.shivappa@intel.com>
Date2017-04-20 23:20 +0200
SubjectRe: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input
Message-ID<tyrEC-5ym-15@gated-at.bofh.it>
In reply to#1627718

On Thu, 20 Apr 2017, Thomas Gleixner wrote:

> On Thu, 20 Apr 2017, Shivappa Vikas wrote:
>> Will fix. I went overboard not wanting to add a line
>
> Finish reading the thread before you start :)

Got it :) Had not seen the tip bot emails on my other email..

>

[toc] | [prev] | [next] | [standalone]


#1627724 — Re: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input

FromShivappa Vikas <vikas.shivappa@intel.com>
Date2017-04-20 20:00 +0200
SubjectRe: [PATCH 2/3] x86/intel_rdt: Trim whitespace while parsing schemata input
Message-ID<tyox4-3vH-11@gated-at.bofh.it>
In reply to#1627485

On Thu, 20 Apr 2017, Thomas Gleixner wrote:

> On Wed, 19 Apr 2017, Vikas Shivappa wrote:
>
>> Schemata is displayed in tabular format which introduces some whitespace
>> to show data in a tabular format. If user wants to input the same data
>> that is displayed, the parsing fails. Trim the leading and trailing
>> whitespace to help parse such data.
>>
>> Reported-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
>> Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
>> Tested-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
>> ---
>>  arch/x86/kernel/cpu/intel_rdt_schemata.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
>> index 9467a00..3cfa1ca 100644
>> --- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
>> +++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
>> @@ -143,7 +143,7 @@ static int parse_line(char *line, struct rdt_resource *r)
>>  		return -EINVAL;
>>  	list_for_each_entry(d, &r->domains, list) {
>>  		if (d->id == dom_id) {
>> -			if (r->parse_ctrlval(dom, r, d))
>> +			if (r->parse_ctrlval(strim(dom), r, d))
>>  				return -EINVAL;
>>  			goto next;
>>  		}
>> @@ -220,7 +220,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
>>  			goto out;
>>  		}
>>  		for_each_enabled_rdt_resource(r) {
>> -			if (!strcmp(resname, r->name) &&
>> +			if (!strcmp(strim(resname), r->name) &&
>
> Both strims() invocations are just silly. They can be done before the loop
> once instead of doing them over and over again.

Will fix. I went overboard not wanting to add a line

Thanks,
Vikas

>
> Thanks,
>
> 	tglx
>

[toc] | [prev] | [next] | [standalone]


#1627491 — [tip:x86/cpu] x86/intel_rdt: Trim whitespace while parsing schemata input

Fromtip-bot for Vikas Shivappa <tipbot@zytor.com>
Date2017-04-20 16:10 +0200
Subject[tip:x86/cpu] x86/intel_rdt: Trim whitespace while parsing schemata input
Message-ID<tykWt-1uY-7@gated-at.bofh.it>
In reply to#1626887
Commit-ID:  634b0e0491d6f6e882b922eb41c278d01a743bab
Gitweb:     http://git.kernel.org/tip/634b0e0491d6f6e882b922eb41c278d01a743bab
Author:     Vikas Shivappa <vikas.shivappa@linux.intel.com>
AuthorDate: Wed, 19 Apr 2017 16:50:03 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 20 Apr 2017 15:57:59 +0200

x86/intel_rdt: Trim whitespace while parsing schemata input

Schemata is displayed in tabular format which introduces some whitespace
to show data in a tabular format.

Writing back the same data fails as the parser does not handle the
whitespace.

Trim the leading and trailing whitespace before parsing.

Reported-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Tested-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
Cc: fenghua.yu@intel.com
Cc: tony.luck@intel.com
Cc: ravi.v.shankar@intel.com
Cc: vikas.shivappa@intel.com
Link: http://lkml.kernel.org/r/1492645804-17465-3-git-send-email-vikas.shivappa@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/cpu/intel_rdt_schemata.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
index 9467a00..e64b2cf 100644
--- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
@@ -141,6 +141,7 @@ next:
 	id = strsep(&dom, "=");
 	if (!dom || kstrtoul(id, 10, &dom_id))
 		return -EINVAL;
+	dom = strim(dom);
 	list_for_each_entry(d, &r->domains, list) {
 		if (d->id == dom_id) {
 			if (r->parse_ctrlval(dom, r, d))
@@ -214,7 +215,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 			dom->have_new_ctrl = false;
 
 	while ((tok = strsep(&buf, "\n")) != NULL) {
-		resname = strsep(&tok, ":");
+		resname = strim(strsep(&tok, ":"));
 		if (!tok) {
 			ret = -EINVAL;
 			goto out;

[toc] | [prev] | [next] | [standalone]


#1626889 — [PATCH 1/3] x86/intel_rdt: Fix padding when resource is enabled via mount

FromVikas Shivappa <vikas.shivappa@linux.intel.com>
Date2017-04-20 02:00 +0200
Subject[PATCH 1/3] x86/intel_rdt: Fix padding when resource is enabled via mount
Message-ID<ty7FT-1nw-5@gated-at.bofh.it>
In reply to#1626881
Currently max width of 'resource name' and 'resource data' is being
initialized based on 'enabled resources' during boot. But the mount can
enable different capable resources at a later time which upsets the
tabular format of schemata. Fix this to be based on 'all capable'
resources.

Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Tested-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
---
 arch/x86/kernel/cpu/intel_rdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
index 731f70a..5b36646 100644
--- a/arch/x86/kernel/cpu/intel_rdt.c
+++ b/arch/x86/kernel/cpu/intel_rdt.c
@@ -492,7 +492,7 @@ static __init void rdt_init_padding(void)
 	struct rdt_resource *r;
 	int cl;
 
-	for_each_enabled_rdt_resource(r) {
+	for_each_capable_rdt_resource(r) {
 		cl = strlen(r->name);
 		if (cl > max_name_width)
 			max_name_width = cl;
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1627493 — [tip:x86/cpu] x86/intel_rdt: Fix padding when resource is enabled via mount

Fromtip-bot for Vikas Shivappa <tipbot@zytor.com>
Date2017-04-20 16:10 +0200
Subject[tip:x86/cpu] x86/intel_rdt: Fix padding when resource is enabled via mount
Message-ID<tykWu-1uY-27@gated-at.bofh.it>
In reply to#1626889
Commit-ID:  adcbdd70309dba5a12a9d8158deb6a62a6d5fc98
Gitweb:     http://git.kernel.org/tip/adcbdd70309dba5a12a9d8158deb6a62a6d5fc98
Author:     Vikas Shivappa <vikas.shivappa@linux.intel.com>
AuthorDate: Wed, 19 Apr 2017 16:50:02 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 20 Apr 2017 15:57:59 +0200

x86/intel_rdt: Fix padding when resource is enabled via mount

Currently max width of 'resource name' and 'resource data' is being
initialized based on 'enabled resources' during boot. But the mount can
enable different capable resources at a later time which upsets the
tabular format of schemata. Fix this to be based on 'all capable'
resources.

Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
Tested-by: Prakhya, Sai Praneeth <sai.praneeth.prakhya@intel.com>
Cc: fenghua.yu@intel.com
Cc: tony.luck@intel.com
Cc: ravi.v.shankar@intel.com
Cc: vikas.shivappa@intel.com
Link: http://lkml.kernel.org/r/1492645804-17465-2-git-send-email-vikas.shivappa@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/cpu/intel_rdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c
index 731f70a..5b36646 100644
--- a/arch/x86/kernel/cpu/intel_rdt.c
+++ b/arch/x86/kernel/cpu/intel_rdt.c
@@ -492,7 +492,7 @@ static __init void rdt_init_padding(void)
 	struct rdt_resource *r;
 	int cl;
 
-	for_each_enabled_rdt_resource(r) {
+	for_each_capable_rdt_resource(r) {
 		cl = strlen(r->name);
 		if (cl > max_name_width)
 			max_name_width = cl;

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web