mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amit Singh Tomar <amitsinght@marvell.com>
To: <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>
Cc: <fenghua.yu@intel.com>, <reinette.chatre@intel.com>,
	<james.morse@arm.com>, <gcherian@marvell.com>, <robh@kernel.org>,
	<peternewman@google.com>, <dfustini@baylibre.com>,
	<jonathan.cameron@huawei.com>,
	Amit Singh Tomar <amitsinght@marvell.com>
Subject: [PATCH v1 08/14] fs/resctrl: Extend schemata write for priority partition control
Date: Wed, 17 Jan 2024 19:43:59 +0530	[thread overview]
Message-ID: <20240117141405.3063506-9-amitsinght@marvell.com> (raw)
In-Reply-To: <20240117141405.3063506-1-amitsinght@marvell.com>

Currently, Users can pass the configurations for CPBM, and MBA through
schemata file. For instance, CPBM can be passed using:

echo L3:0=ffff > schemata

This change allows, users to pass a new configuration for downstream
priority. For instance, dspri value of "0xa" can be passed as:

echo L3DSPRI:0=a > schemata

Signed-off-by: Amit Singh Tomar <amitsinght@marvell.com>
---
Changes since RFC:
		* As suggested by Fenghua Yu, Parse for DSPRI is called
		  from parse_line().
		* Decluttering code from rdtgroup_schemata_write().
---
 fs/resctrl/ctrlmondata.c | 59 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 56 insertions(+), 3 deletions(-)

diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index 78f9fb1c52fa..f1f57bbfa094 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -30,6 +30,55 @@ typedef int (ctrlval_parser_t)(struct rdt_parse_data *data,
 			       struct resctrl_schema *s,
 			       struct rdt_domain *d);
 
+static bool dspri_validate(char *buf, unsigned long *data, struct rdt_resource *r)
+{
+
+	unsigned long dspri_val;
+	bool success = true;
+	int ret;
+
+	ret = kstrtoul(buf, 16, &dspri_val);
+	if (ret) {
+		pr_info("Non-hex character in the mask %s\n", buf);
+		success = false;
+		goto out;
+	}
+
+	if (dspri_val > r->default_dspri_ctrl) {
+		pr_info("dspri value %ld out of range [%d-%d]\n", dspri_val,
+					0, r->default_dspri_ctrl);
+		success = false;
+		goto out;
+	}
+
+	*data = dspri_val;
+
+out:
+	return success;
+}
+
+static int parse_dspri(struct rdt_parse_data *data, struct resctrl_schema *s,
+			struct rdt_domain *d)
+{
+	struct resctrl_staged_config *cfg;
+	struct rdt_resource *r = s->res;
+	unsigned long pri_val;
+
+	cfg = &d->staged_config[s->conf_type];
+	if (cfg->have_new_ctrl) {
+		pr_info("Duplicate domain %d\n", d->id);
+		return -EINVAL;
+	}
+
+	if (!dspri_validate(data->buf, &pri_val, r))
+		return -EINVAL;
+
+	cfg->new_ctrl = pri_val;
+	cfg->have_new_ctrl = true;
+
+	return 0;
+}
+
 /*
  * Check whether MBA bandwidth percentage value is correct. The value is
  * checked against the minimum and max bandwidth values specified by the
@@ -201,10 +250,14 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
 	return 0;
 }
 
-static ctrlval_parser_t *get_parser(struct rdt_resource *res)
+static ctrlval_parser_t *get_parser(struct resctrl_schema *s)
 {
-	if (res->fflags & RFTYPE_RES_CACHE)
+	struct rdt_resource *res = s->res;
+
+	if (res->fflags & RFTYPE_RES_CACHE && !s->ctrl_type)
 		return &parse_cbm;
+	else if (s->ctrl_type == SCHEMA_DSPRI)
+		return &parse_dspri;
 	else
 		return &parse_bw;
 }
@@ -218,7 +271,7 @@ static ctrlval_parser_t *get_parser(struct rdt_resource *res)
 static int parse_line(char *line, struct resctrl_schema *s,
 		      struct rdtgroup *rdtgrp)
 {
-	ctrlval_parser_t *parse_ctrlval = get_parser(s->res);
+	ctrlval_parser_t *parse_ctrlval = get_parser(s);
 	enum resctrl_conf_type t = s->conf_type;
 	struct resctrl_staged_config *cfg;
 	struct rdt_resource *r = s->res;
-- 
2.25.1


  parent reply	other threads:[~2024-01-17 14:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 14:13 [PATCH v1 00/14] ARM: MPAM: add support for priority partitioning control Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 01/14] fs/resctrl: group the resource control types for schemata list Amit Singh Tomar
2024-01-17 19:21   ` Peter Newman
2024-01-17 14:13 ` [PATCH v1 02/14] arm_mpam: resctrl: Detect priority partitioning capability Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 03/14] arm_mpam: resctrl: extend the schemata list to support priority partition Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 04/14] fs/resctrl: Set-up downstream priority partition resources Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 05/14] fs/resctrl: fetch configuration based on control type Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 06/14] arm_mpam: resctrl: Retrieve priority values from arch code Amit Singh Tomar
2024-01-17 14:13 ` [PATCH v1 07/14] fs/resctrl: Schemata write only for intended resource Amit Singh Tomar
2024-01-17 14:13 ` Amit Singh Tomar [this message]
2024-01-17 14:14 ` [PATCH v1 09/14] fs/resctrl: set configuration based on Control type Amit Singh Tomar
2024-01-17 14:14 ` [PATCH v1 10/14] arm_mpam: resctrl: Facilitate writing downstream priority value Amit Singh Tomar
2024-01-17 14:14 ` [PATCH v1 11/14] arm_mpam: Fix Downstream and internal priority mask Amit Singh Tomar
2024-01-17 14:14 ` [PATCH v1 12/14] arm_mpam: Program Downstream priority value Amit Singh Tomar
2024-01-17 14:14 ` [PATCH v1 13/14] arm_mpam: Handle resource instances mapped to different controls Amit Singh Tomar
2024-01-17 18:03   ` Peter Newman
2024-01-19 13:01     ` [EXT] " Amit Singh Tomar
2024-01-19 22:05       ` Peter Newman
2024-05-08 13:55         ` Amit Singh Tomar
2024-01-17 14:14 ` [PATCH v1 14/14] arm64/mpam: resctrl: export DSPRI value to info directory Amit Singh Tomar
2024-01-17 23:59 ` [PATCH v1 00/14] ARM: MPAM: add support for priority partitioning control Reinette Chatre

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=20240117141405.3063506-9-amitsinght@marvell.com \
    --to=amitsinght@marvell.com \
    --cc=dfustini@baylibre.com \
    --cc=fenghua.yu@intel.com \
    --cc=gcherian@marvell.com \
    --cc=james.morse@arm.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peternewman@google.com \
    --cc=reinette.chatre@intel.com \
    --cc=robh@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

all inboxes | Powered by JetHome®