Skip to content

Commit 75408e4

Browse files
James Morsesuryasaimadhu
authored andcommitted
x86/resctrl: Allow different CODE/DATA configurations to be staged
Before the CDP resources can be merged, struct rdt_domain will need an array of struct resctrl_staged_config, one per type of configuration. Use the type as an index to the array to ensure that a schema configuration string can't specify the same domain twice. This will allow two schemata to apply configuration changes to one resource. Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Jamie Iles <jamie@nuviainc.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Tested-by: Babu Moger <babu.moger@amd.com> Link: https://lkml.kernel.org/r/20210728170637.25610-15-james.morse@arm.com
1 parent e8f7282 commit 75408e4

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

arch/x86/kernel/cpu/resctrl/ctrlmondata.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
6060
int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,
6161
struct rdt_domain *d)
6262
{
63+
struct resctrl_staged_config *cfg;
6364
struct rdt_resource *r = s->res;
6465
unsigned long bw_val;
65-
struct resctrl_staged_config *cfg = &d->staged_config;
6666

67+
cfg = &d->staged_config[s->conf_type];
6768
if (cfg->have_new_ctrl) {
6869
rdt_last_cmd_printf("Duplicate domain %d\n", d->id);
6970
return -EINVAL;
@@ -130,11 +131,12 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
130131
int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
131132
struct rdt_domain *d)
132133
{
133-
struct resctrl_staged_config *cfg = &d->staged_config;
134134
struct rdtgroup *rdtgrp = data->rdtgrp;
135+
struct resctrl_staged_config *cfg;
135136
struct rdt_resource *r = s->res;
136137
u32 cbm_val;
137138

139+
cfg = &d->staged_config[s->conf_type];
138140
if (cfg->have_new_ctrl) {
139141
rdt_last_cmd_printf("Duplicate domain %d\n", d->id);
140142
return -EINVAL;
@@ -192,6 +194,7 @@ int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
192194
static int parse_line(char *line, struct resctrl_schema *s,
193195
struct rdtgroup *rdtgrp)
194196
{
197+
enum resctrl_conf_type t = s->conf_type;
195198
struct resctrl_staged_config *cfg;
196199
struct rdt_resource *r = s->res;
197200
struct rdt_parse_data data;
@@ -222,7 +225,7 @@ static int parse_line(char *line, struct resctrl_schema *s,
222225
if (r->parse_ctrlval(&data, s, d))
223226
return -EINVAL;
224227
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
225-
cfg = &d->staged_config;
228+
cfg = &d->staged_config[t];
226229
/*
227230
* In pseudo-locking setup mode and just
228231
* parsed a valid CBM that should be
@@ -261,6 +264,7 @@ int update_domains(struct rdt_resource *r, int closid)
261264
struct resctrl_staged_config *cfg;
262265
struct rdt_hw_domain *hw_dom;
263266
struct msr_param msr_param;
267+
enum resctrl_conf_type t;
264268
cpumask_var_t cpu_mask;
265269
struct rdt_domain *d;
266270
bool mba_sc;
@@ -276,9 +280,13 @@ int update_domains(struct rdt_resource *r, int closid)
276280
mba_sc = is_mba_sc(r);
277281
list_for_each_entry(d, &r->domains, list) {
278282
hw_dom = resctrl_to_arch_dom(d);
279-
cfg = &hw_dom->d_resctrl.staged_config;
280-
if (cfg->have_new_ctrl)
283+
for (t = 0; t < CDP_NUM_TYPES; t++) {
284+
cfg = &hw_dom->d_resctrl.staged_config[t];
285+
if (!cfg->have_new_ctrl)
286+
continue;
287+
281288
apply_config(hw_dom, cfg, closid, cpu_mask, mba_sc);
289+
}
282290
}
283291

284292
/*
@@ -350,7 +358,7 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
350358

351359
list_for_each_entry(s, &resctrl_schema_all, list) {
352360
list_for_each_entry(dom, &s->res->domains, list)
353-
memset(&dom->staged_config, 0, sizeof(dom->staged_config));
361+
memset(dom->staged_config, 0, sizeof(dom->staged_config));
354362
}
355363

356364
while ((tok = strsep(&buf, "\n")) != NULL) {

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,6 +2751,7 @@ static u32 cbm_ensure_valid(u32 _val, struct rdt_resource *r)
27512751
static int __init_one_rdt_domain(struct rdt_domain *d, struct resctrl_schema *s,
27522752
u32 closid)
27532753
{
2754+
enum resctrl_conf_type t = s->conf_type;
27542755
struct rdt_resource *r_cdp = NULL;
27552756
struct resctrl_staged_config *cfg;
27562757
struct rdt_domain *d_cdp = NULL;
@@ -2762,7 +2763,7 @@ static int __init_one_rdt_domain(struct rdt_domain *d, struct resctrl_schema *s,
27622763
int i;
27632764

27642765
rdt_cdp_peer_get(r, d, &r_cdp, &d_cdp);
2765-
cfg = &d->staged_config;
2766+
cfg = &d->staged_config[t];
27662767
cfg->have_new_ctrl = false;
27672768
cfg->new_ctrl = r->cache.shareable_bits;
27682769
used_b = r->cache.shareable_bits;
@@ -2846,7 +2847,7 @@ static void rdtgroup_init_mba(struct rdt_resource *r)
28462847
struct rdt_domain *d;
28472848

28482849
list_for_each_entry(d, &r->domains, list) {
2849-
cfg = &d->staged_config;
2850+
cfg = &d->staged_config[CDP_NONE];
28502851
cfg->new_ctrl = is_mba_sc(r) ? MBA_MAX_MBPS : r->default_ctrl;
28512852
cfg->have_new_ctrl = true;
28522853
}

include/linux/resctrl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ enum resctrl_conf_type {
2727
CDP_DATA,
2828
};
2929

30+
#define CDP_NUM_TYPES (CDP_DATA + 1)
31+
3032
/**
3133
* struct resctrl_staged_config - parsed configuration to be applied
3234
* @new_ctrl: new ctrl value to be loaded
@@ -64,7 +66,7 @@ struct rdt_domain {
6466
int mbm_work_cpu;
6567
int cqm_work_cpu;
6668
struct pseudo_lock_region *plr;
67-
struct resctrl_staged_config staged_config;
69+
struct resctrl_staged_config staged_config[CDP_NUM_TYPES];
6870
};
6971

7072
/**

0 commit comments

Comments
 (0)