mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 14:42:08 +02:00
x86/resctrl: Add a helper to avoid reaching into the arch code resource list
Resctrl occasionally wants to know something about a specific resource, in these cases it reaches into the arch code's rdt_resources_all[] array. Once the filesystem parts of resctrl are moved to /fs/, this means it will need visibility of the architecture specific struct rdt_hw_resource definition, and the array of all resources. All architectures would also need a r_resctrl member in this struct. Instead, abstract this via a helper to allow architectures to do different things here. Move the level enum to the resctrl header and add a helper to retrieve the struct rdt_resource by 'rid'. resctrl_arch_get_resource() should not return NULL for any value in the enum, it may instead return a dummy resource that is !alloc_enabled && !mon_enabled. Co-developed-by: Dave Martin <Dave.Martin@arm.com> Signed-off-by: Dave Martin <Dave.Martin@arm.com> Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Reviewed-by: Babu Moger <babu.moger@amd.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64 Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Amit Singh Tomar <amitsinght@marvell.com> # arm64 Tested-by: Shanker Donthineni <sdonthineni@nvidia.com> # arm64 Tested-by: Babu Moger <babu.moger@amd.com> Link: https://lore.kernel.org/r/20250311183715.16445-3-james.morse@arm.com
This commit is contained in:
parent
a121798ae6
commit
3c02153113
|
|
@ -62,7 +62,7 @@ static void mba_wrmsr_amd(struct msr_param *m);
|
|||
#define ctrl_domain_init(id) LIST_HEAD_INIT(rdt_resources_all[id].r_resctrl.ctrl_domains)
|
||||
#define mon_domain_init(id) LIST_HEAD_INIT(rdt_resources_all[id].r_resctrl.mon_domains)
|
||||
|
||||
struct rdt_hw_resource rdt_resources_all[] = {
|
||||
struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESOURCES] = {
|
||||
[RDT_RESOURCE_L3] =
|
||||
{
|
||||
.r_resctrl = {
|
||||
|
|
@ -127,6 +127,14 @@ u32 resctrl_arch_system_num_rmid_idx(void)
|
|||
return r->num_rmid;
|
||||
}
|
||||
|
||||
struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l)
|
||||
{
|
||||
if (l >= RDT_NUM_RESOURCES)
|
||||
return NULL;
|
||||
|
||||
return &rdt_resources_all[l].r_resctrl;
|
||||
}
|
||||
|
||||
/*
|
||||
* cache_alloc_hsw_probe() - Have to probe for Intel haswell server CPUs
|
||||
* as they do not have CPUID enumeration support for Cache allocation.
|
||||
|
|
@ -174,7 +182,7 @@ static inline void cache_alloc_hsw_probe(void)
|
|||
bool is_mba_sc(struct rdt_resource *r)
|
||||
{
|
||||
if (!r)
|
||||
return rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl.membw.mba_sc;
|
||||
r = resctrl_arch_get_resource(RDT_RESOURCE_MBA);
|
||||
|
||||
/*
|
||||
* The software controller support is only applicable to MBA resource.
|
||||
|
|
|
|||
|
|
@ -649,7 +649,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
|
|||
resid = md.u.rid;
|
||||
domid = md.u.domid;
|
||||
evtid = md.u.evtid;
|
||||
r = &rdt_resources_all[resid].r_resctrl;
|
||||
r = resctrl_arch_get_resource(resid);
|
||||
|
||||
if (md.u.sum) {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -512,16 +512,6 @@ extern struct rdtgroup rdtgroup_default;
|
|||
extern struct dentry *debugfs_resctrl;
|
||||
extern enum resctrl_event_id mba_mbps_default_event;
|
||||
|
||||
enum resctrl_res_level {
|
||||
RDT_RESOURCE_L3,
|
||||
RDT_RESOURCE_L2,
|
||||
RDT_RESOURCE_MBA,
|
||||
RDT_RESOURCE_SMBA,
|
||||
|
||||
/* Must be the last */
|
||||
RDT_NUM_RESOURCES,
|
||||
};
|
||||
|
||||
static inline struct rdt_resource *resctrl_inc(struct rdt_resource *res)
|
||||
{
|
||||
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(res);
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ static void limbo_release_entry(struct rmid_entry *entry)
|
|||
*/
|
||||
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 = resctrl_arch_get_resource(RDT_RESOURCE_L3);
|
||||
u32 idx_limit = resctrl_arch_system_num_rmid_idx();
|
||||
struct rmid_entry *entry;
|
||||
u32 idx, cur_idx = 1;
|
||||
|
|
@ -521,7 +521,7 @@ int alloc_rmid(u32 closid)
|
|||
|
||||
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 = resctrl_arch_get_resource(RDT_RESOURCE_L3);
|
||||
struct rdt_mon_domain *d;
|
||||
u32 idx;
|
||||
|
||||
|
|
@ -761,7 +761,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_mon_domain *dom_mbm)
|
|||
struct rdtgroup *entry;
|
||||
u32 cur_bw, user_bw;
|
||||
|
||||
r_mba = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl;
|
||||
r_mba = resctrl_arch_get_resource(RDT_RESOURCE_MBA);
|
||||
evt_id = rgrp->mba_mbps_event;
|
||||
|
||||
closid = rgrp->closid;
|
||||
|
|
@ -925,7 +925,7 @@ void mbm_handle_overflow(struct work_struct *work)
|
|||
if (!resctrl_mounted || !resctrl_arch_mon_capable())
|
||||
goto out_unlock;
|
||||
|
||||
r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
|
||||
r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
|
||||
d = container_of(work, struct rdt_mon_domain, mbm_over.work);
|
||||
|
||||
list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
|
||||
|
|
|
|||
|
|
@ -2256,7 +2256,7 @@ static void l2_qos_cfg_update(void *arg)
|
|||
|
||||
static inline bool is_mba_linear(void)
|
||||
{
|
||||
return rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl.membw.delay_linear;
|
||||
return resctrl_arch_get_resource(RDT_RESOURCE_MBA)->membw.delay_linear;
|
||||
}
|
||||
|
||||
static int set_cache_qos_cfg(int level, bool enable)
|
||||
|
|
@ -2346,8 +2346,8 @@ static void mba_sc_domain_destroy(struct rdt_resource *r,
|
|||
*/
|
||||
static bool supports_mba_mbps(void)
|
||||
{
|
||||
struct rdt_resource *rmbm = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
|
||||
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl;
|
||||
struct rdt_resource *rmbm = resctrl_arch_get_resource(RDT_RESOURCE_L3);
|
||||
struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_MBA);
|
||||
|
||||
return (is_mbm_enabled() &&
|
||||
r->alloc_capable && is_mba_linear() &&
|
||||
|
|
@ -2360,7 +2360,7 @@ static bool supports_mba_mbps(void)
|
|||
*/
|
||||
static int set_mba_sc(bool mba_sc)
|
||||
{
|
||||
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl;
|
||||
struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_MBA);
|
||||
u32 num_closid = resctrl_arch_get_num_closid(r);
|
||||
struct rdt_ctrl_domain *d;
|
||||
unsigned long fflags;
|
||||
|
|
@ -2714,7 +2714,7 @@ static int rdt_get_tree(struct fs_context *fc)
|
|||
resctrl_mounted = true;
|
||||
|
||||
if (is_mbm_enabled()) {
|
||||
r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
|
||||
r = resctrl_arch_get_resource(RDT_RESOURCE_L3);
|
||||
list_for_each_entry(dom, &r->mon_domains, hdr.list)
|
||||
mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL,
|
||||
RESCTRL_PICK_ANY_CPU);
|
||||
|
|
@ -3951,7 +3951,7 @@ static int rdtgroup_show_options(struct seq_file *seq, struct kernfs_root *kf)
|
|||
if (resctrl_arch_get_cdp_enabled(RDT_RESOURCE_L2))
|
||||
seq_puts(seq, ",cdpl2");
|
||||
|
||||
if (is_mba_sc(&rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl))
|
||||
if (is_mba_sc(resctrl_arch_get_resource(RDT_RESOURCE_MBA)))
|
||||
seq_puts(seq, ",mba_MBps");
|
||||
|
||||
if (resctrl_debug)
|
||||
|
|
@ -4151,7 +4151,7 @@ static void clear_childcpus(struct rdtgroup *r, unsigned int cpu)
|
|||
|
||||
void resctrl_offline_cpu(unsigned int cpu)
|
||||
{
|
||||
struct rdt_resource *l3 = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
|
||||
struct rdt_resource *l3 = resctrl_arch_get_resource(RDT_RESOURCE_L3);
|
||||
struct rdt_mon_domain *d;
|
||||
struct rdtgroup *rdtgrp;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,16 @@ enum resctrl_conf_type {
|
|||
CDP_DATA,
|
||||
};
|
||||
|
||||
enum resctrl_res_level {
|
||||
RDT_RESOURCE_L3,
|
||||
RDT_RESOURCE_L2,
|
||||
RDT_RESOURCE_MBA,
|
||||
RDT_RESOURCE_SMBA,
|
||||
|
||||
/* Must be the last */
|
||||
RDT_NUM_RESOURCES,
|
||||
};
|
||||
|
||||
#define CDP_NUM_TYPES (CDP_DATA + 1)
|
||||
|
||||
/*
|
||||
|
|
@ -226,6 +236,13 @@ struct rdt_resource {
|
|||
bool cdp_capable;
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the resource that exists at this level. If the level is not supported
|
||||
* a dummy/not-capable resource can be returned. Levels >= RDT_NUM_RESOURCES
|
||||
* will return NULL.
|
||||
*/
|
||||
struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l);
|
||||
|
||||
/**
|
||||
* struct resctrl_schema - configuration abilities of a resource presented to
|
||||
* user-space
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user