[v10,10/10] x86/resctrl: Display RMID of resource group

Message ID 20230915224227.1336967-11-babu.moger@amd.com
State New
Headers
Series x86/resctrl: Miscellaneous resctrl features |

Commit Message

Moger, Babu Sept. 15, 2023, 10:42 p.m. UTC
  In x86, hardware uses RMID to identify a monitoring group. When a user
creates a monitor group these details are not visible. These details
can help resctrl debugging.

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

Other architectures do not use "RMID". Use the name mon_hw_id to refer
to "RMID" in an effort to keep the naming generic.

For example:
 $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     |  4 ++++
 arch/x86/kernel/cpu/resctrl/internal.h |  5 +++++
 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 23 +++++++++++++++++++++++
 3 files changed, 32 insertions(+)
  

Comments

Peter Newman Sept. 22, 2023, 2:36 p.m. UTC | #1
Hi Babu,

On Sat, Sep 16, 2023 at 12:42 AM Babu Moger <babu.moger@amd.com> wrote:
>
> In x86, hardware uses RMID to identify a monitoring group. When a user
> creates a monitor group these details are not visible. These details
> can help resctrl debugging.
>
> Add RMID(mon_hw_id) to the monitor groups display in resctrl interface.
> Users can see these details when resctrl is mounted with "-o debug" option.

When I reviewed this, I went through the whole series second-guessing
the wording above and wondering whether "monitoring groups" applied to
CTRL_MON groups.

I was able to confirm that mon_hw_id did appear and had a believable
value in CTRL_MON groups which had allocated monitors. (and I added
some comma-separated PID lists to the tasks node)

for the series:
Tested-By: Peter Newman <peternewman@google.com>

> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index a07fa4329b65..b4910892b0a6 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -296,6 +296,11 @@ struct rdtgroup {
>   *     --> RFTYPE_BASE (Files common for both MON and CTRL groups)
>   *         Files: cpus, cpus_list, tasks
>   *
> + *             --> RFTYPE_MON (Files only for MON group)

If monitoring is supported, all groups are MON groups. I think the
"only" above caused me to second guess whether this takes into account
CTRL_MON groups getting the RFTYPE_MON flag set dynamically.

However, I think the documentation above is still technically accurate.

for the series:
Reviewed-By: Peter Newman <peternewman@google.com>

Thanks!
-Peter
  
Moger, Babu Sept. 22, 2023, 3:49 p.m. UTC | #2
Hi Peter,

On 9/22/2023 9:36 AM, Peter Newman wrote:
> Hi Babu,
>
> On Sat, Sep 16, 2023 at 12:42 AM Babu Moger <babu.moger@amd.com> wrote:
>> In x86, hardware uses RMID to identify a monitoring group. When a user
>> creates a monitor group these details are not visible. These details
>> can help resctrl debugging.
>>
>> Add RMID(mon_hw_id) to the monitor groups display in resctrl interface.
>> Users can see these details when resctrl is mounted with "-o debug" option.
> When I reviewed this, I went through the whole series second-guessing
> the wording above and wondering whether "monitoring groups" applied to
> CTRL_MON groups.
>
> I was able to confirm that mon_hw_id did appear and had a believable
> value in CTRL_MON groups which had allocated monitors. (and I added
> some comma-separated PID lists to the tasks node)
>
> for the series:
> Tested-By: Peter Newman <peternewman@google.com>
Thank you.
>
>> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
>> index a07fa4329b65..b4910892b0a6 100644
>> --- a/arch/x86/kernel/cpu/resctrl/internal.h
>> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
>> @@ -296,6 +296,11 @@ struct rdtgroup {
>>    *     --> RFTYPE_BASE (Files common for both MON and CTRL groups)
>>    *         Files: cpus, cpus_list, tasks
>>    *
>> + *             --> RFTYPE_MON (Files only for MON group)
> If monitoring is supported, all groups are MON groups. I think the
> "only" above caused me to second guess whether this takes into account
> CTRL_MON groups getting the RFTYPE_MON flag set dynamically.
>
> However, I think the documentation above is still technically accurate.
Thanks. If there is another revision, I am open to remove "only" from 
this text.
>
> for the series:
> Reviewed-By: Peter Newman <peternewman@google.com>

Thanks

Babu
  
Fenghua Yu Sept. 22, 2023, 5:59 p.m. UTC | #3
Hi, Peter,

On 9/22/23 07:36, Peter Newman wrote:
> Hi Babu,
> 
> On Sat, Sep 16, 2023 at 12:42 AM Babu Moger <babu.moger@amd.com> wrote:
>>
>> In x86, hardware uses RMID to identify a monitoring group. When a user
>> creates a monitor group these details are not visible. These details
>> can help resctrl debugging.
>>
>> Add RMID(mon_hw_id) to the monitor groups display in resctrl interface.
>> Users can see these details when resctrl is mounted with "-o debug" option.
> 
> When I reviewed this, I went through the whole series second-guessing
> the wording above and wondering whether "monitoring groups" applied to
> CTRL_MON groups.
> 
> I was able to confirm that mon_hw_id did appear and had a believable
> value in CTRL_MON groups which had allocated monitors. (and I added
> some comma-separated PID lists to the tasks node)
> 
> for the series:
> Tested-By: Peter Newman <peternewman@google.com>

Please use "Tested-by" instead of "Tested-By" (the "By" is wrong).

> 
>> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
>> index a07fa4329b65..b4910892b0a6 100644
>> --- a/arch/x86/kernel/cpu/resctrl/internal.h
>> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
>> @@ -296,6 +296,11 @@ struct rdtgroup {
>>    *     --> RFTYPE_BASE (Files common for both MON and CTRL groups)
>>    *         Files: cpus, cpus_list, tasks
>>    *
>> + *             --> RFTYPE_MON (Files only for MON group)
> 
> If monitoring is supported, all groups are MON groups. I think the
> "only" above caused me to second guess whether this takes into account
> CTRL_MON groups getting the RFTYPE_MON flag set dynamically.
> 
> However, I think the documentation above is still technically accurate.
> 
> for the series:
> Reviewed-By: Peter Newman <peternewman@google.com>

Please use "Reviewed-by" instead of "Reviewed-By" (the "By" is wrong).

Thanks.

-Fenghua
  
Peter Newman Sept. 25, 2023, 8:10 a.m. UTC | #4
On Fri, Sep 22, 2023 at 7:59 PM Fenghua Yu <fenghua.yu@intel.com> wrote:
> On 9/22/23 07:36, Peter Newman wrote:
> > On Sat, Sep 16, 2023 at 12:42 AM Babu Moger <babu.moger@amd.com> wrote:
> >>
> >> In x86, hardware uses RMID to identify a monitoring group. When a user
> >> creates a monitor group these details are not visible. These details
> >> can help resctrl debugging.
> >>
> >> Add RMID(mon_hw_id) to the monitor groups display in resctrl interface.
> >> Users can see these details when resctrl is mounted with "-o debug" option.
> >
> > When I reviewed this, I went through the whole series second-guessing
> > the wording above and wondering whether "monitoring groups" applied to
> > CTRL_MON groups.
> >
> > I was able to confirm that mon_hw_id did appear and had a believable
> > value in CTRL_MON groups which had allocated monitors. (and I added
> > some comma-separated PID lists to the tasks node)
> >
> > for the series:
> > Tested-By: Peter Newman <peternewman@google.com>
>
> Please use "Tested-by" instead of "Tested-By" (the "By" is wrong).

Tested-by: Peter Newman <peternewman@google.com>

> >
> >> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> >> index a07fa4329b65..b4910892b0a6 100644
> >> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> >> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> >> @@ -296,6 +296,11 @@ struct rdtgroup {
> >>    *     --> RFTYPE_BASE (Files common for both MON and CTRL groups)
> >>    *         Files: cpus, cpus_list, tasks
> >>    *
> >> + *             --> RFTYPE_MON (Files only for MON group)
> >
> > If monitoring is supported, all groups are MON groups. I think the
> > "only" above caused me to second guess whether this takes into account
> > CTRL_MON groups getting the RFTYPE_MON flag set dynamically.
> >
> > However, I think the documentation above is still technically accurate.
> >
> > for the series:
> > Reviewed-By: Peter Newman <peternewman@google.com>
>
> Please use "Reviewed-by" instead of "Reviewed-By" (the "By" is wrong).

Reviewed-by: Peter Newman <peternewman@google.com>
  
Fenghua Yu Sept. 25, 2023, 9:21 p.m. UTC | #5
On 9/15/23 15:42, Babu Moger wrote:
> In x86, hardware uses RMID to identify a monitoring group. When a user
> creates a monitor group these details are not visible. These details
> can help resctrl debugging.
> 
> Add RMID(mon_hw_id) to the monitor groups display in resctrl interface.
> Users can see these details when resctrl is mounted with "-o debug" option.
> 
> Other architectures do not use "RMID". Use the name mon_hw_id to refer
> to "RMID" in an effort to keep the naming generic.
> 
> For example:
>   $cat /sys/fs/resctrl/mon_groups/mon_grp1/mon_hw_id
>   3
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>

Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>

Thanks.

-Fenghua
  
Reinette Chatre Sept. 27, 2023, 6:35 p.m. UTC | #6
Hi Babu,

On 9/15/2023 3:42 PM, Babu Moger wrote:
> In x86, hardware uses RMID to identify a monitoring group. When a user
> creates a monitor group these details are not visible. These details
> can help resctrl debugging.
> 
> Add RMID(mon_hw_id) to the monitor groups display in resctrl interface.
> Users can see these details when resctrl is mounted with "-o debug" option.
> 
> Other architectures do not use "RMID". Use the name mon_hw_id to refer
> to "RMID" in an effort to keep the naming generic.
> 
> For example:
>  $cat /sys/fs/resctrl/mon_groups/mon_grp1/mon_hw_id
>  3
> 
> Signed-off-by: Babu Moger <babu.moger@amd.com>
> ---

Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>

Reinette
  
Ilpo Järvinen Sept. 29, 2023, 3:56 p.m. UTC | #7
On Fri, 15 Sep 2023, Babu Moger wrote:

> In x86, hardware uses RMID to identify a monitoring group. When a user
> creates a monitor group these details are not visible. These details
> can help resctrl debugging.
> 
> Add RMID(mon_hw_id) to the monitor groups display in resctrl interface.
> Users can see these details when resctrl is mounted with "-o debug" option.
> 
> Other architectures do not use "RMID". Use the name mon_hw_id to refer
> to "RMID" in an effort to keep the naming generic.
> 
> For example:
>  $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     |  4 ++++
>  arch/x86/kernel/cpu/resctrl/internal.h |  5 +++++
>  arch/x86/kernel/cpu/resctrl/rdtgroup.c | 23 +++++++++++++++++++++++
>  3 files changed, 32 insertions(+)
> 
> diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/resctrl.rst
> index 54691c8b832d..98b0eb509ed4 100644
> --- a/Documentation/arch/x86/resctrl.rst
> +++ b/Documentation/arch/x86/resctrl.rst
> @@ -369,6 +369,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/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index a07fa4329b65..b4910892b0a6 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -296,6 +296,11 @@ struct rdtgroup {
>   *	--> RFTYPE_BASE (Files common for both MON and CTRL groups)
>   *	    Files: cpus, cpus_list, tasks
>   *
> + *		--> RFTYPE_MON (Files only for MON group)
> + *
> + *			--> RFTYPE_DEBUG (Files to help resctrl debugging)
> + *			    File: mon_hw_id
> + *
>   *		--> RFTYPE_CTRL (Files only for CTRL group)
>   *		    Files: mode, schemata, size
>   *
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 55d1b90f460e..ef4b18091e5d 100644
> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> @@ -795,6 +795,22 @@ static int rdtgroup_closid_show(struct kernfs_open_file *of,
>  	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
>  
>  /*
> @@ -1856,6 +1872,13 @@ 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,
> +		.fflags		= RFTYPE_MON_BASE | RFTYPE_DEBUG,
> +	},
>  	{
>  		.name		= "schemata",
>  		.mode		= 0644,
> 

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
  

Patch

diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/resctrl.rst
index 54691c8b832d..98b0eb509ed4 100644
--- a/Documentation/arch/x86/resctrl.rst
+++ b/Documentation/arch/x86/resctrl.rst
@@ -369,6 +369,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/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index a07fa4329b65..b4910892b0a6 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -296,6 +296,11 @@  struct rdtgroup {
  *	--> RFTYPE_BASE (Files common for both MON and CTRL groups)
  *	    Files: cpus, cpus_list, tasks
  *
+ *		--> RFTYPE_MON (Files only for MON group)
+ *
+ *			--> RFTYPE_DEBUG (Files to help resctrl debugging)
+ *			    File: mon_hw_id
+ *
  *		--> RFTYPE_CTRL (Files only for CTRL group)
  *		    Files: mode, schemata, size
  *
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 55d1b90f460e..ef4b18091e5d 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -795,6 +795,22 @@  static int rdtgroup_closid_show(struct kernfs_open_file *of,
 	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
 
 /*
@@ -1856,6 +1872,13 @@  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,
+		.fflags		= RFTYPE_MON_BASE | RFTYPE_DEBUG,
+	},
 	{
 		.name		= "schemata",
 		.mode		= 0644,