From: Fenghua Yu <fenghua.yu@intel.com>
To: Amit Singh Tomar <amitsinght@marvell.com>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>
Cc: <reinette.chatre@intel.com>, <james.morse@arm.com>,
<gcherian@marvell.com>, <robh@kernel.org>,
<peternewman@google.com>
Subject: Re: [RFC 09/12] fs/resctrl: Extend schemata write for priority partition control
Date: Thu, 17 Aug 2023 10:27:42 -0700 [thread overview]
Message-ID: <944e7e64-509b-c916-5166-13e7bfe2161b@intel.com> (raw)
In-Reply-To: <20230815152712.1760046-10-amitsinght@marvell.com>
Hi, Amit,
On 8/15/23 08:27, Amit Singh Tomar wrote:
> 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 along with CPBM. For instance, dspri value of "0xa" can be
> passed as:
>
> echo L3:0=ffff,a > schemata
>
> Signed-off-by: Amit Singh Tomar <amitsinght@marvell.com>
> ---
> fs/resctrl/ctrlmondata.c | 92 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 92 insertions(+)
>
> diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
> index ffeb68270968..b444adee2002 100644
> --- a/fs/resctrl/ctrlmondata.c
> +++ b/fs/resctrl/ctrlmondata.c
> @@ -30,6 +30,74 @@ 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)
> +{
> +
> + char *dup_buf, *dspri_token;
> + unsigned long dspri_val;
> + bool success = true;
> + int ret;
> +
> + dup_buf = kstrdup(buf, GFP_KERNEL);
> + if (!dup_buf) {
> + rdt_last_cmd_printf("Failed to allocate buffer %s\n",
> + __func__);
> + success = false;
> + goto out;
> + }
> +
> + strsep(&dup_buf, ",");
> + if (!dup_buf) {
> + rdt_last_cmd_printf("Unable to find priority value token %s\n",
> + __func__);
> + success = false;
> + goto out;
> + }
> +
> + dspri_token = strsep(&dup_buf, ",");
> + ret = kstrtoul(dspri_token, 16, &dspri_val);
> + if (ret) {
> + rdt_last_cmd_printf("Non-hex character in the mask %s\n", buf);
> + success = false;
> + goto out;
> + }
> +
> + if (dspri_val > r->dspri_default_ctrl) {
> + rdt_last_cmd_printf("dspri value %ld out of range [%d-%d]\n", dspri_val,
> + 0, r->dspri_default_ctrl);
> + success = false;
> + goto out;
> + }
> +
> + *data = dspri_val;
> +
> +out:
> + kfree(dup_buf);
> + 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) {
> + rdt_last_cmd_printf("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
> @@ -293,6 +361,8 @@ static int rdtgroup_parse_resource(char *resname, char *tok,
> ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
> char *buf, size_t nbytes, loff_t off)
> {
> + char *dup_buf = kstrdup(buf, GFP_KERNEL);
> + struct rdt_parse_data data;
> struct resctrl_schema *s;
> struct rdtgroup *rdtgrp;
> struct rdt_domain *dom;
> @@ -354,10 +424,32 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
> if (is_mba_sc(r))
> continue;
>
> + if (r->priority_cap)
> + r->dspri_store = false;
> +
> if (!strcmp(resname, s->name)) {
> ret = resctrl_arch_update_domains(r, rdtgrp->closid);
> if (ret)
> goto out;
> +
> + if (r->priority_cap) {
> + r->dspri_store = true;
> + list_for_each_entry(dom, &r->domains, list) {
> + ctrlval_parser_t *parse_ctrlval = &parse_dspri;
> + char *dom_data = NULL;
> +
> + dom_data = strsep(&dup_buf, ";");
> + dom_data = strim(dom_data);
> + data.buf = dom_data;
> + data.rdtgrp = rdtgrp;
> + if (parse_ctrlval(&data, s, dom))
Can this parse be called within parse_line()? So parsing and validation
are before real write. If any parsing error, no write. Otherwise,
partial write or roll back may happen.
> + return -EINVAL;
> + }
> +
> + ret = resctrl_arch_update_domains(r, rdtgrp->closid);
> + if (ret)
> + goto out;
r->dspri_store = false here?
> + }
> }
> }
>
Thanks.
-Fenghua
next prev parent reply other threads:[~2023-08-17 17:28 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 15:27 [RFC 00/12] ARM: MPAM: add support for priority partitioning control Amit Singh Tomar
2023-08-15 15:27 ` [RFC 01/12] arm_mpam: Handle resource instances mapped to different controls Amit Singh Tomar
2023-09-01 12:39 ` Jonathan Cameron
2023-08-15 15:27 ` [RFC 02/12] arm_mpam: resctrl: Detect priority partitioning capability Amit Singh Tomar
2023-09-01 12:30 ` Jonathan Cameron
2023-08-15 15:27 ` [RFC 03/12] arm_mpam: resctrl: Define new schemata format for priority partition Amit Singh Tomar
2023-08-15 15:27 ` [RFC 04/12] fs/resctrl: Obtain CPBM upon priority partition presence Amit Singh Tomar
2023-08-15 15:27 ` [RFC 05/12] fs/resctrl: Set-up downstream priority partition resources Amit Singh Tomar
2023-08-17 17:39 ` Fenghua Yu
2023-08-15 15:27 ` [RFC 06/12] fs/resctrl: Extend schemata read for priority partition control Amit Singh Tomar
2023-08-17 17:42 ` Fenghua Yu
2023-08-15 15:27 ` [RFC 07/12] arm_mpam: resctrl: Retrieve priority values from arch code Amit Singh Tomar
2023-08-15 15:27 ` [RFC 08/12] fs/resctrl: Schemata write only for intended resource Amit Singh Tomar
2023-08-15 15:27 ` [RFC 09/12] fs/resctrl: Extend schemata write for priority partition control Amit Singh Tomar
2023-08-17 17:27 ` Fenghua Yu [this message]
2023-08-17 17:53 ` Fenghua Yu
2023-08-15 15:27 ` [RFC 10/12] arm_mpam: resctrl: Facilitate writing downstream priority value Amit Singh Tomar
2023-08-15 15:27 ` [RFC 11/12] arm_mpam: Fix Downstream priority mask Amit Singh Tomar
2023-09-01 13:32 ` Jonathan Cameron
2023-08-15 15:27 ` [RFC 12/12] arm_mpam: Program Downstream priority value Amit Singh Tomar
2023-09-01 13:17 ` Jonathan Cameron
2023-08-17 19:11 ` [RFC 00/12] ARM: MPAM: add support for priority partitioning control Reinette Chatre
2023-08-17 20:29 ` Reinette Chatre
2023-08-22 12:44 ` [EXT] " Amit Singh Tomar
2023-08-23 19:06 ` Reinette Chatre
2023-08-23 21:33 ` Amit Singh Tomar
2023-08-23 22:20 ` Reinette Chatre
2023-08-23 22:36 ` Luck, Tony
2023-08-24 8:52 ` Amit Singh Tomar
2023-08-24 15:30 ` Luck, Tony
2023-08-24 18:00 ` Reinette Chatre
2024-01-11 20:56 ` Peter Newman
2024-01-11 21:40 ` Tony Luck
2024-01-11 22:01 ` Reinette Chatre
2024-01-11 23:14 ` Luck, Tony
2024-01-11 23:31 ` Reinette Chatre
2023-08-22 9:01 ` Peter Newman
2023-09-01 14:42 ` Jonathan Cameron
2023-09-01 15:04 ` Jonathan Cameron
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=944e7e64-509b-c916-5166-13e7bfe2161b@intel.com \
--to=fenghua.yu@intel.com \
--cc=amitsinght@marvell.com \
--cc=gcherian@marvell.com \
--cc=james.morse@arm.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®