[PATCH 10/15] x86/resctrl: Initialize ABMC counters bitmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



AMD Hardware provides 32 ABMC(Bandwidth Monitoring Event Configuration)
counters when supported. These hardware counters are used to assign
(or pin) the RMID to the group.

Introduce the bitmap abmc_free_map to allocate and free counters.

Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index edb679b22b7b..f72d6d8c12df 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -164,6 +164,22 @@ static bool closid_allocated(unsigned int closid)
 	return (closid_free_map & (1 << closid)) == 0;
 }
 
+static u64 abmc_free_map;
+static u32 abmc_free_map_len;
+
+static void abmc_counters_init(void)
+{
+	struct rdt_hw_resource *hw_res = &rdt_resources_all[RDT_RESOURCE_L3];
+
+	if (hw_res->abmc_counters > 64) {
+		hw_res->abmc_counters = 64;
+		WARN(1, "Cannot support more than 64 abmc counters\n");
+	}
+
+	abmc_free_map = BIT_MASK(hw_res->abmc_counters) - 1;
+	abmc_free_map_len = hw_res->abmc_counters;
+}
+
 /**
  * rdtgroup_mode_by_closid - Return mode of resource group with closid
  * @closid: closid if the resource group
@@ -2715,6 +2731,7 @@ static int rdt_get_tree(struct fs_context *fc)
 {
 	struct rdt_fs_context *ctx = rdt_fc2context(fc);
 	unsigned long flags = RFTYPE_CTRL_BASE;
+	struct rdt_hw_resource *hw_res;
 	struct rdt_domain *dom;
 	struct rdt_resource *r;
 	int ret;
@@ -2745,6 +2762,12 @@ static int rdt_get_tree(struct fs_context *fc)
 
 	closid_init();
 
+	r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
+	hw_res = resctrl_to_arch_res(r);
+
+	if (r->abmc_capable && hw_res->abmc_enabled)
+		abmc_counters_init();
+
 	if (rdt_mon_capable)
 		flags |= RFTYPE_MON;
 
@@ -2789,7 +2812,6 @@ static int rdt_get_tree(struct fs_context *fc)
 		static_branch_enable_cpuslocked(&rdt_enable_key);
 
 	if (is_mbm_enabled()) {
-		r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
 		list_for_each_entry(dom, &r->domains, list)
 			mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL);
 	}
-- 
2.34.1





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux