Skip to content

Commit af1242e

Browse files
babumogerbp3tk0v
authored andcommitted
fs/resctrl: Modify struct rdt_parse_data to pass mode and CLOSID
parse_cbm() requires resource group mode and CLOSID to validate the capacity bitmask (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 resource group 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> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://patch.msgid.link/f8ec6ab5cf594d906a3fe75f56793d5fbd63f38f.1762995456.git.babu.moger@amd.com
1 parent 77b6623 commit af1242e

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

fs/resctrl/ctrlmondata.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
#include "internal.h"
2525

2626
struct rdt_parse_data {
27-
struct rdtgroup *rdtgrp;
27+
u32 closid;
28+
enum rdtgrp_mode mode;
2829
char *buf;
2930
};
3031

@@ -77,8 +78,8 @@ static int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,
7778
struct rdt_ctrl_domain *d)
7879
{
7980
struct resctrl_staged_config *cfg;
80-
u32 closid = data->rdtgrp->closid;
8181
struct rdt_resource *r = s->res;
82+
u32 closid = data->closid;
8283
u32 bw_val;
8384

8485
cfg = &d->staged_config[s->conf_type];
@@ -156,9 +157,10 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
156157
static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
157158
struct rdt_ctrl_domain *d)
158159
{
159-
struct rdtgroup *rdtgrp = data->rdtgrp;
160+
enum rdtgrp_mode mode = data->mode;
160161
struct resctrl_staged_config *cfg;
161162
struct rdt_resource *r = s->res;
163+
u32 closid = data->closid;
162164
u32 cbm_val;
163165

164166
cfg = &d->staged_config[s->conf_type];
@@ -171,7 +173,7 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
171173
* Cannot set up more than one pseudo-locked region in a cache
172174
* hierarchy.
173175
*/
174-
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP &&
176+
if (mode == RDT_MODE_PSEUDO_LOCKSETUP &&
175177
rdtgroup_pseudo_locked_in_hierarchy(d)) {
176178
rdt_last_cmd_puts("Pseudo-locked region in hierarchy\n");
177179
return -EINVAL;
@@ -180,8 +182,7 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
180182
if (!cbm_validate(data->buf, &cbm_val, r))
181183
return -EINVAL;
182184

183-
if ((rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
184-
rdtgrp->mode == RDT_MODE_SHAREABLE) &&
185+
if ((mode == RDT_MODE_EXCLUSIVE || mode == RDT_MODE_SHAREABLE) &&
185186
rdtgroup_cbm_overlaps_pseudo_locked(d, cbm_val)) {
186187
rdt_last_cmd_puts("CBM overlaps with pseudo-locked region\n");
187188
return -EINVAL;
@@ -191,14 +192,14 @@ static int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
191192
* The CBM may not overlap with the CBM of another closid if
192193
* either is exclusive.
193194
*/
194-
if (rdtgroup_cbm_overlaps(s, d, cbm_val, rdtgrp->closid, true)) {
195+
if (rdtgroup_cbm_overlaps(s, d, cbm_val, closid, true)) {
195196
rdt_last_cmd_puts("Overlaps with exclusive group\n");
196197
return -EINVAL;
197198
}
198199

199-
if (rdtgroup_cbm_overlaps(s, d, cbm_val, rdtgrp->closid, false)) {
200-
if (rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
201-
rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
200+
if (rdtgroup_cbm_overlaps(s, d, cbm_val, closid, false)) {
201+
if (mode == RDT_MODE_EXCLUSIVE ||
202+
mode == RDT_MODE_PSEUDO_LOCKSETUP) {
202203
rdt_last_cmd_puts("Overlaps with other group\n");
203204
return -EINVAL;
204205
}
@@ -262,7 +263,8 @@ static int parse_line(char *line, struct resctrl_schema *s,
262263
list_for_each_entry(d, &r->ctrl_domains, hdr.list) {
263264
if (d->hdr.id == dom_id) {
264265
data.buf = dom;
265-
data.rdtgrp = rdtgrp;
266+
data.closid = rdtgrp->closid;
267+
data.mode = rdtgrp->mode;
266268
if (parse_ctrlval(&data, s, d))
267269
return -EINVAL;
268270
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {

0 commit comments

Comments
 (0)