Commit cae2bcb6 authored by Tony Luck's avatar Tony Luck Committed by Borislav Petkov (AMD)

x86/resctrl: Split the rdt_domain and rdt_hw_domain structures

The same rdt_domain structure is used for both control and monitor
functions. But this results in wasted memory as some of the fields are
only used by control functions, while most are only used for monitor
functions.

Split into separate rdt_ctrl_domain and rdt_mon_domain structures with
just the fields required for control and monitoring respectively.

Similar split of the rdt_hw_domain structure into rdt_hw_ctrl_domain
and rdt_hw_mon_domain.
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Tested-by: default avatarBabu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/r/20240628215619.76401-5-tony.luck@intel.com
parent cd84f72b
...@@ -309,8 +309,8 @@ static void rdt_get_cdp_l2_config(void) ...@@ -309,8 +309,8 @@ static void rdt_get_cdp_l2_config(void)
static void mba_wrmsr_amd(struct msr_param *m) static void mba_wrmsr_amd(struct msr_param *m)
{ {
struct rdt_hw_ctrl_domain *hw_dom = resctrl_to_arch_ctrl_dom(m->dom);
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(m->res); struct rdt_hw_resource *hw_res = resctrl_to_arch_res(m->res);
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(m->dom);
unsigned int i; unsigned int i;
for (i = m->low; i < m->high; i++) for (i = m->low; i < m->high; i++)
...@@ -333,8 +333,8 @@ static u32 delay_bw_map(unsigned long bw, struct rdt_resource *r) ...@@ -333,8 +333,8 @@ static u32 delay_bw_map(unsigned long bw, struct rdt_resource *r)
static void mba_wrmsr_intel(struct msr_param *m) static void mba_wrmsr_intel(struct msr_param *m)
{ {
struct rdt_hw_ctrl_domain *hw_dom = resctrl_to_arch_ctrl_dom(m->dom);
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(m->res); struct rdt_hw_resource *hw_res = resctrl_to_arch_res(m->res);
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(m->dom);
unsigned int i; unsigned int i;
/* Write the delay values for mba. */ /* Write the delay values for mba. */
...@@ -344,17 +344,17 @@ static void mba_wrmsr_intel(struct msr_param *m) ...@@ -344,17 +344,17 @@ static void mba_wrmsr_intel(struct msr_param *m)
static void cat_wrmsr(struct msr_param *m) static void cat_wrmsr(struct msr_param *m)
{ {
struct rdt_hw_ctrl_domain *hw_dom = resctrl_to_arch_ctrl_dom(m->dom);
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(m->res); struct rdt_hw_resource *hw_res = resctrl_to_arch_res(m->res);
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(m->dom);
unsigned int i; unsigned int i;
for (i = m->low; i < m->high; i++) for (i = m->low; i < m->high; i++)
wrmsrl(hw_res->msr_base + i, hw_dom->ctrl_val[i]); wrmsrl(hw_res->msr_base + i, hw_dom->ctrl_val[i]);
} }
struct rdt_domain *get_ctrl_domain_from_cpu(int cpu, struct rdt_resource *r) struct rdt_ctrl_domain *get_ctrl_domain_from_cpu(int cpu, struct rdt_resource *r)
{ {
struct rdt_domain *d; struct rdt_ctrl_domain *d;
lockdep_assert_cpus_held(); lockdep_assert_cpus_held();
...@@ -367,9 +367,9 @@ struct rdt_domain *get_ctrl_domain_from_cpu(int cpu, struct rdt_resource *r) ...@@ -367,9 +367,9 @@ struct rdt_domain *get_ctrl_domain_from_cpu(int cpu, struct rdt_resource *r)
return NULL; return NULL;
} }
struct rdt_domain *get_mon_domain_from_cpu(int cpu, struct rdt_resource *r) struct rdt_mon_domain *get_mon_domain_from_cpu(int cpu, struct rdt_resource *r)
{ {
struct rdt_domain *d; struct rdt_mon_domain *d;
lockdep_assert_cpus_held(); lockdep_assert_cpus_held();
...@@ -440,18 +440,23 @@ static void setup_default_ctrlval(struct rdt_resource *r, u32 *dc) ...@@ -440,18 +440,23 @@ static void setup_default_ctrlval(struct rdt_resource *r, u32 *dc)
*dc = r->default_ctrl; *dc = r->default_ctrl;
} }
static void domain_free(struct rdt_hw_domain *hw_dom) static void ctrl_domain_free(struct rdt_hw_ctrl_domain *hw_dom)
{
kfree(hw_dom->ctrl_val);
kfree(hw_dom);
}
static void mon_domain_free(struct rdt_hw_mon_domain *hw_dom)
{ {
kfree(hw_dom->arch_mbm_total); kfree(hw_dom->arch_mbm_total);
kfree(hw_dom->arch_mbm_local); kfree(hw_dom->arch_mbm_local);
kfree(hw_dom->ctrl_val);
kfree(hw_dom); kfree(hw_dom);
} }
static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_domain *d) static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_ctrl_domain *d)
{ {
struct rdt_hw_ctrl_domain *hw_dom = resctrl_to_arch_ctrl_dom(d);
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d);
struct msr_param m; struct msr_param m;
u32 *dc; u32 *dc;
...@@ -476,7 +481,7 @@ static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_domain *d) ...@@ -476,7 +481,7 @@ static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_domain *d)
* @num_rmid: The size of the MBM counter array * @num_rmid: The size of the MBM counter array
* @hw_dom: The domain that owns the allocated arrays * @hw_dom: The domain that owns the allocated arrays
*/ */
static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_domain *hw_dom) static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_mon_domain *hw_dom)
{ {
size_t tsize; size_t tsize;
...@@ -515,10 +520,10 @@ static int get_domain_id_from_scope(int cpu, enum resctrl_scope scope) ...@@ -515,10 +520,10 @@ static int get_domain_id_from_scope(int cpu, enum resctrl_scope scope)
static void domain_add_cpu_ctrl(int cpu, struct rdt_resource *r) static void domain_add_cpu_ctrl(int cpu, struct rdt_resource *r)
{ {
int id = get_domain_id_from_scope(cpu, r->ctrl_scope); int id = get_domain_id_from_scope(cpu, r->ctrl_scope);
struct rdt_hw_ctrl_domain *hw_dom;
struct list_head *add_pos = NULL; struct list_head *add_pos = NULL;
struct rdt_hw_domain *hw_dom;
struct rdt_domain_hdr *hdr; struct rdt_domain_hdr *hdr;
struct rdt_domain *d; struct rdt_ctrl_domain *d;
int err; int err;
lockdep_assert_held(&domain_list_lock); lockdep_assert_held(&domain_list_lock);
...@@ -533,7 +538,7 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_resource *r) ...@@ -533,7 +538,7 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_resource *r)
if (hdr) { if (hdr) {
if (WARN_ON_ONCE(hdr->type != RESCTRL_CTRL_DOMAIN)) if (WARN_ON_ONCE(hdr->type != RESCTRL_CTRL_DOMAIN))
return; return;
d = container_of(hdr, struct rdt_domain, hdr); d = container_of(hdr, struct rdt_ctrl_domain, hdr);
cpumask_set_cpu(cpu, &d->hdr.cpu_mask); cpumask_set_cpu(cpu, &d->hdr.cpu_mask);
if (r->cache.arch_has_per_cpu_cfg) if (r->cache.arch_has_per_cpu_cfg)
...@@ -553,7 +558,7 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_resource *r) ...@@ -553,7 +558,7 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_resource *r)
rdt_domain_reconfigure_cdp(r); rdt_domain_reconfigure_cdp(r);
if (domain_setup_ctrlval(r, d)) { if (domain_setup_ctrlval(r, d)) {
domain_free(hw_dom); ctrl_domain_free(hw_dom);
return; return;
} }
...@@ -563,7 +568,7 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_resource *r) ...@@ -563,7 +568,7 @@ static void domain_add_cpu_ctrl(int cpu, struct rdt_resource *r)
if (err) { if (err) {
list_del_rcu(&d->hdr.list); list_del_rcu(&d->hdr.list);
synchronize_rcu(); synchronize_rcu();
domain_free(hw_dom); ctrl_domain_free(hw_dom);
} }
} }
...@@ -571,9 +576,9 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) ...@@ -571,9 +576,9 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
{ {
int id = get_domain_id_from_scope(cpu, r->mon_scope); int id = get_domain_id_from_scope(cpu, r->mon_scope);
struct list_head *add_pos = NULL; struct list_head *add_pos = NULL;
struct rdt_hw_domain *hw_dom; struct rdt_hw_mon_domain *hw_dom;
struct rdt_domain_hdr *hdr; struct rdt_domain_hdr *hdr;
struct rdt_domain *d; struct rdt_mon_domain *d;
int err; int err;
lockdep_assert_held(&domain_list_lock); lockdep_assert_held(&domain_list_lock);
...@@ -588,7 +593,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) ...@@ -588,7 +593,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
if (hdr) { if (hdr) {
if (WARN_ON_ONCE(hdr->type != RESCTRL_MON_DOMAIN)) if (WARN_ON_ONCE(hdr->type != RESCTRL_MON_DOMAIN))
return; return;
d = container_of(hdr, struct rdt_domain, hdr); d = container_of(hdr, struct rdt_mon_domain, hdr);
cpumask_set_cpu(cpu, &d->hdr.cpu_mask); cpumask_set_cpu(cpu, &d->hdr.cpu_mask);
return; return;
...@@ -604,7 +609,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) ...@@ -604,7 +609,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
cpumask_set_cpu(cpu, &d->hdr.cpu_mask); cpumask_set_cpu(cpu, &d->hdr.cpu_mask);
if (arch_domain_mbm_alloc(r->num_rmid, hw_dom)) { if (arch_domain_mbm_alloc(r->num_rmid, hw_dom)) {
domain_free(hw_dom); mon_domain_free(hw_dom);
return; return;
} }
...@@ -614,7 +619,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) ...@@ -614,7 +619,7 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r)
if (err) { if (err) {
list_del_rcu(&d->hdr.list); list_del_rcu(&d->hdr.list);
synchronize_rcu(); synchronize_rcu();
domain_free(hw_dom); mon_domain_free(hw_dom);
} }
} }
...@@ -629,9 +634,9 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r) ...@@ -629,9 +634,9 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r)
static void domain_remove_cpu_ctrl(int cpu, struct rdt_resource *r) static void domain_remove_cpu_ctrl(int cpu, struct rdt_resource *r)
{ {
int id = get_domain_id_from_scope(cpu, r->ctrl_scope); int id = get_domain_id_from_scope(cpu, r->ctrl_scope);
struct rdt_hw_domain *hw_dom; struct rdt_hw_ctrl_domain *hw_dom;
struct rdt_domain_hdr *hdr; struct rdt_domain_hdr *hdr;
struct rdt_domain *d; struct rdt_ctrl_domain *d;
lockdep_assert_held(&domain_list_lock); lockdep_assert_held(&domain_list_lock);
...@@ -651,8 +656,8 @@ static void domain_remove_cpu_ctrl(int cpu, struct rdt_resource *r) ...@@ -651,8 +656,8 @@ static void domain_remove_cpu_ctrl(int cpu, struct rdt_resource *r)
if (WARN_ON_ONCE(hdr->type != RESCTRL_CTRL_DOMAIN)) if (WARN_ON_ONCE(hdr->type != RESCTRL_CTRL_DOMAIN))
return; return;
d = container_of(hdr, struct rdt_domain, hdr); d = container_of(hdr, struct rdt_ctrl_domain, hdr);
hw_dom = resctrl_to_arch_dom(d); hw_dom = resctrl_to_arch_ctrl_dom(d);
cpumask_clear_cpu(cpu, &d->hdr.cpu_mask); cpumask_clear_cpu(cpu, &d->hdr.cpu_mask);
if (cpumask_empty(&d->hdr.cpu_mask)) { if (cpumask_empty(&d->hdr.cpu_mask)) {
...@@ -661,12 +666,12 @@ static void domain_remove_cpu_ctrl(int cpu, struct rdt_resource *r) ...@@ -661,12 +666,12 @@ static void domain_remove_cpu_ctrl(int cpu, struct rdt_resource *r)
synchronize_rcu(); synchronize_rcu();
/* /*
* rdt_domain "d" is going to be freed below, so clear * rdt_ctrl_domain "d" is going to be freed below, so clear
* its pointer from pseudo_lock_region struct. * its pointer from pseudo_lock_region struct.
*/ */
if (d->plr) if (d->plr)
d->plr->d = NULL; d->plr->d = NULL;
domain_free(hw_dom); ctrl_domain_free(hw_dom);
return; return;
} }
...@@ -675,9 +680,9 @@ static void domain_remove_cpu_ctrl(int cpu, struct rdt_resource *r) ...@@ -675,9 +680,9 @@ static void domain_remove_cpu_ctrl(int cpu, struct rdt_resource *r)
static void domain_remove_cpu_mon(int cpu, struct rdt_resource *r) static void domain_remove_cpu_mon(int cpu, struct rdt_resource *r)
{ {
int id = get_domain_id_from_scope(cpu, r->mon_scope); int id = get_domain_id_from_scope(cpu, r->mon_scope);
struct rdt_hw_domain *hw_dom; struct rdt_hw_mon_domain *hw_dom;
struct rdt_domain_hdr *hdr; struct rdt_domain_hdr *hdr;
struct rdt_domain *d; struct rdt_mon_domain *d;
lockdep_assert_held(&domain_list_lock); lockdep_assert_held(&domain_list_lock);
...@@ -697,15 +702,15 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_resource *r) ...@@ -697,15 +702,15 @@ static void domain_remove_cpu_mon(int cpu, struct rdt_resource *r)
if (WARN_ON_ONCE(hdr->type != RESCTRL_MON_DOMAIN)) if (WARN_ON_ONCE(hdr->type != RESCTRL_MON_DOMAIN))
return; return;
d = container_of(hdr, struct rdt_domain, hdr); d = container_of(hdr, struct rdt_mon_domain, hdr);
hw_dom = resctrl_to_arch_dom(d); hw_dom = resctrl_to_arch_mon_dom(d);
cpumask_clear_cpu(cpu, &d->hdr.cpu_mask); cpumask_clear_cpu(cpu, &d->hdr.cpu_mask);
if (cpumask_empty(&d->hdr.cpu_mask)) { if (cpumask_empty(&d->hdr.cpu_mask)) {
resctrl_offline_mon_domain(r, d); resctrl_offline_mon_domain(r, d);
list_del_rcu(&d->hdr.list); list_del_rcu(&d->hdr.list);
synchronize_rcu(); synchronize_rcu();
domain_free(hw_dom); mon_domain_free(hw_dom);
return; return;
} }
......
...@@ -60,7 +60,7 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r) ...@@ -60,7 +60,7 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
} }
int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s, int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,
struct rdt_domain *d) struct rdt_ctrl_domain *d)
{ {
struct resctrl_staged_config *cfg; struct resctrl_staged_config *cfg;
u32 closid = data->rdtgrp->closid; u32 closid = data->rdtgrp->closid;
...@@ -139,7 +139,7 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r) ...@@ -139,7 +139,7 @@ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
* resource type. * resource type.
*/ */
int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
struct rdt_domain *d) struct rdt_ctrl_domain *d)
{ {
struct rdtgroup *rdtgrp = data->rdtgrp; struct rdtgroup *rdtgrp = data->rdtgrp;
struct resctrl_staged_config *cfg; struct resctrl_staged_config *cfg;
...@@ -208,8 +208,8 @@ static int parse_line(char *line, struct resctrl_schema *s, ...@@ -208,8 +208,8 @@ static int parse_line(char *line, struct resctrl_schema *s,
struct resctrl_staged_config *cfg; struct resctrl_staged_config *cfg;
struct rdt_resource *r = s->res; struct rdt_resource *r = s->res;
struct rdt_parse_data data; struct rdt_parse_data data;
struct rdt_ctrl_domain *d;
char *dom = NULL, *id; char *dom = NULL, *id;
struct rdt_domain *d;
unsigned long dom_id; unsigned long dom_id;
/* Walking r->domains, ensure it can't race with cpuhp */ /* Walking r->domains, ensure it can't race with cpuhp */
...@@ -272,11 +272,11 @@ static u32 get_config_index(u32 closid, enum resctrl_conf_type type) ...@@ -272,11 +272,11 @@ static u32 get_config_index(u32 closid, enum resctrl_conf_type type)
} }
} }
int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type t, u32 cfg_val) u32 closid, enum resctrl_conf_type t, u32 cfg_val)
{ {
struct rdt_hw_ctrl_domain *hw_dom = resctrl_to_arch_ctrl_dom(d);
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d);
u32 idx = get_config_index(closid, t); u32 idx = get_config_index(closid, t);
struct msr_param msr_param; struct msr_param msr_param;
...@@ -297,17 +297,17 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, ...@@ -297,17 +297,17 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d,
int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid) int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
{ {
struct resctrl_staged_config *cfg; struct resctrl_staged_config *cfg;
struct rdt_hw_domain *hw_dom; struct rdt_hw_ctrl_domain *hw_dom;
struct msr_param msr_param; struct msr_param msr_param;
struct rdt_ctrl_domain *d;
enum resctrl_conf_type t; enum resctrl_conf_type t;
struct rdt_domain *d;
u32 idx; u32 idx;
/* Walking r->domains, ensure it can't race with cpuhp */ /* Walking r->domains, ensure it can't race with cpuhp */
lockdep_assert_cpus_held(); lockdep_assert_cpus_held();
list_for_each_entry(d, &r->ctrl_domains, hdr.list) { list_for_each_entry(d, &r->ctrl_domains, hdr.list) {
hw_dom = resctrl_to_arch_dom(d); hw_dom = resctrl_to_arch_ctrl_dom(d);
msr_param.res = NULL; msr_param.res = NULL;
for (t = 0; t < CDP_NUM_TYPES; t++) { for (t = 0; t < CDP_NUM_TYPES; t++) {
cfg = &hw_dom->d_resctrl.staged_config[t]; cfg = &hw_dom->d_resctrl.staged_config[t];
...@@ -430,10 +430,10 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, ...@@ -430,10 +430,10 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
return ret ?: nbytes; return ret ?: nbytes;
} }
u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type type) u32 closid, enum resctrl_conf_type type)
{ {
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d); struct rdt_hw_ctrl_domain *hw_dom = resctrl_to_arch_ctrl_dom(d);
u32 idx = get_config_index(closid, type); u32 idx = get_config_index(closid, type);
return hw_dom->ctrl_val[idx]; return hw_dom->ctrl_val[idx];
...@@ -442,7 +442,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, ...@@ -442,7 +442,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d,
static void show_doms(struct seq_file *s, struct resctrl_schema *schema, int closid) static void show_doms(struct seq_file *s, struct resctrl_schema *schema, int closid)
{ {
struct rdt_resource *r = schema->res; struct rdt_resource *r = schema->res;
struct rdt_domain *dom; struct rdt_ctrl_domain *dom;
bool sep = false; bool sep = false;
u32 ctrl_val; u32 ctrl_val;
...@@ -514,7 +514,7 @@ static int smp_mon_event_count(void *arg) ...@@ -514,7 +514,7 @@ static int smp_mon_event_count(void *arg)
} }
void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
struct rdt_domain *d, struct rdtgroup *rdtgrp, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp,
int evtid, int first) int evtid, int first)
{ {
int cpu; int cpu;
...@@ -557,11 +557,11 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) ...@@ -557,11 +557,11 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
{ {
struct kernfs_open_file *of = m->private; struct kernfs_open_file *of = m->private;
struct rdt_domain_hdr *hdr; struct rdt_domain_hdr *hdr;
struct rdt_mon_domain *d;
u32 resid, evtid, domid; u32 resid, evtid, domid;
struct rdtgroup *rdtgrp; struct rdtgroup *rdtgrp;
struct rdt_resource *r; struct rdt_resource *r;
union mon_data_bits md; union mon_data_bits md;
struct rdt_domain *d;
struct rmid_read rr; struct rmid_read rr;
int ret = 0; int ret = 0;
...@@ -582,7 +582,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) ...@@ -582,7 +582,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
ret = -ENOENT; ret = -ENOENT;
goto out; goto out;
} }
d = container_of(hdr, struct rdt_domain, hdr); d = container_of(hdr, struct rdt_mon_domain, hdr);
mon_event_read(&rr, r, d, rdtgrp, evtid, false); mon_event_read(&rr, r, d, rdtgrp, evtid, false);
......
...@@ -147,7 +147,7 @@ union mon_data_bits { ...@@ -147,7 +147,7 @@ union mon_data_bits {
struct rmid_read { struct rmid_read {
struct rdtgroup *rgrp; struct rdtgroup *rgrp;
struct rdt_resource *r; struct rdt_resource *r;
struct rdt_domain *d; struct rdt_mon_domain *d;
enum resctrl_event_id evtid; enum resctrl_event_id evtid;
bool first; bool first;
int err; int err;
...@@ -232,7 +232,7 @@ struct mongroup { ...@@ -232,7 +232,7 @@ struct mongroup {
*/ */
struct pseudo_lock_region { struct pseudo_lock_region {
struct resctrl_schema *s; struct resctrl_schema *s;
struct rdt_domain *d; struct rdt_ctrl_domain *d;
u32 cbm; u32 cbm;
wait_queue_head_t lock_thread_wq; wait_queue_head_t lock_thread_wq;
int thread_done; int thread_done;
...@@ -355,25 +355,41 @@ struct arch_mbm_state { ...@@ -355,25 +355,41 @@ struct arch_mbm_state {
}; };
/** /**
* struct rdt_hw_domain - Arch private attributes of a set of CPUs that share * struct rdt_hw_ctrl_domain - Arch private attributes of a set of CPUs that share
* a resource * a resource for a control function
* @d_resctrl: Properties exposed to the resctrl file system * @d_resctrl: Properties exposed to the resctrl file system
* @ctrl_val: array of cache or mem ctrl values (indexed by CLOSID) * @ctrl_val: array of cache or mem ctrl values (indexed by CLOSID)
*
* Members of this structure are accessed via helpers that provide abstraction.
*/
struct rdt_hw_ctrl_domain {
struct rdt_ctrl_domain d_resctrl;
u32 *ctrl_val;
};
/**
* struct rdt_hw_mon_domain - Arch private attributes of a set of CPUs that share
* a resource for a monitor function
* @d_resctrl: Properties exposed to the resctrl file system
* @arch_mbm_total: arch private state for MBM total bandwidth * @arch_mbm_total: arch private state for MBM total bandwidth
* @arch_mbm_local: arch private state for MBM local bandwidth * @arch_mbm_local: arch private state for MBM local bandwidth
* *
* Members of this structure are accessed via helpers that provide abstraction. * Members of this structure are accessed via helpers that provide abstraction.
*/ */
struct rdt_hw_domain { struct rdt_hw_mon_domain {
struct rdt_domain d_resctrl; struct rdt_mon_domain d_resctrl;
u32 *ctrl_val;
struct arch_mbm_state *arch_mbm_total; struct arch_mbm_state *arch_mbm_total;
struct arch_mbm_state *arch_mbm_local; struct arch_mbm_state *arch_mbm_local;
}; };
static inline struct rdt_hw_domain *resctrl_to_arch_dom(struct rdt_domain *r) static inline struct rdt_hw_ctrl_domain *resctrl_to_arch_ctrl_dom(struct rdt_ctrl_domain *r)
{
return container_of(r, struct rdt_hw_ctrl_domain, d_resctrl);
}
static inline struct rdt_hw_mon_domain *resctrl_to_arch_mon_dom(struct rdt_mon_domain *r)
{ {
return container_of(r, struct rdt_hw_domain, d_resctrl); return container_of(r, struct rdt_hw_mon_domain, d_resctrl);
} }
/** /**
...@@ -385,7 +401,7 @@ static inline struct rdt_hw_domain *resctrl_to_arch_dom(struct rdt_domain *r) ...@@ -385,7 +401,7 @@ static inline struct rdt_hw_domain *resctrl_to_arch_dom(struct rdt_domain *r)
*/ */
struct msr_param { struct msr_param {
struct rdt_resource *res; struct rdt_resource *res;
struct rdt_domain *dom; struct rdt_ctrl_domain *dom;
u32 low; u32 low;
u32 high; u32 high;
}; };
...@@ -458,9 +474,9 @@ static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r ...@@ -458,9 +474,9 @@ static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r
} }
int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s,
struct rdt_domain *d); struct rdt_ctrl_domain *d);
int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s, int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s,
struct rdt_domain *d); struct rdt_ctrl_domain *d);
extern struct mutex rdtgroup_mutex; extern struct mutex rdtgroup_mutex;
...@@ -564,22 +580,22 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, ...@@ -564,22 +580,22 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
char *buf, size_t nbytes, loff_t off); char *buf, size_t nbytes, loff_t off);
int rdtgroup_schemata_show(struct kernfs_open_file *of, int rdtgroup_schemata_show(struct kernfs_open_file *of,
struct seq_file *s, void *v); struct seq_file *s, void *v);
bool rdtgroup_cbm_overlaps(struct resctrl_schema *s, struct rdt_domain *d, bool rdtgroup_cbm_overlaps(struct resctrl_schema *s, struct rdt_ctrl_domain *d,
unsigned long cbm, int closid, bool exclusive); unsigned long cbm, int closid, bool exclusive);
unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_domain *d, unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_ctrl_domain *d,
unsigned long cbm); unsigned long cbm);
enum rdtgrp_mode rdtgroup_mode_by_closid(int closid); enum rdtgrp_mode rdtgroup_mode_by_closid(int closid);
int rdtgroup_tasks_assigned(struct rdtgroup *r); int rdtgroup_tasks_assigned(struct rdtgroup *r);
int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp);
int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp); int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp);
bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, unsigned long cbm); bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_ctrl_domain *d, unsigned long cbm);
bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d); bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_ctrl_domain *d);
int rdt_pseudo_lock_init(void); int rdt_pseudo_lock_init(void);
void rdt_pseudo_lock_release(void); void rdt_pseudo_lock_release(void);
int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp); int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp);
void rdtgroup_pseudo_lock_remove(struct rdtgroup *rdtgrp); void rdtgroup_pseudo_lock_remove(struct rdtgroup *rdtgrp);
struct rdt_domain *get_ctrl_domain_from_cpu(int cpu, struct rdt_resource *r); struct rdt_ctrl_domain *get_ctrl_domain_from_cpu(int cpu, struct rdt_resource *r);
struct rdt_domain *get_mon_domain_from_cpu(int cpu, struct rdt_resource *r); struct rdt_mon_domain *get_mon_domain_from_cpu(int cpu, struct rdt_resource *r);
int closids_supported(void); int closids_supported(void);
void closid_free(int closid); void closid_free(int closid);
int alloc_rmid(u32 closid); int alloc_rmid(u32 closid);
...@@ -590,19 +606,19 @@ bool __init rdt_cpu_has(int flag); ...@@ -590,19 +606,19 @@ bool __init rdt_cpu_has(int flag);
void mon_event_count(void *info); void mon_event_count(void *info);
int rdtgroup_mondata_show(struct seq_file *m, void *arg); int rdtgroup_mondata_show(struct seq_file *m, void *arg);
void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
struct rdt_domain *d, struct rdtgroup *rdtgrp, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp,
int evtid, int first); int evtid, int first);
void mbm_setup_overflow_handler(struct rdt_domain *dom, void mbm_setup_overflow_handler(struct rdt_mon_domain *dom,
unsigned long delay_ms, unsigned long delay_ms,
int exclude_cpu); int exclude_cpu);
void mbm_handle_overflow(struct work_struct *work); void mbm_handle_overflow(struct work_struct *work);
void __init intel_rdt_mbm_apply_quirk(void); void __init intel_rdt_mbm_apply_quirk(void);
bool is_mba_sc(struct rdt_resource *r); bool is_mba_sc(struct rdt_resource *r);
void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms, void cqm_setup_limbo_handler(struct rdt_mon_domain *dom, unsigned long delay_ms,
int exclude_cpu); int exclude_cpu);
void cqm_handle_limbo(struct work_struct *work); void cqm_handle_limbo(struct work_struct *work);
bool has_busy_rmid(struct rdt_domain *d); bool has_busy_rmid(struct rdt_mon_domain *d);
void __check_limbo(struct rdt_domain *d, bool force_free); void __check_limbo(struct rdt_mon_domain *d, bool force_free);
void rdt_domain_reconfigure_cdp(struct rdt_resource *r); void rdt_domain_reconfigure_cdp(struct rdt_resource *r);
void __init thread_throttle_mode_init(void); void __init thread_throttle_mode_init(void);
void __init mbm_config_rftype_init(const char *config); void __init mbm_config_rftype_init(const char *config);
......
...@@ -209,7 +209,7 @@ static int __rmid_read(u32 rmid, enum resctrl_event_id eventid, u64 *val) ...@@ -209,7 +209,7 @@ static int __rmid_read(u32 rmid, enum resctrl_event_id eventid, u64 *val)
return 0; return 0;
} }
static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_domain *hw_dom, static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_mon_domain *hw_dom,
u32 rmid, u32 rmid,
enum resctrl_event_id eventid) enum resctrl_event_id eventid)
{ {
...@@ -228,11 +228,11 @@ static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_domain *hw_dom, ...@@ -228,11 +228,11 @@ static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_domain *hw_dom,
return NULL; return NULL;
} }
void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_domain *d, void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d,
u32 unused, u32 rmid, u32 unused, u32 rmid,
enum resctrl_event_id eventid) enum resctrl_event_id eventid)
{ {
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d); struct rdt_hw_mon_domain *hw_dom = resctrl_to_arch_mon_dom(d);
struct arch_mbm_state *am; struct arch_mbm_state *am;
am = get_arch_mbm_state(hw_dom, rmid, eventid); am = get_arch_mbm_state(hw_dom, rmid, eventid);
...@@ -248,9 +248,9 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_domain *d, ...@@ -248,9 +248,9 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_domain *d,
* Assumes that hardware counters are also reset and thus that there is * Assumes that hardware counters are also reset and thus that there is
* no need to record initial non-zero counts. * no need to record initial non-zero counts.
*/ */
void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_domain *d) void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_domain *d)
{ {
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d); struct rdt_hw_mon_domain *hw_dom = resctrl_to_arch_mon_dom(d);
if (is_mbm_total_enabled()) if (is_mbm_total_enabled())
memset(hw_dom->arch_mbm_total, 0, memset(hw_dom->arch_mbm_total, 0,
...@@ -269,12 +269,12 @@ static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int width) ...@@ -269,12 +269,12 @@ static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int width)
return chunks >> shift; return chunks >> shift;
} }
int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d, int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d,
u32 unused, u32 rmid, enum resctrl_event_id eventid, u32 unused, u32 rmid, enum resctrl_event_id eventid,
u64 *val, void *ignored) u64 *val, void *ignored)
{ {
struct rdt_hw_mon_domain *hw_dom = resctrl_to_arch_mon_dom(d);
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
struct rdt_hw_domain *hw_dom = resctrl_to_arch_dom(d);
struct arch_mbm_state *am; struct arch_mbm_state *am;
u64 msr_val, chunks; u64 msr_val, chunks;
int ret; int ret;
...@@ -320,7 +320,7 @@ static void limbo_release_entry(struct rmid_entry *entry) ...@@ -320,7 +320,7 @@ static void limbo_release_entry(struct rmid_entry *entry)
* decrement the count. If the busy count gets to zero on an RMID, we * decrement the count. If the busy count gets to zero on an RMID, we
* free the RMID * free the RMID
*/ */
void __check_limbo(struct rdt_domain *d, bool force_free) void __check_limbo(struct rdt_mon_domain *d, bool force_free)
{ {
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
u32 idx_limit = resctrl_arch_system_num_rmid_idx(); u32 idx_limit = resctrl_arch_system_num_rmid_idx();
...@@ -378,7 +378,7 @@ void __check_limbo(struct rdt_domain *d, bool force_free) ...@@ -378,7 +378,7 @@ void __check_limbo(struct rdt_domain *d, bool force_free)
resctrl_arch_mon_ctx_free(r, QOS_L3_OCCUP_EVENT_ID, arch_mon_ctx); resctrl_arch_mon_ctx_free(r, QOS_L3_OCCUP_EVENT_ID, arch_mon_ctx);
} }
bool has_busy_rmid(struct rdt_domain *d) bool has_busy_rmid(struct rdt_mon_domain *d)
{ {
u32 idx_limit = resctrl_arch_system_num_rmid_idx(); u32 idx_limit = resctrl_arch_system_num_rmid_idx();
...@@ -479,7 +479,7 @@ int alloc_rmid(u32 closid) ...@@ -479,7 +479,7 @@ int alloc_rmid(u32 closid)
static void add_rmid_to_limbo(struct rmid_entry *entry) static void add_rmid_to_limbo(struct rmid_entry *entry)
{ {
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
struct rdt_domain *d; struct rdt_mon_domain *d;
u32 idx; u32 idx;
lockdep_assert_held(&rdtgroup_mutex); lockdep_assert_held(&rdtgroup_mutex);
...@@ -531,7 +531,7 @@ void free_rmid(u32 closid, u32 rmid) ...@@ -531,7 +531,7 @@ void free_rmid(u32 closid, u32 rmid)
list_add_tail(&entry->list, &rmid_free_lru); list_add_tail(&entry->list, &rmid_free_lru);
} }
static struct mbm_state *get_mbm_state(struct rdt_domain *d, u32 closid, static struct mbm_state *get_mbm_state(struct rdt_mon_domain *d, u32 closid,
u32 rmid, enum resctrl_event_id evtid) u32 rmid, enum resctrl_event_id evtid)
{ {
u32 idx = resctrl_arch_rmid_idx_encode(closid, rmid); u32 idx = resctrl_arch_rmid_idx_encode(closid, rmid);
...@@ -667,12 +667,12 @@ void mon_event_count(void *info) ...@@ -667,12 +667,12 @@ void mon_event_count(void *info)
* throttle MSRs already have low percentage values. To avoid * throttle MSRs already have low percentage values. To avoid
* unnecessarily restricting such rdtgroups, we also increase the bandwidth. * unnecessarily restricting such rdtgroups, we also increase the bandwidth.
*/ */
static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm) static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_mon_domain *dom_mbm)
{ {
u32 closid, rmid, cur_msr_val, new_msr_val; u32 closid, rmid, cur_msr_val, new_msr_val;
struct mbm_state *pmbm_data, *cmbm_data; struct mbm_state *pmbm_data, *cmbm_data;
struct rdt_ctrl_domain *dom_mba;
struct rdt_resource *r_mba; struct rdt_resource *r_mba;
struct rdt_domain *dom_mba;
u32 cur_bw, user_bw, idx; u32 cur_bw, user_bw, idx;
struct list_head *head; struct list_head *head;
struct rdtgroup *entry; struct rdtgroup *entry;
...@@ -733,7 +733,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm) ...@@ -733,7 +733,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm)
resctrl_arch_update_one(r_mba, dom_mba, closid, CDP_NONE, new_msr_val); resctrl_arch_update_one(r_mba, dom_mba, closid, CDP_NONE, new_msr_val);
} }
static void mbm_update(struct rdt_resource *r, struct rdt_domain *d, static void mbm_update(struct rdt_resource *r, struct rdt_mon_domain *d,
u32 closid, u32 rmid) u32 closid, u32 rmid)
{ {
struct rmid_read rr; struct rmid_read rr;
...@@ -791,12 +791,12 @@ static void mbm_update(struct rdt_resource *r, struct rdt_domain *d, ...@@ -791,12 +791,12 @@ static void mbm_update(struct rdt_resource *r, struct rdt_domain *d,
void cqm_handle_limbo(struct work_struct *work) void cqm_handle_limbo(struct work_struct *work)
{ {
unsigned long delay = msecs_to_jiffies(CQM_LIMBOCHECK_INTERVAL); unsigned long delay = msecs_to_jiffies(CQM_LIMBOCHECK_INTERVAL);
struct rdt_domain *d; struct rdt_mon_domain *d;
cpus_read_lock(); cpus_read_lock();
mutex_lock(&rdtgroup_mutex); mutex_lock(&rdtgroup_mutex);
d = container_of(work, struct rdt_domain, cqm_limbo.work); d = container_of(work, struct rdt_mon_domain, cqm_limbo.work);
__check_limbo(d, false); __check_limbo(d, false);
...@@ -819,7 +819,7 @@ void cqm_handle_limbo(struct work_struct *work) ...@@ -819,7 +819,7 @@ void cqm_handle_limbo(struct work_struct *work)
* @exclude_cpu: Which CPU the handler should not run on, * @exclude_cpu: Which CPU the handler should not run on,
* RESCTRL_PICK_ANY_CPU to pick any CPU. * RESCTRL_PICK_ANY_CPU to pick any CPU.
*/ */
void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms, void cqm_setup_limbo_handler(struct rdt_mon_domain *dom, unsigned long delay_ms,
int exclude_cpu) int exclude_cpu)
{ {
unsigned long delay = msecs_to_jiffies(delay_ms); unsigned long delay = msecs_to_jiffies(delay_ms);
...@@ -836,9 +836,9 @@ void mbm_handle_overflow(struct work_struct *work) ...@@ -836,9 +836,9 @@ void mbm_handle_overflow(struct work_struct *work)
{ {
unsigned long delay = msecs_to_jiffies(MBM_OVERFLOW_INTERVAL); unsigned long delay = msecs_to_jiffies(MBM_OVERFLOW_INTERVAL);
struct rdtgroup *prgrp, *crgrp; struct rdtgroup *prgrp, *crgrp;
struct rdt_mon_domain *d;
struct list_head *head; struct list_head *head;
struct rdt_resource *r; struct rdt_resource *r;
struct rdt_domain *d;
cpus_read_lock(); cpus_read_lock();
mutex_lock(&rdtgroup_mutex); mutex_lock(&rdtgroup_mutex);
...@@ -851,7 +851,7 @@ void mbm_handle_overflow(struct work_struct *work) ...@@ -851,7 +851,7 @@ void mbm_handle_overflow(struct work_struct *work)
goto out_unlock; goto out_unlock;
r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
d = container_of(work, struct rdt_domain, mbm_over.work); d = container_of(work, struct rdt_mon_domain, mbm_over.work);
list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
mbm_update(r, d, prgrp->closid, prgrp->mon.rmid); mbm_update(r, d, prgrp->closid, prgrp->mon.rmid);
...@@ -885,7 +885,7 @@ void mbm_handle_overflow(struct work_struct *work) ...@@ -885,7 +885,7 @@ void mbm_handle_overflow(struct work_struct *work)
* @exclude_cpu: Which CPU the handler should not run on, * @exclude_cpu: Which CPU the handler should not run on,
* RESCTRL_PICK_ANY_CPU to pick any CPU. * RESCTRL_PICK_ANY_CPU to pick any CPU.
*/ */
void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms, void mbm_setup_overflow_handler(struct rdt_mon_domain *dom, unsigned long delay_ms,
int exclude_cpu) int exclude_cpu)
{ {
unsigned long delay = msecs_to_jiffies(delay_ms); unsigned long delay = msecs_to_jiffies(delay_ms);
......
...@@ -809,7 +809,7 @@ int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp) ...@@ -809,7 +809,7 @@ int rdtgroup_locksetup_exit(struct rdtgroup *rdtgrp)
* Return: true if @cbm overlaps with pseudo-locked region on @d, false * Return: true if @cbm overlaps with pseudo-locked region on @d, false
* otherwise. * otherwise.
*/ */
bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, unsigned long cbm) bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_ctrl_domain *d, unsigned long cbm)
{ {
unsigned int cbm_len; unsigned int cbm_len;
unsigned long cbm_b; unsigned long cbm_b;
...@@ -836,11 +836,11 @@ bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, unsigned long cbm ...@@ -836,11 +836,11 @@ bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_domain *d, unsigned long cbm
* if it is not possible to test due to memory allocation issue, * if it is not possible to test due to memory allocation issue,
* false otherwise. * false otherwise.
*/ */
bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d) bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_ctrl_domain *d)
{ {
struct rdt_ctrl_domain *d_i;
cpumask_var_t cpu_with_psl; cpumask_var_t cpu_with_psl;
struct rdt_resource *r; struct rdt_resource *r;
struct rdt_domain *d_i;
bool ret = false; bool ret = false;
/* Walking r->domains, ensure it can't race with cpuhp */ /* Walking r->domains, ensure it can't race with cpuhp */
......
This diff is collapsed.
...@@ -78,7 +78,23 @@ struct rdt_domain_hdr { ...@@ -78,7 +78,23 @@ struct rdt_domain_hdr {
}; };
/** /**
* struct rdt_domain - group of CPUs sharing a resctrl resource * struct rdt_ctrl_domain - group of CPUs sharing a resctrl control resource
* @hdr: common header for different domain types
* @plr: pseudo-locked region (if any) associated with domain
* @staged_config: parsed configuration to be applied
* @mbps_val: When mba_sc is enabled, this holds the array of user
* specified control values for mba_sc in MBps, indexed
* by closid
*/
struct rdt_ctrl_domain {
struct rdt_domain_hdr hdr;
struct pseudo_lock_region *plr;
struct resctrl_staged_config staged_config[CDP_NUM_TYPES];
u32 *mbps_val;
};
/**
* struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
* @hdr: common header for different domain types * @hdr: common header for different domain types
* @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold * @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold
* @mbm_total: saved state for MBM total bandwidth * @mbm_total: saved state for MBM total bandwidth
...@@ -87,13 +103,8 @@ struct rdt_domain_hdr { ...@@ -87,13 +103,8 @@ struct rdt_domain_hdr {
* @cqm_limbo: worker to periodically read CQM h/w counters * @cqm_limbo: worker to periodically read CQM h/w counters
* @mbm_work_cpu: worker CPU for MBM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters
* @cqm_work_cpu: worker CPU for CQM h/w counters * @cqm_work_cpu: worker CPU for CQM h/w counters
* @plr: pseudo-locked region (if any) associated with domain
* @staged_config: parsed configuration to be applied
* @mbps_val: When mba_sc is enabled, this holds the array of user
* specified control values for mba_sc in MBps, indexed
* by closid
*/ */
struct rdt_domain { struct rdt_mon_domain {
struct rdt_domain_hdr hdr; struct rdt_domain_hdr hdr;
unsigned long *rmid_busy_llc; unsigned long *rmid_busy_llc;
struct mbm_state *mbm_total; struct mbm_state *mbm_total;
...@@ -102,9 +113,6 @@ struct rdt_domain { ...@@ -102,9 +113,6 @@ struct rdt_domain {
struct delayed_work cqm_limbo; struct delayed_work cqm_limbo;
int mbm_work_cpu; int mbm_work_cpu;
int cqm_work_cpu; int cqm_work_cpu;
struct pseudo_lock_region *plr;
struct resctrl_staged_config staged_config[CDP_NUM_TYPES];
u32 *mbps_val;
}; };
/** /**
...@@ -208,7 +216,7 @@ struct rdt_resource { ...@@ -208,7 +216,7 @@ struct rdt_resource {
const char *format_str; const char *format_str;
int (*parse_ctrlval)(struct rdt_parse_data *data, int (*parse_ctrlval)(struct rdt_parse_data *data,
struct resctrl_schema *s, struct resctrl_schema *s,
struct rdt_domain *d); struct rdt_ctrl_domain *d);
struct list_head evt_list; struct list_head evt_list;
unsigned long fflags; unsigned long fflags;
bool cdp_capable; bool cdp_capable;
...@@ -242,15 +250,15 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid); ...@@ -242,15 +250,15 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
* Update the ctrl_val and apply this config right now. * Update the ctrl_val and apply this config right now.
* Must be called on one of the domain's CPUs. * Must be called on one of the domain's CPUs.
*/ */
int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type t, u32 cfg_val); u32 closid, enum resctrl_conf_type t, u32 cfg_val);
u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type type); u32 closid, enum resctrl_conf_type type);
int resctrl_online_ctrl_domain(struct rdt_resource *r, struct rdt_domain *d); int resctrl_online_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_domain *d);
int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_domain *d); int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d);
void resctrl_offline_ctrl_domain(struct rdt_resource *r, struct rdt_domain *d); void resctrl_offline_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_domain *d);
void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_domain *d); void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d);
void resctrl_online_cpu(unsigned int cpu); void resctrl_online_cpu(unsigned int cpu);
void resctrl_offline_cpu(unsigned int cpu); void resctrl_offline_cpu(unsigned int cpu);
...@@ -279,7 +287,7 @@ void resctrl_offline_cpu(unsigned int cpu); ...@@ -279,7 +287,7 @@ void resctrl_offline_cpu(unsigned int cpu);
* Return: * Return:
* 0 on success, or -EIO, -EINVAL etc on error. * 0 on success, or -EIO, -EINVAL etc on error.
*/ */
int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d, int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d,
u32 closid, u32 rmid, enum resctrl_event_id eventid, u32 closid, u32 rmid, enum resctrl_event_id eventid,
u64 *val, void *arch_mon_ctx); u64 *val, void *arch_mon_ctx);
...@@ -312,7 +320,7 @@ static inline void resctrl_arch_rmid_read_context_check(void) ...@@ -312,7 +320,7 @@ static inline void resctrl_arch_rmid_read_context_check(void)
* *
* This can be called from any CPU. * This can be called from any CPU.
*/ */
void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_domain *d, void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d,
u32 closid, u32 rmid, u32 closid, u32 rmid,
enum resctrl_event_id eventid); enum resctrl_event_id eventid);
...@@ -325,7 +333,7 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_domain *d, ...@@ -325,7 +333,7 @@ void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_domain *d,
* *
* This can be called from any CPU. * This can be called from any CPU.
*/ */
void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_domain *d); void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_domain *d);
extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_threshold;
extern unsigned int resctrl_rmid_realloc_limit; extern unsigned int resctrl_rmid_realloc_limit;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment