parse_cbm() and parse_bw() require mode and CLOSID to validate the Capacity
Bit Mask (CBM). It is passed via struct rdtgroup in struct rdt_parse_data.
The io_alloc feature also uses CBMs to indicate which portions of cache are
allocated for I/O traffic. The CBMs are provided by user space and need to
be validated the same as CBMs provided for general (CPU) cache allocation.
parse_cbm() cannot be used as-is since io_alloc does not have rdtgroup
context.
Pass the mode and CLOSID directly to parse_cbm() via struct rdt_parse_data
instead of through the rdtgroup struct to facilitate calling parse_cbm() to
verify the CBM of the io_alloc feature.
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
v8: Rephrase of changelog.
v7: Rephrase of changelog.
v6: Changed the subject line to fs/resctrl.
v5: Resolved conflicts due to recent resctrl FS/ARCH code restructure.
v4: New patch to call parse_cbm() directly to avoid code duplication.
---
fs/resctrl/ctrlmondata.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index edb9dd131eed..641094aac322 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -24,7 +24,8 @@
#include "internal.h"
struct rdt_parse_data {
- struct rdtgroup *rdtgrp;
+ u32 closid;
+ enum rdtgrp_mode mode;
char *buf;
};
@@ -77,8 +78,8 @@ static int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,
struct rdt_ctrl_domain *d)
{
struct resctrl_staged_config *cfg;
- u32 closid = data->rdtgrp->closid;
struct rdt_resource *r = s->res;
+ u32 closid = data->closid;
u32 bw_val;
cfg = &d->staged_config[s->conf_type];
@@ -156,9 +157,10 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
struct rdt_ctrl_domain *d)
{
- struct rdtgroup *rdtgrp = data->rdtgrp;
+ enum rdtgrp_mode mode = data->mode;
struct resctrl_staged_config *cfg;
struct rdt_resource *r = s->res;
+ u32 closid = data->closid;
u32 cbm_val;
cfg = &d->staged_config[s->conf_type];
@@ -171,7 +173,7 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
* Cannot set up more than one pseudo-locked region in a cache
* hierarchy.
*/
- if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP &&
+ if (mode == RDT_MODE_PSEUDO_LOCKSETUP &&
rdtgroup_pseudo_locked_in_hierarchy(d)) {
rdt_last_cmd_puts("Pseudo-locked region in hierarchy\n");
return -EINVAL;
@@ -180,8 +182,8 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
if (!cbm_validate(data->buf, &cbm_val, r))
return -EINVAL;
- if ((rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
- rdtgrp->mode == RDT_MODE_SHAREABLE) &&
+ if ((mode == RDT_MODE_EXCLUSIVE ||
+ mode == RDT_MODE_SHAREABLE) &&
rdtgroup_cbm_overlaps_pseudo_locked(d, cbm_val)) {
rdt_last_cmd_puts("CBM overlaps with pseudo-locked region\n");
return -EINVAL;
@@ -191,14 +193,14 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
* The CBM may not overlap with the CBM of another closid if
* either is exclusive.
*/
- if (rdtgroup_cbm_overlaps(s, d, cbm_val, rdtgrp->closid, true)) {
+ if (rdtgroup_cbm_overlaps(s, d, cbm_val, closid, true)) {
rdt_last_cmd_puts("Overlaps with exclusive group\n");
return -EINVAL;
}
- if (rdtgroup_cbm_overlaps(s, d, cbm_val, rdtgrp->closid, false)) {
- if (rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
- rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
+ if (rdtgroup_cbm_overlaps(s, d, cbm_val, closid, false)) {
+ if (mode == RDT_MODE_EXCLUSIVE ||
+ mode == RDT_MODE_PSEUDO_LOCKSETUP) {
rdt_last_cmd_puts("Overlaps with other group\n");
return -EINVAL;
}
@@ -262,7 +264,8 @@ static int parse_line(char *line, struct resctrl_schema *s,
list_for_each_entry(d, &r->ctrl_domains, hdr.list) {
if (d->hdr.id == dom_id) {
data.buf = dom;
- data.rdtgrp = rdtgrp;
+ data.closid = rdtgrp->closid;
+ data.mode = rdtgrp->mode;
if (parse_ctrlval(&data, s, d))
return -EINVAL;
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
--
2.34.1
Hi Babu,
On 8/5/25 4:30 PM, Babu Moger wrote:
> parse_cbm() and parse_bw() require mode and CLOSID to validate the Capacity
Again [1], parse_bw() does not validate any CBMs.
To be more specific: "mode" -> "resource group mode"?
> Bit Mask (CBM). It is passed via struct rdtgroup in struct rdt_parse_data.
>
> The io_alloc feature also uses CBMs to indicate which portions of cache are
> allocated for I/O traffic. The CBMs are provided by user space and need to
> be validated the same as CBMs provided for general (CPU) cache allocation.
> parse_cbm() cannot be used as-is since io_alloc does not have rdtgroup
> context.
>
> Pass the mode and CLOSID directly to parse_cbm() via struct rdt_parse_data
> instead of through the rdtgroup struct to facilitate calling parse_cbm() to
> verify the CBM of the io_alloc feature.
>
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---
...
> @@ -156,9 +157,10 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
> static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
> struct rdt_ctrl_domain *d)
> {
> - struct rdtgroup *rdtgrp = data->rdtgrp;
> + enum rdtgrp_mode mode = data->mode;
> struct resctrl_staged_config *cfg;
> struct rdt_resource *r = s->res;
> + u32 closid = data->closid;
> u32 cbm_val;
>
> cfg = &d->staged_config[s->conf_type];
> @@ -171,7 +173,7 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
> * Cannot set up more than one pseudo-locked region in a cache
> * hierarchy.
> */
> - if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP &&
> + if (mode == RDT_MODE_PSEUDO_LOCKSETUP &&
> rdtgroup_pseudo_locked_in_hierarchy(d)) {
> rdt_last_cmd_puts("Pseudo-locked region in hierarchy\n");
> return -EINVAL;
> @@ -180,8 +182,8 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
> if (!cbm_validate(data->buf, &cbm_val, r))
> return -EINVAL;
>
> - if ((rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
> - rdtgrp->mode == RDT_MODE_SHAREABLE) &&
> + if ((mode == RDT_MODE_EXCLUSIVE ||
> + mode == RDT_MODE_SHAREABLE) &&
This can now be on one line?
> rdtgroup_cbm_overlaps_pseudo_locked(d, cbm_val)) {
> rdt_last_cmd_puts("CBM overlaps with pseudo-locked region\n");
> return -EINVAL;
Reinette
[1] https://lore.kernel.org/lkml/798ba4db-3ac2-44a9-9e0d-e9cbb0dbff45@intel.com/
Hi Reinette,
On 8/7/25 20:52, Reinette Chatre wrote:
> Hi Babu,
>
> On 8/5/25 4:30 PM, Babu Moger wrote:
>> parse_cbm() and parse_bw() require mode and CLOSID to validate the Capacity
>
> Again [1], parse_bw() does not validate any CBMs.
Removed parse_bw() reference.
>
> To be more specific: "mode" -> "resource group mode"?
Sure.
>
>> Bit Mask (CBM). It is passed via struct rdtgroup in struct rdt_parse_data.
>>
>> The io_alloc feature also uses CBMs to indicate which portions of cache are
>> allocated for I/O traffic. The CBMs are provided by user space and need to
>> be validated the same as CBMs provided for general (CPU) cache allocation.
>> parse_cbm() cannot be used as-is since io_alloc does not have rdtgroup
>> context.
>>
>> Pass the mode and CLOSID directly to parse_cbm() via struct rdt_parse_data
>> instead of through the rdtgroup struct to facilitate calling parse_cbm() to
>> verify the CBM of the io_alloc feature.
>>
>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>> ---
>
> ...
>
>> @@ -156,9 +157,10 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
>> static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
>> struct rdt_ctrl_domain *d)
>> {
>> - struct rdtgroup *rdtgrp = data->rdtgrp;
>> + enum rdtgrp_mode mode = data->mode;
>> struct resctrl_staged_config *cfg;
>> struct rdt_resource *r = s->res;
>> + u32 closid = data->closid;
>> u32 cbm_val;
>>
>> cfg = &d->staged_config[s->conf_type];
>> @@ -171,7 +173,7 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
>> * Cannot set up more than one pseudo-locked region in a cache
>> * hierarchy.
>> */
>> - if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP &&
>> + if (mode == RDT_MODE_PSEUDO_LOCKSETUP &&
>> rdtgroup_pseudo_locked_in_hierarchy(d)) {
>> rdt_last_cmd_puts("Pseudo-locked region in hierarchy\n");
>> return -EINVAL;
>> @@ -180,8 +182,8 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
>> if (!cbm_validate(data->buf, &cbm_val, r))
>> return -EINVAL;
>>
>> - if ((rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
>> - rdtgrp->mode == RDT_MODE_SHAREABLE) &&
>> + if ((mode == RDT_MODE_EXCLUSIVE ||
>> + mode == RDT_MODE_SHAREABLE) &&
>
> This can now be on one line?
Sure.
>
>> rdtgroup_cbm_overlaps_pseudo_locked(d, cbm_val)) {
>> rdt_last_cmd_puts("CBM overlaps with pseudo-locked region\n");
>> return -EINVAL;
>
> Reinette
>
> [1] https://lore.kernel.org/lkml/798ba4db-3ac2-44a9-9e0d-e9cbb0dbff45@intel.com/
>
--
Thanks
Babu Moger
© 2016 - 2026 Red Hat, Inc.