All of lore.kernel.org
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com,
	vikas.shivappa@linux.intel.com
Cc: gavin.hindman@intel.com, jithu.joseph@intel.com,
	dave.hansen@intel.com, mingo@redhat.com, hpa@zytor.com,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Reinette Chatre <reinette.chatre@intel.com>
Subject: [PATCH V3 12/39] x86/intel_rdt: Ensure requested schemata respects mode
Date: Wed, 25 Apr 2018 03:09:48 -0700	[thread overview]
Message-ID: <7d535bec73940e3e3efa93785bfeda23b902c450.1524649902.git.reinette.chatre@intel.com> (raw)
In-Reply-To: <cover.1524649902.git.reinette.chatre@intel.com>
In-Reply-To: <cover.1524649902.git.reinette.chatre@intel.com>

When the administrator requests a change in a resource group's schemata
we have to ensure that the new schemata respects the current resource
group as well as the other active resource groups' schemata.

The new schemata is not allowed to overlap with the schemata of any
exclusive resource groups. Similarly, if the resource group being
changed is exclusive then its new schemata is not allowed to overlap
with any schemata of any other active resource group.

Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
---
 arch/x86/kernel/cpu/intel_rdt.h             |  2 ++
 arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 49 ++++++++++++++++++++++-------
 arch/x86/kernel/cpu/intel_rdt_rdtgroup.c    |  4 +--
 3 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h
index 3eb2616c4254..e48ff4e62757 100644
--- a/arch/x86/kernel/cpu/intel_rdt.h
+++ b/arch/x86/kernel/cpu/intel_rdt.h
@@ -450,6 +450,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 				char *buf, size_t nbytes, loff_t off);
 int rdtgroup_schemata_show(struct kernfs_open_file *of,
 			   struct seq_file *s, void *v);
+int rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d,
+			  u32 _cbm, int closid, bool exclusive);
 enum rdtgrp_mode rdtgroup_mode_by_closid(int closid);
 struct rdt_domain *get_domain_from_cpu(int cpu, struct rdt_resource *r);
 int update_domains(struct rdt_resource *r, int closid);
diff --git a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
index a55bc0b0e0ac..15291ca02daf 100644
--- a/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
+++ b/arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c
@@ -122,13 +122,19 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
 	return true;
 }
 
+struct rdt_cbm_parse_data {
+	char *buf;
+	struct rdtgroup *rdtgrp;
+};
+
 /*
  * Read one cache bit mask (hex). Check that it is valid for the current
  * resource type.
  */
 int parse_cbm(void *_data, struct rdt_resource *r, struct rdt_domain *d)
 {
-	char *buf = _data;
+	struct rdt_cbm_parse_data *data = _data;
+	struct rdtgroup *rdtgrp = data->rdtgrp;
 	u32 cbm_val;
 
 	if (d->have_new_ctrl) {
@@ -136,8 +142,24 @@ int parse_cbm(void *_data, struct rdt_resource *r, struct rdt_domain *d)
 		return -EINVAL;
 	}
 
-	if (!cbm_validate(buf, &cbm_val, r))
+	if (!cbm_validate(data->buf, &cbm_val, r))
+		return -EINVAL;
+
+	/*
+	 * The CBM may not overlap with the CBM of another closid if
+	 * either is exclusive.
+	 */
+	if (rdtgroup_cbm_overlaps(r, d, cbm_val, rdtgrp->closid, true)) {
+		rdt_last_cmd_printf("overlaps with exclusive group\n");
 		return -EINVAL;
+	}
+
+	if (rdtgroup_cbm_overlaps(r, d, cbm_val, rdtgrp->closid, false)) {
+		if (rdtgrp->mode == RDT_MODE_EXCLUSIVE) {
+			rdt_last_cmd_printf("overlaps with other group\n");
+			return -EINVAL;
+		}
+	}
 
 	d->new_ctrl = cbm_val;
 	d->have_new_ctrl = true;
@@ -151,8 +173,10 @@ int parse_cbm(void *_data, struct rdt_resource *r, struct rdt_domain *d)
  * separated by ";". The "id" is in decimal, and must match one of
  * the "id"s for this resource.
  */
-static int parse_line(char *line, struct rdt_resource *r)
+static int parse_line(char *line, struct rdt_resource *r,
+		      struct rdtgroup *rdtgrp)
 {
+	struct rdt_cbm_parse_data data;
 	char *dom = NULL, *id;
 	struct rdt_domain *d;
 	unsigned long dom_id;
@@ -169,7 +193,9 @@ static int parse_line(char *line, struct rdt_resource *r)
 	dom = strim(dom);
 	list_for_each_entry(d, &r->domains, list) {
 		if (d->id == dom_id) {
-			if (r->parse_ctrlval(dom, r, d))
+			data.buf = dom;
+			data.rdtgrp = rdtgrp;
+			if (r->parse_ctrlval(&data, r, d))
 				return -EINVAL;
 			goto next;
 		}
@@ -213,13 +239,14 @@ int update_domains(struct rdt_resource *r, int closid)
 	return 0;
 }
 
-static int rdtgroup_parse_resource(char *resname, char *tok, int closid)
+static int rdtgroup_parse_resource(char *resname, char *tok,
+				   struct rdtgroup *rdtgrp)
 {
 	struct rdt_resource *r;
 
 	for_each_alloc_enabled_rdt_resource(r) {
-		if (!strcmp(resname, r->name) && closid < r->num_closid)
-			return parse_line(tok, r);
+		if (!strcmp(resname, r->name) && rdtgrp->closid < r->num_closid)
+			return parse_line(tok, r, rdtgrp);
 	}
 	rdt_last_cmd_printf("unknown/unsupported resource name '%s'\n", resname);
 	return -EINVAL;
@@ -232,7 +259,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 	struct rdt_domain *dom;
 	struct rdt_resource *r;
 	char *tok, *resname;
-	int closid, ret = 0;
+	int ret = 0;
 
 	/* Valid input requires a trailing newline */
 	if (nbytes == 0 || buf[nbytes - 1] != '\n')
@@ -246,8 +273,6 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 	}
 	rdt_last_cmd_clear();
 
-	closid = rdtgrp->closid;
-
 	for_each_alloc_enabled_rdt_resource(r) {
 		list_for_each_entry(dom, &r->domains, list)
 			dom->have_new_ctrl = false;
@@ -265,13 +290,13 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
 			ret = -EINVAL;
 			goto out;
 		}
-		ret = rdtgroup_parse_resource(resname, tok, closid);
+		ret = rdtgroup_parse_resource(resname, tok, rdtgrp);
 		if (ret)
 			goto out;
 	}
 
 	for_each_alloc_enabled_rdt_resource(r) {
-		ret = update_domains(r, closid);
+		ret = update_domains(r, rdtgrp->closid);
 		if (ret)
 			goto out;
 	}
diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
index 0bacfdb85de1..6cc8384c8edf 100644
--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
+++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c
@@ -829,8 +829,8 @@ static int rdtgroup_mode_show(struct kernfs_open_file *of,
  *
  * Return: 0 if CBM does not overlap, 1 if it does.
  */
-static int rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d,
-				 u32 _cbm, int closid, bool exclusive)
+int rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d,
+			  u32 _cbm, int closid, bool exclusive)
 {
 	unsigned long *cbm = (unsigned long *)&_cbm;
 	unsigned long *ctrl_b;
-- 
2.13.6

  parent reply	other threads:[~2018-04-25 18:13 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-25 10:09 [PATCH V3 00/39] Intel(R) Resource Director Technology Cache Pseudo-Locking enabling Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 01/39] x86/intel_rdt: Document new mode, size, and bit_usage Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 02/39] x86/intel_rdt: Introduce RDT resource group mode Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 03/39] x86/intel_rdt: Associate mode with each RDT resource group Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 04/39] x86/intel_rdt: Introduce resource group's mode resctrl file Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 05/39] x86/intel_rdt: Introduce test to determine if closid is in use Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 06/39] x86/intel_rdt: Make useful functions available internally Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 07/39] x86/intel_rdt: Initialize new resource group with sane defaults Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 08/39] x86/intel_rdt: Introduce new "exclusive" mode Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 09/39] x86/intel_rdt: Enable setting of exclusive mode Reinette Chatre
