[v5,6/8] x86/resctrl: Display CLOSID and RMID for the resctrl groups

Message ID 168564611100.527584.7981937236207103115.stgit@bmoger-ubuntu
State New
Headers
Series x86/resctrl: Miscellaneous resctrl features |

Commit Message

Moger, Babu June 1, 2023, 7:01 p.m. UTC
  In x86, hardware uses CLOSID and an RMID to identify a control group and
a monitoring group respectively. When a user creates a control or monitor
group these details are not visible to the user. These details can help
to debug the issues.

Add CLOSID(ctrl_hw_id) and RMID(mon_hw_id) to the control/monitor groups
display in resctrl interface. Users can see these details when mounted
with "-o debug" option.

For example:
 $cat /sys/fs/resctrl/ctrl_grp1/ctrl_hw_id
 1
 $cat /sys/fs/resctrl/mon_groups/mon_grp1/mon_hw_id
 3

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
 Documentation/arch/x86/resctrl.rst     |    8 ++++++
 arch/x86/kernel/cpu/resctrl/rdtgroup.c |   44 ++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
  

Comments

Reinette Chatre July 7, 2023, 9:45 p.m. UTC | #1
Hi Babu,

On 6/1/2023 12:01 PM, Babu Moger wrote:
> In x86, hardware uses CLOSID and an RMID to identify a control group and
> a monitoring group respectively. When a user creates a control or monitor
> group these details are not visible to the user. These details can help
> to debug the issues.

"to debug the issues" -> "to debug issues"? Even so "issues" is vague,
perhaps just "These details can help debugging."

> 
> Add CLOSID(ctrl_hw_id) and RMID(mon_hw_id) to the control/monitor groups
> display in resctrl interface. Users can see these details when mounted

"when mounted with" -> "when resctrl is mounted with"?

> with "-o debug" option.

Could you please add a snippet to explain the file naming choice? Just a
mention that this is done in support of other architectures that do not use
"CLOSID" and "RMID". 

Considering that, "x86/resctrl: Display hardware ids of resource groups"
may be a more appropriate subject.


Reinette
  
Moger, Babu July 12, 2023, 7:36 p.m. UTC | #2
Hi Reinette,

On 7/7/23 16:45, Reinette Chatre wrote:
> Hi Babu,
> 
> On 6/1/2023 12:01 PM, Babu Moger wrote:
>> In x86, hardware uses CLOSID and an RMID to identify a control group and
>> a monitoring group respectively. When a user creates a control or monitor
>> group these details are not visible to the user. These details can help
>> to debug the issues.
> 
> "to debug the issues" -> "to debug issues"? Even so "issues" is vague,
> perhaps just "These details can help debugging."

Sure.
> 
>>
>> Add CLOSID(ctrl_hw_id) and RMID(mon_hw_id) to the control/monitor groups
>> display in resctrl interface. Users can see these details when mounted
> 
> "when mounted with" -> "when resctrl is mounted with"?

Sure.

> 
>> with "-o debug" option.
> 
> Could you please add a snippet to explain the file naming choice? Just a
> mention that this is done in support of other architectures that do not use
> "CLOSID" and "RMID". 
Adding this.

Other architectures do not use "CLOSID" and "RMID". Kept the names
ctrl_hw_id and mon_hw_id to refer "CLOSID" and "RMID" respectively in an
effort to keep the naming generic.

> 
> Considering that, "x86/resctrl: Display hardware ids of resource groups"
> may be a more appropriate subject.
Sure.
  
Reinette Chatre July 14, 2023, 9:53 p.m. UTC | #3
Hi Babu,

On 7/12/2023 12:36 PM, Moger, Babu wrote:
> On 7/7/23 16:45, Reinette Chatre wrote:
>> On 6/1/2023 12:01 PM, Babu Moger wrote:

>>
>> Could you please add a snippet to explain the file naming choice? Just a
>> mention that this is done in support of other architectures that do not use
>> "CLOSID" and "RMID". 
> Adding this.
> 
> Other architectures do not use "CLOSID" and "RMID". Kept the names
> ctrl_hw_id and mon_hw_id to refer "CLOSID" and "RMID" respectively in an
> effort to keep the naming generic.
> 

Looks good. I would just replace "Kept" with "Use" since this
change introduces these terms.

