Hi Reinette,
To be honest, I had tough time understanding these flags. Also, I need to
add more files in the future. So, I am trying make these these things
clear before I do those changes.
These flags decoding is pretty confusing. Also, there are some flags which
are duplicate. Not really required.
For example:
In group structure, we have control group or mon group. We just need two
bits here. The code uses combination of 3 flags here.
#define RFTYPE_BASE BIT(1)
#define RFTYPE_CTRL BIT(4)
#define RFTYPE_MON BIT(5)
Also, the flag RFTYPE_MON again used in creation on info directory.
Basically, very confusing to add anything new.
I will try to minimize the changes in the next version but still make it
clear.
On 3/15/23 13:37, Reinette Chatre wrote:
> Hi Babu,
>
> On 3/2/2023 12:24 PM, Babu Moger wrote:
>> RESCTRL filesystem has two main components:
>> a. info (Details on resources and monitoring)
>> b. base (Details on CONTROL and MON groups)
>>
>> The rftype flags can be renamed accordingly for better understanding.
>> For example:
>> RFTYPE_INFO : Files with these flags go in info directory
>
> This is not a rename but the current name.
Agree. I am giving some example here. I may not need to change the text here.
>
>> RFTYPE_INFO_MON : Files with these flags go in info/L3_MON
>
> How does this improve the current RFTYPE_MON_INFO?
RFTYPE_INFO_MON -> info/L3_MON.
I tried to improve some readability based on hierarchy. Basically, looking
at the flags we know exaclty where these files land.
>
>> RFTYPE_BASE : Files with these flags go in group's(control or mon)
>> base directory
> This is not a rename but the current name.
>
>> RFTYPE_BASE_CTRL: Files with these flags go in only CONTROL groups
>
> How does this improve current RFTYPE_CTRL_BASE ?
Again, same explanation as above. Started with RFTYPE_BASE and added
RFTYPE_BASE_CTRL to say these files are on top of base.
>
>>
>> Add comments to make it easy for future additions.
>>
>> Signed-off-by: Babu Moger <babu.moger@amd.com>
>> ---
>> arch/x86/kernel/cpu/resctrl/core.c | 8 ++--
>> arch/x86/kernel/cpu/resctrl/internal.h | 64 ++++++++++++++++++++++++++++----
>> arch/x86/kernel/cpu/resctrl/rdtgroup.c | 44 +++++++++++-----------
>> 3 files changed, 81 insertions(+), 35 deletions(-)
>>
>> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
>> index 030d3b409768..d1c6b2cc8611 100644
>> --- a/arch/x86/kernel/cpu/resctrl/core.c
>> +++ b/arch/x86/kernel/cpu/resctrl/core.c
>> @@ -69,7 +69,7 @@ struct rdt_hw_resource rdt_resources_all[] = {
>> .domains = domain_init(RDT_RESOURCE_L3),
>> .parse_ctrlval = parse_cbm,
>> .format_str = "%d=%0*x",
>> - .fflags = RFTYPE_RES_CACHE,
>> + .fflags = RFTYPE_CACHE,
>> },
>
> How does this rename improve understanding?
Agree. This change may not be required. I can actually remove these changes
>
> ...
>
>> @@ -97,7 +97,7 @@ struct rdt_hw_resource rdt_resources_all[] = {
>> .domains = domain_init(RDT_RESOURCE_MBA),
>> .parse_ctrlval = parse_bw,
>> .format_str = "%d=%*u",
>> - .fflags = RFTYPE_RES_MB,
>> + .fflags = RFTYPE_MB,
>> },
>> },
>> [RDT_RESOURCE_SMBA] =
>
> ditto.
Agree. This change may not be required. I can actually remove these changes
.
>
>
> ...
>
>> + *
>> */
>> #define RFTYPE_INFO BIT(0)
>> #define RFTYPE_BASE BIT(1)
>> -#define RFTYPE_CTRL BIT(4)
>> -#define RFTYPE_MON BIT(5)
>> -#define RFTYPE_TOP BIT(6)
>> -#define RFTYPE_RES_CACHE BIT(8)
>> -#define RFTYPE_RES_MB BIT(9)
>> -#define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL)
>> -#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_TOP BIT(2)
>> +#define RFTYPE_MON BIT(3)
>> +#define RFTYPE_RES BIT(4)
>> +
>> +#define RFTYPE_CACHE BIT(5)
>> +#define RFTYPE_MB BIT(6)
>> +
>> +#define RFTYPE_CTRL BIT(8)
>> +
>> +#define RFTYPE_INFO_TOP (RFTYPE_INFO | RFTYPE_TOP)
>> +#define RFTYPE_INFO_MON (RFTYPE_INFO | RFTYPE_MON)
>> +#define RFTYPE_INFO_RES (RFTYPE_INFO | RFTYPE_RES)
>> +
>> +#define RFTYPE_BASE_CTRL (RFTYPE_BASE | RFTYPE_CTRL)
>>
>
> It is not clear to me how any of the renames improves understanding.
>
> How does renaming RFTYPE_CTRL_BASE to RFTYPE_BASE_CTRL improve
> understanding? Renaming RFTYPE_MON_INFO to RFTYPE_INFO_MON?
>
> This all seems unnecessary.
Again see my comments in the beginning.
>
> ...
>
>> @@ -3218,7 +3218,7 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
>> if (rtype == RDTCTRL_GROUP)
>> fflags = RFTYPE_BASE | RFTYPE_CTRL;
>> else
>> - fflags = RFTYPE_BASE | RFTYPE_MON;
>> + fflags = RFTYPE_BASE;
>>
>
> Is this intended?
Yes. We don't need this extra flag (RFTYPE_MON) here.
Thanks
Babu Moger
@@ -69,7 +69,7 @@ struct rdt_hw_resource rdt_resources_all[] = {
.domains = domain_init(RDT_RESOURCE_L3),
.parse_ctrlval = parse_cbm,
.format_str = "%d=%0*x",
- .fflags = RFTYPE_RES_CACHE,
+ .fflags = RFTYPE_CACHE,
},
.msr_base = MSR_IA32_L3_CBM_BASE,
.msr_update = cat_wrmsr,
@@ -83,7 +83,7 @@ struct rdt_hw_resource rdt_resources_all[] = {
.domains = domain_init(RDT_RESOURCE_L2),
.parse_ctrlval = parse_cbm,
.format_str = "%d=%0*x",
- .fflags = RFTYPE_RES_CACHE,
+ .fflags = RFTYPE_CACHE,
},
.msr_base = MSR_IA32_L2_CBM_BASE,
.msr_update = cat_wrmsr,
@@ -97,7 +97,7 @@ struct rdt_hw_resource rdt_resources_all[] = {
.domains = domain_init(RDT_RESOURCE_MBA),
.parse_ctrlval = parse_bw,
.format_str = "%d=%*u",
- .fflags = RFTYPE_RES_MB,
+ .fflags = RFTYPE_MB,
},
},
[RDT_RESOURCE_SMBA] =
@@ -109,7 +109,7 @@ struct rdt_hw_resource rdt_resources_all[] = {
.domains = domain_init(RDT_RESOURCE_SMBA),
.parse_ctrlval = parse_bw,
.format_str = "%d=%*u",
- .fflags = RFTYPE_RES_MB,
+ .fflags = RFTYPE_MB,
},
},
};
@@ -240,18 +240,64 @@ struct rdtgroup {
/*
* Define the file type flags for base and info directories.
+ *
+ * RESCTRL filesystem has two main components
+ * a. info
+ * b. base.
+ *
+ * /sys/fs/resctrl/
+ * |
+ * --> info (Displays information about control and monitoring)
+ * |
+ * --> base (Displays the details on resctrl groups)
+ *
+ * -------------------------------------------------------------
+ * info directory structure
+ * --> INFO
+ * --> TOP
+ * last_cmd_status
+ *
+ * --> MON
+ * --> (L2_MON)
+ * --> (L3_MON)
+ * max_threshold_occupancy, mbm_local_bytes_config,
+ * mbm_total_bytes_config, mon_features, num_rmids
+ *
+ * --> RES
+ * --> CACHE (L2, L3)
+ * bit_usage, cbm_mask, min_cbm_bits, num_closids,
+ * shareable_bits
+ *
+ * --> MB (MB, SMBA)
+ * bandwidth_gran, delay_linear, min_bandwidth,
+ * num_closids
+ *
+ * group structure
+ * -----------------------------------------------------------
+ * --> BASE (Files common for both MON and CTRL groups)
+ * cpus, cpus_list, tasks
+ *
+ * --> CTRL (Files only for CTRL group)
+ * mode, schemata, size
+ *
*/
#define RFTYPE_INFO BIT(0)
#define RFTYPE_BASE BIT(1)
-#define RFTYPE_CTRL BIT(4)
-#define RFTYPE_MON BIT(5)
-#define RFTYPE_TOP BIT(6)
-#define RFTYPE_RES_CACHE BIT(8)
-#define RFTYPE_RES_MB BIT(9)
-#define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL)
-#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_TOP BIT(2)
+#define RFTYPE_MON BIT(3)
+#define RFTYPE_RES BIT(4)
+
+#define RFTYPE_CACHE BIT(5)
+#define RFTYPE_MB BIT(6)
+
+#define RFTYPE_CTRL BIT(8)
+
+#define RFTYPE_INFO_TOP (RFTYPE_INFO | RFTYPE_TOP)
+#define RFTYPE_INFO_MON (RFTYPE_INFO | RFTYPE_MON)
+#define RFTYPE_INFO_RES (RFTYPE_INFO | RFTYPE_RES)
+
+#define RFTYPE_BASE_CTRL (RFTYPE_BASE | RFTYPE_CTRL)
/* List of all resource groups */
extern struct list_head rdt_all_groups;
@@ -1691,77 +1691,77 @@ static struct rftype res_common_files[] = {
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_last_cmd_status_show,
- .fflags = RFTYPE_TOP_INFO,
+ .fflags = RFTYPE_INFO_TOP,
},
{
.name = "num_closids",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_num_closids_show,
- .fflags = RFTYPE_CTRL_INFO,
+ .fflags = RFTYPE_INFO_RES,
},
{
.name = "mon_features",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_mon_features_show,
- .fflags = RFTYPE_MON_INFO,
+ .fflags = RFTYPE_INFO_MON,
},
{
.name = "num_rmids",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_num_rmids_show,
- .fflags = RFTYPE_MON_INFO,
+ .fflags = RFTYPE_INFO_MON,
},
{
.name = "cbm_mask",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_default_ctrl_show,
- .fflags = RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE,
+ .fflags = RFTYPE_INFO_RES | RFTYPE_CACHE,
},
{
.name = "min_cbm_bits",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_min_cbm_bits_show,
- .fflags = RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE,
+ .fflags = RFTYPE_INFO_RES | RFTYPE_CACHE,
},
{
.name = "shareable_bits",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_shareable_bits_show,
- .fflags = RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE,
+ .fflags = RFTYPE_INFO_RES | RFTYPE_CACHE,
},
{
.name = "bit_usage",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_bit_usage_show,
- .fflags = RFTYPE_CTRL_INFO | RFTYPE_RES_CACHE,
+ .fflags = RFTYPE_INFO_RES | RFTYPE_CACHE,
},
{
.name = "min_bandwidth",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_min_bw_show,
- .fflags = RFTYPE_CTRL_INFO | RFTYPE_RES_MB,
+ .fflags = RFTYPE_INFO_RES | RFTYPE_MB,
},
{
.name = "bandwidth_gran",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_bw_gran_show,
- .fflags = RFTYPE_CTRL_INFO | RFTYPE_RES_MB,
+ .fflags = RFTYPE_INFO_RES | RFTYPE_MB,
},
{
.name = "delay_linear",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdt_delay_linear_show,
- .fflags = RFTYPE_CTRL_INFO | RFTYPE_RES_MB,
+ .fflags = RFTYPE_INFO_RES | RFTYPE_MB,
},
/*
* Platform specific which (if any) capabilities are provided by
@@ -1780,7 +1780,7 @@ static struct rftype res_common_files[] = {
.kf_ops = &rdtgroup_kf_single_ops,
.write = max_threshold_occ_write,
.seq_show = max_threshold_occ_show,
- .fflags = RFTYPE_MON_INFO | RFTYPE_RES_CACHE,
+ .fflags = RFTYPE_INFO_MON | RFTYPE_CACHE,
},
{
.name = "mbm_total_bytes_config",
@@ -1827,7 +1827,7 @@ static struct rftype res_common_files[] = {
.kf_ops = &rdtgroup_kf_single_ops,
.write = rdtgroup_schemata_write,
.seq_show = rdtgroup_schemata_show,
- .fflags = RFTYPE_CTRL_BASE,
+ .fflags = RFTYPE_BASE_CTRL,
},
{
.name = "mode",
@@ -1835,14 +1835,14 @@ static struct rftype res_common_files[] = {
.kf_ops = &rdtgroup_kf_single_ops,
.write = rdtgroup_mode_write,
.seq_show = rdtgroup_mode_show,
- .fflags = RFTYPE_CTRL_BASE,
+ .fflags = RFTYPE_BASE_CTRL,
},
{
.name = "size",
.mode = 0444,
.kf_ops = &rdtgroup_kf_single_ops,
.seq_show = rdtgroup_size_show,
- .fflags = RFTYPE_CTRL_BASE,
+ .fflags = RFTYPE_BASE_CTRL,
},
};
@@ -1899,7 +1899,7 @@ void __init thread_throttle_mode_init(void)
if (!rft)
return;
- rft->fflags = RFTYPE_CTRL_INFO | RFTYPE_RES_MB;
+ rft->fflags = RFTYPE_INFO_RES | RFTYPE_MB;
}
void __init mbm_config_rftype_init(const char *config)
@@ -1908,7 +1908,7 @@ void __init mbm_config_rftype_init(const char *config)
rft = rdtgroup_get_rftype_by_name(config);
if (rft)
- rft->fflags = RFTYPE_MON_INFO | RFTYPE_RES_CACHE;
+ rft->fflags = RFTYPE_INFO_MON | RFTYPE_CACHE;
}
/**
@@ -2043,21 +2043,21 @@ static int rdtgroup_create_info_dir(struct kernfs_node *parent_kn)
if (IS_ERR(kn_info))
return PTR_ERR(kn_info);
- ret = rdtgroup_add_files(kn_info, RFTYPE_TOP_INFO);
+ ret = rdtgroup_add_files(kn_info, RFTYPE_INFO_TOP);
if (ret)
goto out_destroy;
/* loop over enabled controls, these are all alloc_capable */
list_for_each_entry(s, &resctrl_schema_all, list) {
r = s->res;
- fflags = r->fflags | RFTYPE_CTRL_INFO;
+ fflags = r->fflags | RFTYPE_INFO_RES;
ret = rdtgroup_mkdir_info_resdir(s, s->name, fflags);
if (ret)
goto out_destroy;
}
for_each_mon_capable_rdt_resource(r) {
- fflags = r->fflags | RFTYPE_MON_INFO;
+ fflags = r->fflags | RFTYPE_INFO_MON;
sprintf(name, "%s_MON", r->name);
ret = rdtgroup_mkdir_info_resdir(r, name, fflags);
if (ret)
@@ -3218,7 +3218,7 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
if (rtype == RDTCTRL_GROUP)
fflags = RFTYPE_BASE | RFTYPE_CTRL;
else
- fflags = RFTYPE_BASE | RFTYPE_MON;
+ fflags = RFTYPE_BASE;
ret = rdtgroup_add_files(kn, fflags);
if (ret) {
@@ -3554,7 +3554,7 @@ static int __init rdtgroup_setup_root(void)
list_add(&rdtgroup_default.rdtgroup_list, &rdt_all_groups);
- ret = rdtgroup_add_files(kernfs_root_to_node(rdt_root), RFTYPE_CTRL_BASE);
+ ret = rdtgroup_add_files(kernfs_root_to_node(rdt_root), RFTYPE_BASE_CTRL);
if (ret) {
kernfs_destroy_root(rdt_root);
goto out;