In x86, hardware uses RMID to identify a 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.
Add the flag RFTYPE_MON_BASE, which contains the files required only
for the MON group.
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 | 6 ++++
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 38 +++++++++++++++++++++++---
3 files changed, 44 insertions(+), 4 deletions(-)
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 ccdbed615d41..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
*
@@ -315,6 +320,7 @@ struct rdtgroup {
#define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
#define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
#define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
+#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON)
/* List of all resource groups */
extern struct list_head rdt_all_groups;
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 8be0fb323ad3..fc830ffce82a 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,
@@ -2535,6 +2558,7 @@ static void schemata_list_destroy(void)
static int rdt_get_tree(struct fs_context *fc)
{
struct rdt_fs_context *ctx = rdt_fc2context(fc);
+ unsigned long flags = RFTYPE_CTRL_BASE;
struct rdt_domain *dom;
struct rdt_resource *r;
int ret;
@@ -2565,7 +2589,10 @@ static int rdt_get_tree(struct fs_context *fc)
closid_init();
- ret = rdtgroup_add_files(rdtgroup_default.kn, RFTYPE_CTRL_BASE);
+ if (rdt_mon_capable)
+ flags |= RFTYPE_MON;
+
+ ret = rdtgroup_add_files(rdtgroup_default.kn, flags);
if (ret)
goto out_schemata_free;
@@ -3255,8 +3282,8 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
enum rdt_group_type rtype, struct rdtgroup **r)
{
struct rdtgroup *prdtgrp, *rdtgrp;
+ unsigned long files = 0;
struct kernfs_node *kn;
- uint files = 0;
int ret;
prdtgrp = rdtgroup_kn_lock_live(parent_kn);
@@ -3308,10 +3335,13 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
goto out_destroy;
}
- if (rtype == RDTCTRL_GROUP)
+ if (rtype == RDTCTRL_GROUP) {
files = RFTYPE_BASE | RFTYPE_CTRL;
- else
+ if (rdt_mon_capable)
+ files |= RFTYPE_MON;
+ } else {
files = RFTYPE_BASE | RFTYPE_MON;
+ }
ret = rdtgroup_add_files(kn, files);
if (ret) {
--
2.34.1
Hi Babu, On 9/7/2023 4:51 PM, Babu Moger wrote: > In x86, hardware uses RMID to identify a 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. > > Add the flag RFTYPE_MON_BASE, which contains the files required only > for the MON group. As I mentioned in [1] I believe adding support for files with RFTYPE_MON flag to resctrl needs to be in a separate patch. With the core support added a file with this flag can be introduced separately. Reinette [1] https://lore.kernel.org/lkml/2feb3e01-96c7-fdde-a0d2-509fa1527243@intel.com/
Hi Reinette,
On 9/11/23 18:08, Reinette Chatre wrote:
> Hi Babu,
>
> On 9/7/2023 4:51 PM, Babu Moger wrote:
>> In x86, hardware uses RMID to identify a 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.
>>
>> Add the flag RFTYPE_MON_BASE, which contains the files required only
>> for the MON group.
>
> As I mentioned in [1] I believe adding support for files with RFTYPE_MON flag
> to resctrl needs to be in a separate patch. With the core support added a file
> with this flag can be introduced separately.
Yes. We discussed it. Thought it may not fit as a separate patch on its
own. So, i combined it.
Now, I split patch 9 into two. Let me know if it looks ok.
==========================================================================
Author: Babu Moger <babu.moger@amd.com>
Date: Thu Sep 7 18:51:28 2023 -0500
x86/resctrl: Add RFTYPE_MON_BASE for MON groups
Add the flag RFTYPE_MON_BASE, which contains the files required only
for the MON group. Files with these flags are only visible when
monitoring is enabled.
Signed-off-by: Babu Moger <babu.moger@amd.com>
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h
b/arch/x86/kernel/cpu/resctrl/internal.h
index ccdbed615d41..72988e5c52a7 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -296,6 +296,8 @@ 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_CTRL (Files only for CTRL group)
* Files: mode, schemata, size
*
@@ -315,6 +317,7 @@ struct rdtgroup {
#define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
#define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
#define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
+#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON)
/* List of all resource groups */
extern struct list_head rdt_all_groups;
=============================================================================
Thanks
Babu Moger
Hi Babu,
On 9/12/2023 10:39 AM, Moger, Babu wrote:
> On 9/11/23 18:08, Reinette Chatre wrote:
>> Hi Babu,
>>
>> On 9/7/2023 4:51 PM, Babu Moger wrote:
>>> In x86, hardware uses RMID to identify a 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.
>>>
>>> Add the flag RFTYPE_MON_BASE, which contains the files required only
>>> for the MON group.
>>
>> As I mentioned in [1] I believe adding support for files with RFTYPE_MON flag
>> to resctrl needs to be in a separate patch. With the core support added a file
>> with this flag can be introduced separately.
>
> Yes. We discussed it. Thought it may not fit as a separate patch on its
> own. So, i combined it.
>
> Now, I split patch 9 into two. Let me know if it looks ok.
>
> ==========================================================================
>
> Author: Babu Moger <babu.moger@amd.com>
> Date: Thu Sep 7 18:51:28 2023 -0500
>
> x86/resctrl: Add RFTYPE_MON_BASE for MON groups
>
> Add the flag RFTYPE_MON_BASE, which contains the files required only
> for the MON group. Files with these flags are only visible when
> monitoring is enabled.
>
> Signed-off-by: Babu Moger <babu.moger@amd.com>
>
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h
> b/arch/x86/kernel/cpu/resctrl/internal.h
> index ccdbed615d41..72988e5c52a7 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -296,6 +296,8 @@ 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_CTRL (Files only for CTRL group)
> * Files: mode, schemata, size
> *
I think it would be ok to add above hunk as part of the patch
that adds mon_hw_id, similar to what you did in patch 8.
> @@ -315,6 +317,7 @@ struct rdtgroup {
> #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
> #define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
> #define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
> +#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON)
>
This hunk may be appropriate for patch 3.
> /* List of all resource groups */
> extern struct list_head rdt_all_groups;
>
This is not how I expected it to look. There is currently an issue
in resctrl where files with RFTYPE_MON are not created for CTRL_MON
groups. This has not actually been a problem because there are
no files with the RFTYPE_MON flag. This series introduces the first
file with RFTYPE_MON flag and thus this resctrl issue needs to be fixed
before this new file can be supported.
Considering this I expected to see the changes in rdt_get_tree()
and mkdir_rdt_prepare() done as a separate patch. This will add
support for RFTYPE_MON files to resctrl. After this change
a separate patch can add the file that has this flag.
Reinette
Hi Reinette,
On 9/12/23 12:57, Reinette Chatre wrote:
> Hi Babu,
>
> On 9/12/2023 10:39 AM, Moger, Babu wrote:
>> On 9/11/23 18:08, Reinette Chatre wrote:
>>> Hi Babu,
>>>
>>> On 9/7/2023 4:51 PM, Babu Moger wrote:
>>>> In x86, hardware uses RMID to identify a 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.
>>>>
>>>> Add the flag RFTYPE_MON_BASE, which contains the files required only
>>>> for the MON group.
>>>
>>> As I mentioned in [1] I believe adding support for files with RFTYPE_MON flag
>>> to resctrl needs to be in a separate patch. With the core support added a file
>>> with this flag can be introduced separately.
>>
>> Yes. We discussed it. Thought it may not fit as a separate patch on its
>> own. So, i combined it.
>>
>> Now, I split patch 9 into two. Let me know if it looks ok.
>>
>> ==========================================================================
>>
>> Author: Babu Moger <babu.moger@amd.com>
>> Date: Thu Sep 7 18:51:28 2023 -0500
>>
>> x86/resctrl: Add RFTYPE_MON_BASE for MON groups
>>
>> Add the flag RFTYPE_MON_BASE, which contains the files required only
>> for the MON group. Files with these flags are only visible when
>> monitoring is enabled.
>>
>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>>
>> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h
>> b/arch/x86/kernel/cpu/resctrl/internal.h
>> index ccdbed615d41..72988e5c52a7 100644
>> --- a/arch/x86/kernel/cpu/resctrl/internal.h
>> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
>> @@ -296,6 +296,8 @@ 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_CTRL (Files only for CTRL group)
>> * Files: mode, schemata, size
>> *
>
> I think it would be ok to add above hunk as part of the patch
> that adds mon_hw_id, similar to what you did in patch 8.
Ok. Sure.
>
>> @@ -315,6 +317,7 @@ struct rdtgroup {
>> #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
>> #define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
>> #define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
>> +#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON)
>>
>
> This hunk may be appropriate for patch 3.
Sure.
>
>> /* List of all resource groups */
>> extern struct list_head rdt_all_groups;
>>
>
> This is not how I expected it to look. There is currently an issue
> in resctrl where files with RFTYPE_MON are not created for CTRL_MON
> groups. This has not actually been a problem because there are
> no files with the RFTYPE_MON flag. This series introduces the first
> file with RFTYPE_MON flag and thus this resctrl issue needs to be fixed
> before this new file can be supported.
Yes.
>
> Considering this I expected to see the changes in rdt_get_tree()
> and mkdir_rdt_prepare() done as a separate patch. This will add
> support for RFTYPE_MON files to resctrl. After this change
> a separate patch can add the file that has this flag.
>
Sure. Got it.
Thanks
Babu Moger
Hi, Babu,
On 9/7/23 16:51, Babu Moger wrote:
> In x86, hardware uses RMID to identify a a monitoring group. When a
s/a a/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.
>
> Add the flag RFTYPE_MON_BASE, which contains the files required only
> for the MON group.
>
> 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 | 6 ++++
> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 38 +++++++++++++++++++++++---
> 3 files changed, 44 insertions(+), 4 deletions(-)
>
> 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 ccdbed615d41..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
> *
> @@ -315,6 +320,7 @@ struct rdtgroup {
> #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
> #define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
> #define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
> +#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON)
>
> /* List of all resource groups */
> extern struct list_head rdt_all_groups;
> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
> index 8be0fb323ad3..fc830ffce82a 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,
Similar to showing ctrl_hw_id, is it better to rename
"rdtgroup_rmid_show" as "rdtgroup_mon_hw_id_show" for arch neutral naming?
> + .fflags = RFTYPE_MON_BASE | RFTYPE_DEBUG,
> + },
> {
> .name = "schemata",
> .mode = 0644,
> @@ -2535,6 +2558,7 @@ static void schemata_list_destroy(void)
> static int rdt_get_tree(struct fs_context *fc)
> {
> struct rdt_fs_context *ctx = rdt_fc2context(fc);
> + unsigned long flags = RFTYPE_CTRL_BASE;
> struct rdt_domain *dom;
> struct rdt_resource *r;
> int ret;
> @@ -2565,7 +2589,10 @@ static int rdt_get_tree(struct fs_context *fc)
>
> closid_init();
>
> - ret = rdtgroup_add_files(rdtgroup_default.kn, RFTYPE_CTRL_BASE);
> + if (rdt_mon_capable)
> + flags |= RFTYPE_MON;
> +
> + ret = rdtgroup_add_files(rdtgroup_default.kn, flags);
> if (ret)
> goto out_schemata_free;
>
> @@ -3255,8 +3282,8 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
> enum rdt_group_type rtype, struct rdtgroup **r)
> {
> struct rdtgroup *prdtgrp, *rdtgrp;
> + unsigned long files = 0;
> struct kernfs_node *kn;
> - uint files = 0;
> int ret;
>
> prdtgrp = rdtgroup_kn_lock_live(parent_kn);
> @@ -3308,10 +3335,13 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
> goto out_destroy;
> }
>
> - if (rtype == RDTCTRL_GROUP)
> + if (rtype == RDTCTRL_GROUP) {
> files = RFTYPE_BASE | RFTYPE_CTRL;
> - else
> + if (rdt_mon_capable)
> + files |= RFTYPE_MON;
> + } else {
> files = RFTYPE_BASE | RFTYPE_MON;
> + }
>
> ret = rdtgroup_add_files(kn, files);
> if (ret) {
Thanks.
-Fenghua
Hi Fenghua,
On 9/11/23 13:14, Fenghua Yu wrote:
> Hi, Babu,
>
> On 9/7/23 16:51, Babu Moger wrote:
>> In x86, hardware uses RMID to identify a a monitoring group. When a
>
> s/a a/a/
Sure.
Thanks for the review. Reinette has already addressed other comments.
Thanks
Babu
>
>> 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.
>>
>> Add the flag RFTYPE_MON_BASE, which contains the files required only
>> for the MON group.
>>
>> 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 | 6 ++++
>> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 38 +++++++++++++++++++++++---
>> 3 files changed, 44 insertions(+), 4 deletions(-)
>>
>> 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 ccdbed615d41..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
>> *
>> @@ -315,6 +320,7 @@ struct rdtgroup {
>> #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
>> #define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)
>> #define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL)
>> +#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON)
>> /* List of all resource groups */
>> extern struct list_head rdt_all_groups;
>> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
>> index 8be0fb323ad3..fc830ffce82a 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,
>
> Similar to showing ctrl_hw_id, is it better to rename "rdtgroup_rmid_show"
> as "rdtgroup_mon_hw_id_show" for arch neutral naming?
>
>> + .fflags = RFTYPE_MON_BASE | RFTYPE_DEBUG,
>> + },
>> {
>> .name = "schemata",
>> .mode = 0644,
>> @@ -2535,6 +2558,7 @@ static void schemata_list_destroy(void)
>> static int rdt_get_tree(struct fs_context *fc)
>> {
>> struct rdt_fs_context *ctx = rdt_fc2context(fc);
>> + unsigned long flags = RFTYPE_CTRL_BASE;
>> struct rdt_domain *dom;
>> struct rdt_resource *r;
>> int ret;
>> @@ -2565,7 +2589,10 @@ static int rdt_get_tree(struct fs_context *fc)
>> closid_init();
>> - ret = rdtgroup_add_files(rdtgroup_default.kn, RFTYPE_CTRL_BASE);
>> + if (rdt_mon_capable)
>> + flags |= RFTYPE_MON;
>> +
>> + ret = rdtgroup_add_files(rdtgroup_default.kn, flags);
>> if (ret)
>> goto out_schemata_free;
>> @@ -3255,8 +3282,8 @@ static int mkdir_rdt_prepare(struct kernfs_node
>> *parent_kn,
>> enum rdt_group_type rtype, struct rdtgroup **r)
>> {
>> struct rdtgroup *prdtgrp, *rdtgrp;
>> + unsigned long files = 0;
>> struct kernfs_node *kn;
>> - uint files = 0;
>> int ret;
>> prdtgrp = rdtgroup_kn_lock_live(parent_kn);
>> @@ -3308,10 +3335,13 @@ static int mkdir_rdt_prepare(struct kernfs_node
>> *parent_kn,
>> goto out_destroy;
>> }
>> - if (rtype == RDTCTRL_GROUP)
>> + if (rtype == RDTCTRL_GROUP) {
>> files = RFTYPE_BASE | RFTYPE_CTRL;
>> - else
>> + if (rdt_mon_capable)
>> + files |= RFTYPE_MON;
>> + } else {
>> files = RFTYPE_BASE | RFTYPE_MON;
>> + }
>> ret = rdtgroup_add_files(kn, files);
>> if (ret) {
>
> Thanks.
>
> -Fenghua
--
Thanks
Babu Moger
© 2016 - 2025 Red Hat, Inc.