Re: [PATCH v13 08/27] x86/resctrl: Introduce mbm_cntr_cfg to track assignable counters at domain

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

 



Hi Reinette,

On 5/22/2025 4:02 PM, Reinette Chatre wrote:
Hi Babu,

shortlog: "at domain" -> "per domain"?

Sure.

On 5/15/25 3:51 PM, Babu Moger wrote:
In mbm_cntr_assign mode hardware counters are assigned/unassigned to an
MBM event of a monitor group. Hardware counters are assigned/unassigned
at monitoring domain level.

Manage a monitoring domain's hardware counters using a per monitoring
domain array of struct mbm_cntr_cfg that is indexed by the hardware
counter ID. A hardware counter's configuration contains the MBM event
ID and points to the monitoring group that it is assigned to, with a
NULL pointer meaning that the hardware counter is available for assignment.

There is no direct way to determine which hardware counters are assigned
to a particular monitoring group. Check every entry of every hardware
counter configuration array in every monitoring domain to query which
MBM events of a monitoring group is tracked by hardware. Such queries are
acceptable because of a very small number of assignable counters (32
to 64).

Suggested-by: Peter Newman <peternewman@xxxxxxxxxx>
Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v13: Resolved conflicts caused by the recent FS/ARCH code restructure.
      The files monitor.c/rdtgroup.c have been split between FS and ARCH directories.

v12: Fixed the struct mbm_cntr_cfg code documentation.
      Removed few strange charactors in changelog.
      Added the counter range for better understanding.
      Moved the struct mbm_cntr_cfg definition to resctrl/internal.h as
      suggested by James.

v11: Refined the change log based on Reinette's feedback.
      Fixed few style issues.

v10: Patch changed completely to handle the counters at domain level.
      https://lore.kernel.org/lkml/CALPaoCj+zWq1vkHVbXYP0znJbe6Ke3PXPWjtri5AFgD9cQDCUg@xxxxxxxxxxxxxx/
      Removed Reviewed-by tag.
      Did not see the need to add cntr_id in mbm_state structure. Not used in the code.

v9: Added Reviewed-by tag. No other changes.

v8: Minor commit message changes.

v7: Added check mbm_cntr_assignable for allocating bitmap mbm_cntr_map

v6: New patch to add domain level assignment.
---
  fs/resctrl/rdtgroup.c   | 11 +++++++++++
  include/linux/resctrl.h | 16 ++++++++++++++++
  2 files changed, 27 insertions(+)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 51f8f8d3ccbc..e2005fc9acd9 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -4085,6 +4085,7 @@ static void rdtgroup_setup_default(void)
static void domain_destroy_mon_state(struct rdt_mon_domain *d)
  {
+	kfree(d->cntr_cfg);
  	bitmap_free(d->rmid_busy_llc);
  	kfree(d->mbm_total);
  	kfree(d->mbm_local);
@@ -4171,6 +4172,16 @@ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_mon_domain
  			return -ENOMEM;
  		}
  	}
+	if (resctrl_is_mbm_enabled() && r->mon.mbm_cntr_assignable) {
+		tsize = sizeof(*d->cntr_cfg);
+		d->cntr_cfg = kcalloc(r->mon.num_mbm_cntrs, tsize, GFP_KERNEL);
+		if (!d->cntr_cfg) {
+			bitmap_free(d->rmid_busy_llc);
+			kfree(d->mbm_total);
+			kfree(d->mbm_local);
+			return -ENOMEM;
+		}
+	}
return 0;
  }
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index bdb264875ef6..d77981d1fcb9 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -156,6 +156,20 @@ struct rdt_ctrl_domain {
  	u32				*mbps_val;
  };
+/**
+ * struct mbm_cntr_cfg - Assignable counter configuration
+ * @evtid:		MBM event to which the counter is assigned. Only valid
+ *			if @rdtgroup is not NULL.
+ * @evt_cfg:		Event configuration value.

@evt_cfg is not introduced in changelog nor defined here. Please add a snippet here
on what @evt_cfg's values represent. This is important since this is exposed
as resctrl fs API to architectures so all architectures need to use same values when
interacting with resctrl.

Sure.

@evt_cfg: A value that represents memory transactions (e.g., reads, writes, etc.).


+ * @rdtgrp:		resctrl group assigned to the counter. NULL if the
+ *			counter is free.
+ */
+struct mbm_cntr_cfg {
+	enum resctrl_event_id   evtid;
+	u32                     evt_cfg;
+	struct rdtgroup         *rdtgrp;

Please align struct member names using TABs.

Sure.


+};
+
  /**
   * struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
   * @hdr:		common header for different domain types
@@ -167,6 +181,7 @@ struct rdt_ctrl_domain {
   * @cqm_limbo:		worker to periodically read CQM h/w counters
   * @mbm_work_cpu:	worker CPU for MBM h/w counters
   * @cqm_work_cpu:	worker CPU for CQM h/w counters
+ * @cntr_cfg:		assignable counters configuration

"array of assignable counters' configuration (indexed by counter ID)"

Sure.


   */
  struct rdt_mon_domain {
  	struct rdt_domain_hdr		hdr;
@@ -178,6 +193,7 @@ struct rdt_mon_domain {
  	struct delayed_work		cqm_limbo;
  	int				mbm_work_cpu;
  	int				cqm_work_cpu;
+	struct mbm_cntr_cfg		*cntr_cfg;
  };
/**

Reinette


thanks
Babu




[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