Thread (93 messages) 93 messages, 3 authors, 2025-08-12

Re: [PATCH v16 13/34] fs/resctrl: Introduce interface to display number of free MBM counters

From: "Moger, Babu" <babu.moger@amd.com>
Date: 2025-08-06 22:04:51
Also in: lkml

Hi Reinette,

On 8/6/25 16:31, Reinette Chatre wrote:
Hi Babu,

On 8/6/25 2:19 PM, Moger, Babu wrote:
quoted
quoted
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index a09566720d4f..15d10c346307 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -1853,6 +1853,48 @@ static int resctrl_num_mbm_cntrs_show(struct kernfs_open_file *of,
 	return 0;
 }
 
+static int resctrl_available_mbm_cntrs_show(struct kernfs_open_file *of,
+					    struct seq_file *s, void *v)
+{
+	struct rdt_resource *r = rdt_kn_parent_priv(of->kn);
+	struct rdt_mon_domain *dom;
+	bool sep = false;
+	u32 cntrs, i;
+	int ret = 0;
+
+	cpus_read_lock();
+	mutex_lock(&rdtgroup_mutex);
+
+	rdt_last_cmd_clear();
+
+	if (!resctrl_arch_mbm_cntr_assign_enabled(r)) {
+		rdt_last_cmd_puts("mbm_event mode is not enabled\n");
+		ret = -EINVAL;
+		goto out_unlock;
+	}
+
+	list_for_each_entry(dom, &r->mon_domains, hdr.list) {
+		if (sep)
+			seq_putc(s, ';');
+
+		cntrs = 0;
+		for (i = 0; i < r->mon.num_mbm_cntrs; i++) {
+			if (!dom->cntr_cfg[i].rdtgrp)
+				cntrs++;
+		}
+
+		seq_printf(s, "%d=%u", dom->hdr.id, cntrs);
+		sep = true;
+	}
+	seq_putc(s, '\n');
+
+out_unlock:
+	mutex_unlock(&rdtgroup_mutex);
+	cpus_read_unlock();
+
+	return ret;
+}
+
This also can be moved to monitor.c.  What do you think?
Yes, I believe monitor.c is most appropriate for all the monitoring
related handlers [1].
Sure. Will do.
Reinette

[1] https://lore.kernel.org/lkml/0fa9a12b-e900-4ceb-b59c-e653ec3db0ca@intel.com/ (local)
-- 
Thanks
Babu Moger
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help