2018-05-19 15:18   ` Thomas Gleixner
2018-04-25 10:09 ` [PATCH V3 10/39] x86/intel_rdt: Making CBM name and type more explicit Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 11/39] x86/intel_rdt: Support flexible data to parsing callbacks Reinette Chatre
2018-04-25 10:09 ` Reinette Chatre [this message]
2018-05-19 15:19   ` [PATCH V3 12/39] x86/intel_rdt: Ensure requested schemata respects mode Thomas Gleixner
2018-04-25 10:09 ` [PATCH V3 13/39] x86/intel_rdt: Introduce "bit_usage" to display cache allocations details Reinette Chatre
2018-05-19 15:21   ` Thomas Gleixner
2018-04-25 10:09 ` [PATCH V3 14/39] x86/intel_rdt: Display resource groups' allocations' size in bytes Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 15/39] x86/intel_rdt: Documentation for Cache Pseudo-Locking Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 16/39] x86/intel_rdt: Introduce the Cache Pseudo-Locking modes Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 17/39] x86/intel_rdt: Respect read and write access Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 18/39] x86/intel_rdt: Add utility to test if tasks assigned to resource group Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 19/39] x86/intel_rdt: Add utility to restrict/restore access to resctrl files Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 20/39] x86/intel_rdt: Protect against resource group changes during locking Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 21/39] x86/intel_rdt: Utilities to restrict/restore access to specific files Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 22/39] x86/intel_rdt: Add check to determine if monitoring in progress Reinette Chatre
2018-04-25 10:09 ` [PATCH V3 23/39] x86/intel_rdt: Introduce pseudo-locked region Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 24/39] x86/intel_rdt: Support enter/exit of locksetup mode Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 25/39] x86/intel_rdt: Enable entering of pseudo-locksetup mode Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 26/39] x86/intel_rdt: Split resource group removal in two Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 27/39] x86/intel_rdt: Add utilities to test pseudo-locked region possibility Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 28/39] x86/intel_rdt: Discover supported platforms via prefetch disable bits Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 29/39] x86/intel_rdt: Pseudo-lock region creation/removal core Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 30/39] x86/intel_rdt: Support creation/removal of pseudo-locked region Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 31/39] x86/intel_rdt: resctrl files reflect pseudo-locked information Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 32/39] x86/intel_rdt: Ensure RDT cleanup on exit Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 33/39] x86/intel_rdt: Create resctrl debug area Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 34/39] x86/intel_rdt: Create debugfs files for pseudo-locking testing Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 35/39] x86/intel_rdt: Create character device exposing pseudo-locked region Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 36/39] x86/intel_rdt: More precise L2 hit/miss measurements Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 37/39] x86/intel_rdt: Support L3 cache performance event of Broadwell Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 38/39] x86/intel_rdt: Limit C-states dynamically when pseudo-locking active Reinette Chatre
2018-04-25 10:10 ` [PATCH V3 39/39] x86/intel_rdt: Support contiguous memory of all sizes Reinette Chatre
2018-05-19 19:54 ` [PATCH V3 00/39] Intel(R) Resource Director Technology Cache Pseudo-Locking enabling Thomas Gleixner

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=7d535bec73940e3e3efa93785bfeda23b902c450.1524649902.git.reinette.chatre@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=gavin.hindman@intel.com \
    --cc=hpa@zytor.com \
    --cc=jithu.joseph@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=vikas.shivappa@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.