[RFC PATCH 03/19] fs/resctrl: Add new interface max_bandwidth

Babu Moger posted 19 patches 2 weeks, 3 days ago
[RFC PATCH 03/19] fs/resctrl: Add new interface max_bandwidth
Posted by Babu Moger 2 weeks, 3 days ago
While min_bandwidth is exposed for each resource under
/sys/fs/resctrl, the maximum supported bandwidth is not currently shown.

Add max_bandwidth to report the maximum bandwidth permitted for a resource.
This helps users understand the limits of the associated resource control
group.

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
 Documentation/filesystems/resctrl.rst |  6 +++++-
 fs/resctrl/rdtgroup.c                 | 17 +++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesystems/resctrl.rst
index 45dde8774128..94187dd3c244 100644
--- a/Documentation/filesystems/resctrl.rst
+++ b/Documentation/filesystems/resctrl.rst
@@ -224,7 +224,11 @@ Memory bandwidth(MB) subdirectory contains the following files
 with respect to allocation:
 
 "min_bandwidth":
-		The minimum memory bandwidth percentage which
+		The minimum memory bandwidth percentage or units which
+		user can request.
+
+"max_bandwidth":
+		The maximum memory bandwidth percentage or units which
 		user can request.
 
 "bandwidth_gran":
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index ae6c515f4c19..d2eab9007cc1 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -1153,6 +1153,16 @@ static int rdt_min_bw_show(struct kernfs_open_file *of,
 	return 0;
 }
 
+static int rdt_max_bw_show(struct kernfs_open_file *of,
+			   struct seq_file *seq, void *v)
+{
+	struct resctrl_schema *s = rdt_kn_parent_priv(of->kn);
+	struct rdt_resource *r = s->res;
+
+	seq_printf(seq, "%u\n", r->membw.max_bw);
+	return 0;
+}
+
 static int rdt_num_rmids_show(struct kernfs_open_file *of,
 			      struct seq_file *seq, void *v)
 {
@@ -1959,6 +1969,13 @@ static struct rftype res_common_files[] = {
 		.seq_show	= rdt_min_bw_show,
 		.fflags		= RFTYPE_CTRL_INFO | RFTYPE_RES_MB,
 	},
+	{
+		.name		= "max_bandwidth",
+		.mode		= 0444,
+		.kf_ops		= &rdtgroup_kf_single_ops,
+		.seq_show	= rdt_max_bw_show,
+		.fflags		= RFTYPE_CTRL_INFO | RFTYPE_RES_MB,
+	},
 	{
 		.name		= "bandwidth_gran",
 		.mode		= 0444,
-- 
2.34.1
Re: [RFC PATCH 03/19] fs/resctrl: Add new interface max_bandwidth
Posted by Reinette Chatre 1 day, 15 hours ago
Hi Babu,

On 1/21/26 1:12 PM, Babu Moger wrote:
> While min_bandwidth is exposed for each resource under
> /sys/fs/resctrl, the maximum supported bandwidth is not currently shown.
> 
> Add max_bandwidth to report the maximum bandwidth permitted for a resource.
> This helps users understand the limits of the associated resource control
> group.
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---

With resctrl fs being used by several architectures we should take care that
interface changes take all planned usages into account. 

As shared at LPC [1] and email [2] we are already trying to create an interface
that works for everybody and it already contains a way to expose the maximum
bandwidth to user space. You attended that LPC session and [2] directed to you
received no response. This submission with a different interface is unexpected.

Reinette

[1] https://lpc.events/event/19/contributions/2093/attachments/1958/4172/resctrl%20Microconference%20LPC%202025%20Tokyo.pdf
[2] https://lore.kernel.org/lkml/fb1e2686-237b-4536-acd6-15159abafcba@intel.com/