x86/resctrl: Introduce interface to list monitor states of all the groups
ANBZ: #9790 cherry-picked from https://lore.kernel.org/all/cover.1722981659.git.babu.moger@amd.com/ Provide the interface to list the monitor states of all the resctrl groups in ABMC mode. Example: $cat /sys/fs/resctrl/info/L3_MON/mbm_control List follows the following format: "<CTRL_MON group>/<MON group>/<domain_id>=<flags>" Format for specific type of groups: - Default CTRL_MON group: "//<domain_id>=<flags>" - Non-default CTRL_MON group: "<CTRL_MON group>//<domain_id>=<flags>" - Child MON group of default CTRL_MON group: "/<MON group>/<domain_id>=<flags>" - Child MON group of non-default CTRL_MON group: "<CTRL_MON group>/<MON group>/<domain_id>=<flags>" Flags can be one of the following: t MBM total event is enabled l MBM local event is enabled tl Both total and local MBM events are enabled _ None of the MBM events are enabled Signed-off-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Kun(llfl) <llfl@linux.alibaba.com> Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com> Link: https://gitee.com/anolis/cloud-kernel/pulls/3731
This commit is contained in:
parent
9bd6f677fe
commit
51c5ecfd85
|
@ -317,6 +317,50 @@ with the following files:
|
|||
the counter is not assigned to the event when read. Users need to assign a
|
||||
counter manually to read the events.
|
||||
|
||||
"mbm_control":
|
||||
Reports the resctrl group and monitor status of each group.
|
||||
|
||||
List follows the following format:
|
||||
"<CTRL_MON group>/<MON group>/<domain_id>=<flags>"
|
||||
|
||||
Format for specific type of groups:
|
||||
|
||||
* Default CTRL_MON group:
|
||||
"//<domain_id>=<flags>"
|
||||
|
||||
* Non-default CTRL_MON group:
|
||||
"<CTRL_MON group>//<domain_id>=<flags>"
|
||||
|
||||
* Child MON group of default CTRL_MON group:
|
||||
"/<MON group>/<domain_id>=<flags>"
|
||||
|
||||
* Child MON group of non-default CTRL_MON group:
|
||||
"<CTRL_MON group>/<MON group>/<domain_id>=<flags>"
|
||||
|
||||
Flags can be one of the following:
|
||||
::
|
||||
|
||||
t MBM total event is enabled.
|
||||
l MBM local event is enabled.
|
||||
tl Both total and local MBM events are enabled.
|
||||
_ None of the MBM events are enabled.
|
||||
|
||||
Examples:
|
||||
::
|
||||
|
||||
# mkdir /sys/fs/resctrl/mon_groups/child_default_mon_grp
|
||||
# mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp
|
||||
# mkdir /sys/fs/resctrl/non_default_ctrl_mon_grp/mon_groups/child_non_default_mon_grp
|
||||
|
||||
# cat /sys/fs/resctrl/info/L3_MON/mbm_control
|
||||
non_default_ctrl_mon_grp//0=tl;1=tl;
|
||||
non_default_ctrl_mon_grp/child_non_default_mon_grp/0=tl;1=tl;
|
||||
//0=tl;1=tl;
|
||||
/child_default_mon_grp/0=tl;1=tl;
|
||||
|
||||
There are four resctrl groups. All the groups have total and local MBM events
|
||||
enabled on domain 0 and 1.
|
||||
|
||||
"max_threshold_occupancy":
|
||||
Read/write file provides the largest value (in
|
||||
bytes) at which a previously used LLC_occupancy
|
||||
|
|
|
@ -231,6 +231,7 @@ bool resctrl_arch_get_abmc_enabled(void);
|
|||
|
||||
int resctrl_arch_mbm_cntr_assign_enable(void);
|
||||
void resctrl_arch_mbm_cntr_assign_disable(void);
|
||||
bool resctrl_arch_get_mbm_cntr_assign_enable(void);
|
||||
|
||||
void resctrl_arch_event_config_set(void *info);
|
||||
u32 resctrl_arch_event_config_get(void *dom,
|
||||
|
|
|
@ -237,6 +237,14 @@ void resctrl_arch_mbm_cntr_assign_disable(void)
|
|||
}
|
||||
}
|
||||
|
||||
bool resctrl_arch_get_mbm_cntr_assign_enable(void)
|
||||
{
|
||||
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
|
||||
struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
|
||||
|
||||
return hw_res->mbm_cntr_assign_enabled;
|
||||
}
|
||||
|
||||
static void rdtgroup_abmc_cfg(void *info)
|
||||
{
|
||||
u64 *msrval = info;
|
||||
|
|
|
@ -748,8 +748,10 @@ static void l3_mon_evt_init(struct rdt_resource *r)
|
|||
RF_MON_INFO | RFTYPE_RES_CACHE);
|
||||
}
|
||||
|
||||
if (resctrl_arch_get_abmc_enabled())
|
||||
if (resctrl_arch_get_abmc_enabled()) {
|
||||
resctrl_file_fflags_init("num_mbm_cntrs", RF_MON_INFO);
|
||||
resctrl_file_fflags_init("mbm_control", RF_MON_INFO);
|
||||
}
|
||||
|
||||
if (resctrl_arch_is_llc_occupancy_enabled())
|
||||
list_add_tail(&llc_occupancy_event.list, &r->mon.evt_list);
|
||||
|
|
|
@ -887,6 +887,74 @@ static int rdtgroup_num_mbm_cntrs_show(struct kernfs_open_file *of,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char *rdtgroup_mon_state_to_str(struct rdtgroup *rdtgrp,
|
||||
struct rdt_domain *d, char *str)
|
||||
{
|
||||
char *tmp = str;
|
||||
int index;
|
||||
|
||||
/*
|
||||
* Query the monitor state for the domain.
|
||||
* Index 0 for evtid == QOS_L3_MBM_TOTAL_EVENT_ID
|
||||
* Index 1 for evtid == QOS_L3_MBM_LOCAL_EVENT_ID
|
||||
*/
|
||||
index = mon_event_config_index_get(QOS_L3_MBM_TOTAL_EVENT_ID);
|
||||
if (rdtgrp->mon.cntr_id[index] != MON_CNTR_UNSET &&
|
||||
test_bit(rdtgrp->mon.cntr_id[index], d->mbm_cntr_map))
|
||||
*tmp++ = 't';
|
||||
|
||||
index = mon_event_config_index_get(QOS_L3_MBM_LOCAL_EVENT_ID);
|
||||
if (rdtgrp->mon.cntr_id[index] != MON_CNTR_UNSET &&
|
||||
test_bit(rdtgrp->mon.cntr_id[index], d->mbm_cntr_map))
|
||||
*tmp++ = 'l';
|
||||
|
||||
if (tmp == str)
|
||||
*tmp++ = '_';
|
||||
|
||||
*tmp = '\0';
|
||||
return str;
|
||||
}
|
||||
|
||||
static int rdtgroup_mbm_control_show(struct kernfs_open_file *of,
|
||||
struct seq_file *s, void *v)
|
||||
{
|
||||
struct rdt_resource *r = of->kn->parent->priv;
|
||||
struct rdt_domain *dom;
|
||||
struct rdtgroup *rdtg;
|
||||
char str[10];
|
||||
|
||||
if (!resctrl_arch_get_mbm_cntr_assign_enable()) {
|
||||
rdt_last_cmd_puts("ABMC feature is not enabled\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&rdtgroup_mutex);
|
||||
|
||||
list_for_each_entry(rdtg, &rdt_all_groups, rdtgroup_list) {
|
||||
struct rdtgroup *crg;
|
||||
|
||||
seq_printf(s, "%s//", rdtg->kn->name);
|
||||
|
||||
list_for_each_entry(dom, &r->domains, list)
|
||||
seq_printf(s, "%d=%s;", dom->id,
|
||||
rdtgroup_mon_state_to_str(rdtg, dom, str));
|
||||
seq_putc(s, '\n');
|
||||
|
||||
list_for_each_entry(crg, &rdtg->mon.crdtgrp_list,
|
||||
mon.crdtgrp_list) {
|
||||
seq_printf(s, "%s/%s/", rdtg->kn->name, crg->kn->name);
|
||||
|
||||
list_for_each_entry(dom, &r->domains, list)
|
||||
seq_printf(s, "%d=%s;", dom->id,
|
||||
rdtgroup_mon_state_to_str(crg, dom, str));
|
||||
seq_putc(s, '\n');
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&rdtgroup_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROC_CPU_RESCTRL
|
||||
|
||||
/*
|
||||
|
@ -2066,6 +2134,12 @@ static struct rftype res_common_files[] = {
|
|||
.kf_ops = &rdtgroup_kf_single_ops,
|
||||
.seq_show = rdtgroup_num_mbm_cntrs_show,
|
||||
},
|
||||
{
|
||||
.name = "mbm_control",
|
||||
.mode = 0444,
|
||||
.kf_ops = &rdtgroup_kf_single_ops,
|
||||
.seq_show = rdtgroup_mbm_control_show,
|
||||
},
|
||||
{
|
||||
.name = "cpus_list",
|
||||
.mode = 0644,
|
||||
|
|
|
@ -126,6 +126,11 @@ static inline int resctrl_arch_mbm_cntr_assign_enable(void)
|
|||
|
||||
static inline void resctrl_arch_mbm_cntr_assign_disable(void) { }
|
||||
|
||||
static inline bool resctrl_arch_get_mbm_cntr_assign_enable(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void resctrl_arch_event_config_set(void *info) { }
|
||||
static inline u32 resctrl_arch_event_config_get(void *dom,
|
||||
enum resctrl_event_id eventid)
|
||||
|
|
Loading…
Reference in New Issue