Reinette
  
Moger, Babu July 14, 2023, 10:45 p.m. UTC | #4
On 7/14/23 16:53, Reinette Chatre wrote:
> Hi Babu,
> 
> On 7/12/2023 12:36 PM, Moger, Babu wrote:
>> On 7/7/23 16:45, Reinette Chatre wrote:
>>> On 6/1/2023 12:01 PM, Babu Moger wrote:
> 
>>>
>>> Could you please add a snippet to explain the file naming choice? Just a
>>> mention that this is done in support of other architectures that do not use
>>> "CLOSID" and "RMID". 
>> Adding this.
>>
>> Other architectures do not use "CLOSID" and "RMID". Kept the names
>> ctrl_hw_id and mon_hw_id to refer "CLOSID" and "RMID" respectively in an
>> effort to keep the naming generic.
>>
> 
> Looks good. I would just replace "Kept" with "Use" since this
> change introduces these terms.

Sure. Will do that.
  

Patch

diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/resctrl.rst
index afdee4d1f691..1baf857ad8c6 100644
--- a/Documentation/arch/x86/resctrl.rst
+++ b/Documentation/arch/x86/resctrl.rst
@@ -344,6 +344,10 @@  When control is enabled all CTRL_MON groups will also contain:
 	file. On successful pseudo-locked region creation the mode will
 	automatically change to "pseudo-locked".
 
+"ctrl_hw_id":
+	Available only with debug option. The identifier used by hardware
+	for the control group. On x86 this is the CLOSID.
+
 When monitoring is enabled all MON groups will also contain:
 
 "mon_data":
@@ -357,6 +361,10 @@  When monitoring is enabled all MON groups will also contain:
 	the sum for all tasks in the CTRL_MON group and all tasks in
 	MON groups. Please see example section for more details on usage.
 
+"mon_hw_id":
+	Available only with debug option. The identifier used by hardware
+	for the monitor group. On x86 this is the RMID.
+
 Resource allocation rules
 -------------------------
 
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index be91dea5f927..2f5cdc638607 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -763,6 +763,38 @@  static int rdtgroup_tasks_show(struct kernfs_open_file *of,
 	return ret;
 }
 
+static int rdtgroup_closid_show(struct kernfs_open_file *of,
+				struct seq_file *s, void *v)
+{
+	struct rdtgroup *rdtgrp;
+	int ret = 0;
+
+	rdtgrp = rdtgroup_kn_lock_live(of->kn);
+	if (rdtgrp)
+		seq_printf(s, "%u\n", rdtgrp->closid);
+	else
+		ret = -ENOENT;
+	rdtgroup_kn_unlock(of->kn);
+
+	return ret;
+}
+
+static int rdtgroup_rmid_show(struct kernfs_open_file *of,
+			      struct seq_file *s, void *v)
+{
+	struct rdtgroup *rdtgrp;
+	int ret = 0;
+
+	rdtgrp = rdtgroup_kn_lock_live(of->kn);
+	if (rdtgrp)
+		seq_printf(s, "%u\n", rdtgrp->mon.rmid);
+	else
+		ret = -ENOENT;
+	rdtgroup_kn_unlock(of->kn);
+
+	return ret;
+}
+
 #ifdef CONFIG_PROC_CPU_RESCTRL
 
 /*
@@ -1824,6 +1856,12 @@  static struct rftype res_common_files[] = {
 		.seq_show	= rdtgroup_tasks_show,
 		.fflags		= RFTYPE_BASE,
 	},
+	{
+		.name		= "mon_hw_id",
+		.mode		= 0444,
+		.kf_ops		= &rdtgroup_kf_single_ops,
+		.seq_show	= rdtgroup_rmid_show,
+	},
 	{
 		.name		= "schemata",
 		.mode		= 0644,
@@ -1847,6 +1885,12 @@  static struct rftype res_common_files[] = {
 		.seq_show	= rdtgroup_size_show,
 		.fflags		= RFTYPE_CTRL_BASE,
 	},
+	{
+		.name		= "ctrl_hw_id",
+		.mode		= 0444,
+		.kf_ops		= &rdtgroup_kf_single_ops,
+		.seq_show	= rdtgroup_closid_show,
+	},
 
 };