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


Groups > linux.kernel > #1583671 > unrolled thread

[PATCH 2/5] x86/intel_rdt: Improvements to parsing schemata

Started byVikas Shivappa <vikas.shivappa@linux.intel.com>
First post2017-02-17 20:50 +0100
Last post2017-02-17 20:50 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/5] x86/intel_rdt: Improvements to parsing schemata Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2017-02-17 20:50 +0100

#1583671 — [PATCH 2/5] x86/intel_rdt: Improvements to parsing schemata

FromVikas Shivappa <vikas.shivappa@linux.intel.com>
Date2017-02-17 20:50 +0100
Subject[PATCH 2/5] x86/intel_rdt: Improvements to parsing schemata
Message-ID<tbWHw-8v1-7@gated-at.bofh.it>
The schemata file requires all RDT (Resource director technology)
resources be entered in the same order they are shown in the root
schemata file.
Hence remove the looping through all resources while parsing each
schemata and get the next enabled resource after processing a resource.

Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
---
 arch/x86/kernel/cpu/intel_rdt_schemata.c | 40 ++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel_rdt_schemata.c b/arch/x86/kernel/cpu/intel_rdt_schemata.c
index 14ba504..64b43b1 100644
--- a/arch/x86/kernel/cpu/intel_rdt_schemata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_schemata.c
@@ -138,6 +138,27 @@ static int update_domains(struct rdt_resource *r, int closid)
 	return 0;
 }
 
+/*
+ * Parameter r must be NULL or pointing to
+ * a valid rdt_resource_all entry.
+ * returns next enabled RDT resource.
+ */
+static inline struct rdt_resource*
+get_next_enabled_rdt_resource(struct rdt_resource *r)
+{
+	struct rdt_resource *it = r;
+
+	if (!it)
+		it = rdt_resources_all;
+	else
+		it++;
+	for (; it < rdt_resources_all + RDT_NUM_RESOURCES; it++)
+		if (it->enabled)
+			return it;
+
+	return NULL;
+}
+
 ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 				char *buf, size_t nbytes, loff_t off)
 {
@@ -171,22 +192,21 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 		r->num_tmp_cbms = 0;
 	}
 
+	r = NULL;
 	while ((tok = strsep(&buf, "\n")) != NULL) {
 		resname = strsep(&tok, ":");
 		if (!tok) {
 			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) {
+
+		r = get_next_enabled_rdt_resource(r);
+
+		if (r && !strcmp(resname, r->name)) {
+			ret = parse_line(tok, r);
+			if (ret)
+				goto out;
+		} else {
 			ret = -EINVAL;
 			goto out;
 		}
-- 
1.9.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web