The ABMC feature provides an option to the user to assign a hardware counter to an RMID and monitor the bandwidth as long as it is assigned. There are two events per resctrl group, mbm total and mbm local. User have the option to assign or unassign each event individually. Add a new field mon_state in mongroup data structure to represent the assignment state of the group. Reset the states when switching the monitor mode. Signed-off-by: Babu Moger <babu.moger@xxxxxxx> --- v4: Changed ASSIGN_TOTAL and ASSIGN_LOCAL to use QOS_L3_MBM_TOTAL_EVENT_ID and QOS_L3_MBM_LOCAL_EVENT_ID. Few more commit text changes. v3: Changed the field name to mon_state. Also thie state is not visible to users directly as part of out global assign approach. v2: Added check to display "Unsupported" when user tries to access monitor state when ABMC is not enabled. --- arch/x86/kernel/cpu/resctrl/internal.h | 9 +++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index fabe40304798..5e7e76cd512f 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -100,6 +100,13 @@ cpumask_any_housekeeping(const struct cpumask *mask, int exclude_cpu) /* Setting bit 0 in L3_QOS_EXT_CFG enables the ABMC feature */ #define ABMC_ENABLE BIT(0) +/* + * monitor group's state when ABMC is supported + */ +#define ASSIGN_NONE 0 +#define ASSIGN_TOTAL BIT(QOS_L3_MBM_TOTAL_EVENT_ID) +#define ASSIGN_LOCAL BIT(QOS_L3_MBM_LOCAL_EVENT_ID) + struct rdt_fs_context { struct kernfs_fs_context kfc; bool enable_cdpl2; @@ -203,12 +210,14 @@ enum rdtgrp_mode { * @parent: parent rdtgrp * @crdtgrp_list: child rdtgroup node list * @rmid: rmid for this rdtgroup + * @mon_state: Assignment state of the group */ struct mongroup { struct kernfs_node *mon_data_kn; struct rdtgroup *parent; struct list_head crdtgrp_list; u32 rmid; + u32 mon_state; }; /** diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 400ae405e10e..c176bacf7ba1 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2474,6 +2474,7 @@ static void resctrl_abmc_set_one(void *arg) static int resctrl_abmc_set_all(enum resctrl_res_level l, bool enable) { struct rdt_resource *r = &rdt_resources_all[l].r_resctrl; + struct rdtgroup *prgrp, *crgrp; struct rdt_domain *d; /* @@ -2493,6 +2494,13 @@ static int resctrl_abmc_set_all(enum resctrl_res_level l, bool enable) resctrl_arch_reset_rmid_all(r, d); } + /* Reset assign state for all the monitor groups */ + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + prgrp->mon.mon_state = ASSIGN_NONE; + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) + crgrp->mon.mon_state = ASSIGN_NONE; + } + return 0; } -- 2.34.1