x86/resctrl: Add io_alloc_min_cbm_all interface for CBM reset
Subsystems (3)
cover x86/resctrl: Add io_alloc_min_cbm_all interface for CBM reset
Hi Babu,
This patch is based on and intended for inclusion with the "[PATCH v11 00/10] x86,fs/resctrl: Support L3 Smart Data Cache Injection Allocation Enforcement (SDCIAE)" series [1].
This proposal introduces a new resctrl interface file, "io_alloc_min_cbm_all", to provide users with a clean, unified mechanism for resetting I/O allocation CBMs. Previously, resetting all relevant CBMs to their minimum (cleared) configuration required userspace to perform multiple sequential writes to "io_alloc_cbm". By writing a zero (0) value to "io_alloc_min_cbm_all", the user can now force all corresponding CBMs back to their minimum size in a single operation, greatly simplifying automation and management tasks.
Please let me know your thoughts.
[1]: https://lore.kernel.org/lkml/[email protected]/#b
Aaron Tomlin (2):
x86/resctrl: Add io_alloc_min_cbm_all interface for CBM reset fs/resctrl: resctrl: Return -EINVAL for a missing seq_show
implementation
Documentation/filesystems/resctrl.rst | 13 +++ arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 23 +++-- fs/resctrl/ctrlmondata.c | 117 ++++++++++++++++++---- fs/resctrl/internal.h | 3 + fs/resctrl/rdtgroup.c | 13 ++- include/linux/resctrl.h | 30 +++++- 7 files changed, 167 insertions(+), 34 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/2 x86/resctrl: Add io_alloc_min_cbm_all interface for CBM reset
This patch introduces the new resctrl interface file "io_alloc_min_cbm_all" to provide users with a clean mechanism to reset all I/O allocation CBMs (Cache-Block Masks) to their minimum configuration.
Writing '0' to this file triggers the logic to set each corresponding CBM to the minimum number of consecutive bits (effectively clearing them to 0 or their smallest supported mask). This simplifies the process of clearing or resetting the I/O allocation state without requiring manual CBM string calculations and eliminating the need for multiple writes to "io_alloc_cbm".
--- Documentation/filesystems/resctrl.rst | 13 +++ arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 23 +++-- fs/resctrl/ctrlmondata.c | 117 ++++++++++++++++++---- fs/resctrl/internal.h | 3 + fs/resctrl/rdtgroup.c | 10 +- include/linux/resctrl.h | 30 +++++- 7 files changed, 165 insertions(+), 33 deletions(-)
Documentation/filesystems/resctrl.rst +13 -0
@@ -213,6 +213,19 @@ related to allocation: written to /sys/fs/resctrl/info/L3DATA/io_alloc_cbm may be reflected by /sys/fs/resctrl/info/L3CODE/io_alloc_cbm and vice versa. +"io_alloc_min_cbm_all": + Set each CBM to their minimum number of consecutive bits. + + Example:: + + # cat /sys/fs/resctrl/info/L3/io_alloc_cbm + 0=ffff;1=00ff + + # echo 0 > /sys/fs/resctrl/info/L3/io_alloc_min_cbm_all + + # cat /sys/fs/resctrl/info/L3/io_alloc_cbm + 0=0;1=0 + Memory bandwidth(MB) subdirectory contains the following files with respect to allocation:
arch/x86/kernel/cpu/resctrl/core.c +1 -1
@@ -276,7 +276,7 @@ static void rdt_get_cdp_config(int level)static void rdt_set_io_alloc_capable (struct rdt_resource *r) { - r->cache.io_alloc_capable = true; + r->cache.io_alloc.io_alloc_capable = true; }static void rdt_get_cdp_l3_config (void )
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +14 -9
@@ -57,14 +57,19 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid) hw_dom =resctrl_to_arch_ctrl_dom (d); msr_param.res =NULL ;for (t =0 ; t <CDP_NUM_TYPES ; t++) { - cfg = &hw_dom->d_resctrl.staged_config[t]; -if (!cfg->have_new_ctrl) -continue ; - - idx =resctrl_get_config_index (closid, t); -if (cfg->new_ctrl == hw_dom->ctrl_val[idx]) -continue ; - hw_dom->ctrl_val[idx] = cfg->new_ctrl; +if (resctrl_should_io_alloc_min_cbm (r)) { + idx =resctrl_get_config_index (closid, t); + hw_dom->ctrl_val[idx] =apply_io_alloc_min_cbm (r); + }else { + cfg = &hw_dom->d_resctrl.staged_config[t]; +if (!cfg->have_new_ctrl) +continue ; + + idx =resctrl_get_config_index (closid, t); +if (cfg->new_ctrl == hw_dom->ctrl_val[idx]) +continue ; + hw_dom->ctrl_val[idx] = cfg->new_ctrl; + }if (!msr_param.res) { msr_param.low = idx;
@@ -123,7 +128,7 @@ int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable) {struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r); -if (hw_res->r_resctrl.cache.io_alloc_capable && +if (hw_res->r_resctrl.cache.io_alloc.io_alloc_capable && hw_res->sdciae_enabled != enable) {_resctrl_sdciae_enable (r, enable); hw_res->sdciae_enabled = enable;
fs/resctrl/ctrlmondata.c +96 -21
160 lines not on this page · raw message
fs/resctrl/internal.h +3 -0
@@ -442,6 +442,9 @@ int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, struct seq_file *seq, void *v);ssize_t resctrl_io_alloc_cbm_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off); +ssize_t resctrl_io_alloc_cbm_min_write (struct kernfs_open_file *of,char *buf, +size_t nbytes,loff_t off); +u32 resctrl_io_alloc_closid (struct rdt_resource *r);#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK
fs/resctrl/rdtgroup.c +9 -1
@@ -1995,6 +1995,12 @@ static struct rftype res_common_files[] = { .seq_show = resctrl_io_alloc_cbm_show, .write = resctrl_io_alloc_cbm_write, }, + { + .name = "io_alloc_min_cbm_all", + .mode = 0644, + .kf_ops = &rdtgroup_kf_single_ops, + .write = resctrl_io_alloc_cbm_min_write, + }, { .name = "max_threshold_occupancy", .mode = 0644,
@@ -2195,11 +2201,13 @@ static void io_alloc_init(void) {struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); -if (r->cache.io_alloc_capable) { +if (r->cache.io_alloc.io_alloc_capable) {resctrl_file_fflags_init ("io_alloc" ,RFTYPE_CTRL_INFO |RFTYPE_RES_CACHE );resctrl_file_fflags_init ("io_alloc_cbm" ,RFTYPE_CTRL_INFO |RFTYPE_RES_CACHE ); +resctrl_file_fflags_init ("io_alloc_min_cbm_all" , +RFTYPE_CTRL_INFO |RFTYPE_RES_CACHE ); } }
include/linux/resctrl.h +29 -1
@@ -215,7 +215,10 @@ struct resctrl_cache {unsigned int shareable_bits;bool arch_has_sparse_bitmasks;bool arch_has_per_cpu_cfg; -bool io_alloc_capable; +struct { +bool io_alloc_capable; +bool io_alloc_min_cbm; + } io_alloc; };/**
@@ -415,6 +418,31 @@ static inline bool resctrl_is_mbm_event(enum resctrl_event_id eventid) eventid <= QOS_L3_MBM_LOCAL_EVENT_ID); } +/* +* apply_io_alloc_min_cbm() - Apply minimum io_alloc CBM +* +* @r: resctrl resource +* +* Return: Minimum number of consecutive io_alloc CBM bits to be set. +*/ +static inline u32 apply_io_alloc_min_cbm (struct rdt_resource *r) +{ +return r->cache.min_cbm_bits; +} + +/* +* resctrl_should_io_alloc_min_cbm() - Should the minimum io_alloc +* CBM be applied +* @r: resctrl resource +* +* Return: True if the minimum number of consecutive +* bits to be set in the io_alloc CBM should be applied. +*/ +static inline bool resctrl_should_io_alloc_min_cbm (struct rdt_resource *r) +{ +return r->cache.io_alloc.io_alloc_min_cbm; +} +u32 resctrl_get_mon_evt_cfg (enum resctrl_event_id eventid);/* Iterate over all memory bandwidth events */
Signature · 1 line
2.51.0
PATCH 2/2 fs/resctrl: resctrl: Return -EINVAL for a missing seq_show implementation
In reply to Aaron TomlinThe rdtgroup_seqfile_show() function, which is the sequence file handler for reading data from resctrl files, previously returned 0 (success) if the file's associated rftype did not define a .seq_show implementation.
This behavior is incorrect and confusing, as a read operation that does not define a display function should be treated as an error.
This patch change the function to return -EINVAL if the file type handler (i.e., rft->seq_show) is NULL, providing proper feedback that the operation is invalid for that file.
--- fs/resctrl/rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/resctrl/rdtgroup.c +2 -1
@@ -314,7 +314,8 @@ static int rdtgroup_seqfile_show(struct seq_file *m, void *arg)if (rft->seq_show)return rft->seq_show (of, m, arg); -return 0 ; + +return -EINVAL ; } static ssize_t rdtgroup_file_write(struct kernfs_open_file *of, char *buf,
Signature · 1 line
2.51.0
Hi Aaron,
Thanks for trying the patches.
Quoted 9 lines · Aaron Tomlin
This patch introduces the new resctrl interface file "
io_alloc_min_cbm_all" to provide users with a clean mechanism to reset all I/O allocation CBMs (Cache-Block Masks) to their minimum configuration.Writing '0' to this file triggers the logic to set each corresponding CBM to the minimum number of consecutive bits (effectively clearing them to 0 or their smallest supported mask). This simplifies the process of clearing or resetting the I/O allocation state without requiring manual CBM string calculations and eliminating the need for multiple writes to "
io_alloc_cbm".
Your patch replaces the need for
[1] # echo "0=0;1=0" > /sys/fs/resctrl/info/L3/io_alloc_cbm
Instead it does
[2] # echo 0 > /sys/fs/resctrl/info/L3/io_alloc_min_cbm_all
Both approaches involve a single system call, with no multiple writes in either case.
I don’t see a strong justification for keeping both options. Option [1] is consistent with the existing interfaces and is also efficient, so I don’t see the need for an additional mechanism.
Quoted 354 lines
Signed-off-by Aaron Tomlin <[email protected]>--- Documentation/filesystems/resctrl.rst | 13 +++ arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 23 +++-- fs/resctrl/ctrlmondata.c | 117 ++++++++++++++++++---- fs/resctrl/internal.h | 3 + fs/resctrl/rdtgroup.c | 10 +- include/linux/resctrl.h | 30 +++++- 7 files changed, 165 insertions(+), 33 deletions(-)Documentation/filesystems/resctrl.rst +13
-0@@ -213,6 +213,19 @@ related to allocation: written to /sys/fs/resctrl/info/L3DATA/io_alloc_cbm may be reflected by /sys/fs/resctrl/info/L3CODE/io_alloc_cbm and vice versa. +"io_alloc_min_cbm_all": + Set each CBM to their minimum number of consecutive bits. + + Example:: + + # cat /sys/fs/resctrl/info/L3/io_alloc_cbm + 0=ffff;1=00ff + + # echo 0 > /sys/fs/resctrl/info/L3/io_alloc_min_cbm_all + + # cat /sys/fs/resctrl/info/L3/io_alloc_cbm + 0=0;1=0 + Memory bandwidth(MB) subdirectory contains the following files with respect to allocation:arch/x86/kernel/cpu/resctrl/core.c +1
-1@@ -276,7 +276,7 @@ static void rdt_get_cdp_config(int level)static void rdt_set_io_alloc_capable (struct rdt_resource *r) { - r->cache.io_alloc_capable = true; + r->cache.io_alloc.io_alloc_capable = true; }static void rdt_get_cdp_l3_config (void )arch/x86/kernel/cpu/resctrl/ctrlmondata.c +14
-9@@ -57,14 +57,19 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid) hw_dom =resctrl_to_arch_ctrl_dom (d); msr_param.res =NULL ;for (t =0 ; t <CDP_NUM_TYPES ; t++) { - cfg = &hw_dom->d_resctrl.staged_config[t]; -if (!cfg->have_new_ctrl) -continue ; - - idx =resctrl_get_config_index (closid, t); -if (cfg->new_ctrl == hw_dom->ctrl_val[idx]) -continue ; - hw_dom->ctrl_val[idx] = cfg->new_ctrl; +if (resctrl_should_io_alloc_min_cbm (r)) { + idx =resctrl_get_config_index (closid, t); + hw_dom->ctrl_val[idx] =apply_io_alloc_min_cbm (r); + }else { + cfg = &hw_dom->d_resctrl.staged_config[t]; +if (!cfg->have_new_ctrl) +continue ; + + idx =resctrl_get_config_index (closid, t); +if (cfg->new_ctrl == hw_dom->ctrl_val[idx]) +continue ; + hw_dom->ctrl_val[idx] = cfg->new_ctrl; + }if (!msr_param.res) { msr_param.low = idx;@@ -123,7 +128,7 @@ int resctrl_arch_io_alloc_enable(struct rdt_resource *r, bool enable) {struct rdt_hw_resource *hw_res =resctrl_to_arch_res (r); -if (hw_res->r_resctrl.cache.io_alloc_capable && +if (hw_res->r_resctrl.cache.io_alloc.io_alloc_capable && hw_res->sdciae_enabled != enable) {_resctrl_sdciae_enable (r, enable); hw_res->sdciae_enabled = enable;fs/resctrl/ctrlmondata.c +96
-21@@ -688,7 +688,7 @@ int resctrl_io_alloc_show(struct kernfs_open_file *of, struct seq_file *seq, voimutex_lock (&rdtgroup_mutex); -if (r->cache.io_alloc_capable) { +if (r->cache.io_alloc.io_alloc_capable) {if (resctrl_arch_get_io_alloc_enabled (r))seq_puts (seq,"enabled\n" );else @@ -758,6 +758,50 @@ u32 resctrl_io_alloc_closid(struct rdt_resource *r)return resctrl_arch_get_num_closid (r) -1 ; } +/* +* check_io_alloc_support() - Establish if io_alloc is supported +* +* @s: resctrl resource schema. +* +* This function must be called under the cpu hotplug lock +* and rdtgroup mutex +* +* Return: 0 on success, negative error code otherwise. +*/ +static int check_io_alloc_support (struct resctrl_schema *s) +{ +struct rdt_resource *r = s->res; + +if (!r->cache.io_alloc.io_alloc_capable) { +rdt_last_cmd_printf ("io_alloc is not supported on %s\n" , s->name); +return -ENODEV ; + } + +return 0 ; +} + +/* +* check_io_alloc_enabled() - Establish if io_alloc is enabled +* +* @s: resctrl resource schema +* +* This function must be called under the cpu hotplug lock +* and rdtgroup mutex +* +* Return: 0 on success, negative error code otherwise. +*/ +static int check_io_alloc_enabled (struct resctrl_schema *s) +{ +struct rdt_resource *r = s->res; + +if (!resctrl_arch_get_io_alloc_enabled (r)) { +rdt_last_cmd_printf ("io_alloc is not enabled on %s\n" , s->name); +return -EINVAL ; + } + +return 0 ; +} +ssize_t resctrl_io_alloc_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off) {@@ -777,11 +821,9 @@ ssize_t resctrl_io_alloc_write(struct kernfs_open_file *of, char *buf,rdt_last_cmd_clear (); -if (!r->cache.io_alloc_capable) { -rdt_last_cmd_printf ("io_alloc is not supported on %s\n" , s->name); - ret = -ENODEV ; + ret =check_io_alloc_support (s); +if (ret) goto out_unlock; - }/* If the feature is already up to date, no action is needed. */ if (resctrl_arch_get_io_alloc_enabled (r) == enable)@@ -828,6 +870,47 @@ ssize_t resctrl_io_alloc_write(struct kernfs_open_file *of, char *buf,return ret ?: nbytes; } +ssize_t resctrl_io_alloc_cbm_min_write (struct kernfs_open_file *of,char *buf, +size_t nbytes,loff_t off) +{ +struct resctrl_schema *s =rdt_kn_parent_priv (of->kn); +struct rdt_resource *r = s->res; +bool reset; +u32 io_alloc_closid; +int ret; + + ret =kstrtobool (buf, &reset); +if (ret) +return ret; +if (reset) +return -EINVAL ; + +cpus_read_lock (); +mutex_lock (&rdtgroup_mutex); + +rdt_last_cmd_clear (); + + ret =check_io_alloc_support (s); +if (ret) + goto out_unlock; + + ret =check_io_alloc_enabled (s); +if (ret) + goto out_unlock; + + r->cache.io_alloc.io_alloc_min_cbm = true; + + io_alloc_closid =resctrl_io_alloc_closid (r); + ret =resctrl_arch_update_domains (r, io_alloc_closid); + + r->cache.io_alloc.io_alloc_min_cbm = false; +out_unlock: +mutex_unlock (&rdtgroup_mutex); +cpus_read_unlock (); + +return ret ?: nbytes; +} +int resctrl_io_alloc_cbm_show (struct kernfs_open_file *of,struct seq_file *seq,void *v) {struct resctrl_schema *s =rdt_kn_parent_priv (of->kn);@@ -839,17 +922,13 @@ int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, struct seq_file *seq,rdt_last_cmd_clear (); -if (!r->cache.io_alloc_capable) { -rdt_last_cmd_printf ("io_alloc is not supported on %s\n" , s->name); - ret = -ENODEV ; + ret =check_io_alloc_support (s); +if (ret) goto out_unlock; - } -if (!resctrl_arch_get_io_alloc_enabled (r)) { -rdt_last_cmd_printf ("io_alloc is not enabled on %s\n" , s->name); - ret = -EINVAL ; + ret =check_io_alloc_enabled (s); +if (ret) goto out_unlock; - }/* * When CDP is enabled, the CBMs of the highest CLOSID of CDP_CODE and @@ -928,17 +1007,13 @@ ssize_t resctrl_io_alloc_cbm_write(struct kernfs_open_file *of, char *buf,mutex_lock (&rdtgroup_mutex);rdt_last_cmd_clear (); -if (!r->cache.io_alloc_capable) { -rdt_last_cmd_printf ("io_alloc is not supported on %s\n" , s->name); - ret = -ENODEV ; + ret =check_io_alloc_support (s); +if (ret) goto out_unlock; - } -if (!resctrl_arch_get_io_alloc_enabled (r)) { -rdt_last_cmd_printf ("io_alloc is not enabled on %s\n" , s->name); - ret = -EINVAL ; + ret =check_io_alloc_enabled (s); +if (ret) goto out_unlock; - } io_alloc_closid =resctrl_io_alloc_closid (r);fs/resctrl/internal.h +3
-0@@ -442,6 +442,9 @@ int resctrl_io_alloc_cbm_show(struct kernfs_open_file *of, struct seq_file *seq, void *v);ssize_t resctrl_io_alloc_cbm_write (struct kernfs_open_file *of,char *buf,size_t nbytes,loff_t off); +ssize_t resctrl_io_alloc_cbm_min_write (struct kernfs_open_file *of,char *buf, +size_t nbytes,loff_t off); +u32 resctrl_io_alloc_closid (struct rdt_resource *r);#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK fs/resctrl/rdtgroup.c +9
-1@@ -1995,6 +1995,12 @@ static struct rftype res_common_files[] = { .seq_show = resctrl_io_alloc_cbm_show, .write = resctrl_io_alloc_cbm_write, }, + { + .name = "io_alloc_min_cbm_all", + .mode = 0644, + .kf_ops = &rdtgroup_kf_single_ops, + .write = resctrl_io_alloc_cbm_min_write, + }, { .name = "max_threshold_occupancy", .mode = 0644,@@ -2195,11 +2201,13 @@ static void io_alloc_init(void) {struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); -if (r->cache.io_alloc_capable) { +if (r->cache.io_alloc.io_alloc_capable) {resctrl_file_fflags_init ("io_alloc" ,RFTYPE_CTRL_INFO |RFTYPE_RES_CACHE );resctrl_file_fflags_init ("io_alloc_cbm" ,RFTYPE_CTRL_INFO |RFTYPE_RES_CACHE ); +resctrl_file_fflags_init ("io_alloc_min_cbm_all" , +RFTYPE_CTRL_INFO |RFTYPE_RES_CACHE ); } }include/linux/resctrl.h +29
-1@@ -215,7 +215,10 @@ struct resctrl_cache {unsigned int shareable_bits;bool arch_has_sparse_bitmasks;bool arch_has_per_cpu_cfg; -bool io_alloc_capable; +struct { +bool io_alloc_capable; +bool io_alloc_min_cbm; + } io_alloc; };/** @@ -415,6 +418,31 @@ static inline bool resctrl_is_mbm_event(enum resctrl_event_id eventid) eventid <= QOS_L3_MBM_LOCAL_EVENT_ID); } +/* +* apply_io_alloc_min_cbm() - Apply minimum io_alloc CBM +* +* @r: resctrl resource +* +* Return: Minimum number of consecutive io_alloc CBM bits to be set. +*/ +static inline u32 apply_io_alloc_min_cbm (struct rdt_resource *r) +{ +return r->cache.min_cbm_bits; +} + +/* +* resctrl_should_io_alloc_min_cbm() - Should the minimum io_alloc +* CBM be applied +* @r: resctrl resource +* +* Return: True if the minimum number of consecutive +* bits to be set in the io_alloc CBM should be applied. +*/ +static inline bool resctrl_should_io_alloc_min_cbm (struct rdt_resource *r) +{ +return r->cache.io_alloc.io_alloc_min_cbm; +} +u32 resctrl_get_mon_evt_cfg (enum resctrl_event_id eventid);/* Iterate over all memory bandwidth events */
Quoted 3 lines · Babu
Hi Aaron,
Thanks for trying the patches.
Hi Babu,
Thank you very much for taking the time to review the patch and for pointing out the efficiency of the existing interface. You are correct that option [1], echo "0=0;1=0" > io_alloc_cbm, is also accomplished with a single system call.
However, the primary justification for introducing "io_alloc_min_cbm_all" lies in abstraction and the knowledge burden placed upon the user, not the system call count.
To successfully execute option [1], the user is required to have advanced knowledge of the system's current cache topology and capabilities:
Domain ID Knowledge: The user must know every active Domain ID (e.g.,
0, 1, 2, etc.) that supports the resource and manually enumerate them in the write string. If a domain is missed, it will not be reset.
Minimal CBM Knowledge: The user must know the minimal supported number
of consecutive bits that constitute a "cleared" state for each domain. While this is often 0, relying on this is not architecture-aware.
The new interface, is designed to abstract this complexity entirely. Also, applies the hardware's guaranteed minimum supported CBM (based on r->cache.min_cbm_bits) to each domain automatically.
This unified approach provides a robust and efficient mechanism to guarantee a full, architecture-aware reset across all domains, eliminating the need for userspace to parse the topology and construct a complex, domain-specific input string.
Please let me know if this clarifies the motivation.
Kind regards,
Signature · 1 line
Aaron Tomlin
Quoted 33 lines · Aaron Tomlin
Quoted 3 lines · Babu
Hi Aaron,
Thanks for trying the patches.
Hi Babu,
Thank you very much for taking the time to review the patch and for pointing out the efficiency of the existing interface. You are correct that option [1], echo "0=0;1=0" >
io_alloc_cbm, is also accomplished with a single system call.However, the primary justification for introducing "
io_alloc_min_cbm_all" lies in abstraction and the knowledge burden placed upon the user, not the system call count.To successfully execute option [1], the user is required to have advanced knowledge of the system's current cache topology and capabilities:
Domain ID Knowledge: The user must know every active Domain ID (e.g.,
0, 1, 2, etc.) that supports the resource and manually enumerate them in the write string. If a domain is missed, it will not be reset.Minimal CBM Knowledge: The user must know the minimal supported number
of consecutive bits that constitute a "cleared" state for each domain. While this is often 0, relying on this is not architecture-aware.The new interface, is designed to abstract this complexity entirely. Also, applies the hardware's guaranteed minimum supported CBM (based on
r->cache.min_cbm_bits) to each domain automatically.
Quoted 7 lines
This unified approach provides a robust and efficient mechanism to guarantee a full, architecture-aware reset across all domains, eliminating the need for userspace to parse the topology and construct a complex, domain-specific input string.
Please let me know if this clarifies the motivation.
No, I don’t agree with introducing this new interface.
These settings are intended to be modified only by system administrators, not general users.
Administrators are already expected to have complete knowledge of the hardware and corresponding configuration details. They also typically rely on benchmark data to determine appropriate settings.
Additionally, this approach is not consistent with our existing CBM setting model.
Thanks
Babu
Quoted 11 lines · Babu
No, I don’t agree with introducing this new interface.
These settings are intended to be modified only by system administrators, not general users.
Administrators are already expected to have complete knowledge of the hardware and corresponding configuration details. They also typically rely on benchmark data to determine appropriate settings.
Additionally, this approach is not consistent with our existing CBM setting model.
Hi Babu,
I fully appreciate your point that system administrators are expected to have complete knowledge of the hardware configuration. I believe my initial motivation may have been unclear, so let me clarify the intention behind "io_alloc_min_cbm_all".
The intention of this new interface is not to hide lower-level details from the administrator, but rather to simplify a specific, high-overhead administration task and prevent human error, which I encountered during testing of your series.
By default, it is my understanding that when I/O allocation CBM is enabled, all applicable shared L3 resources typically have their CBM bits set (e.g., ffff). If an administrator wishes to revert to a clean baseline before applying a subset of dedicated bits, the manual process requires them to not only have knowledge of every single Domain ID
applicable to the shared L3 resource but manually construct a long, error-prone input string.
The objective of "io_alloc_min_cbm_all" is to provide a quick and accurate medium to revert this topology-dependent default configuration to the minimal supported state, thereby avoiding possible miscalculation or omission of a Domain ID in the CBM string. As shown in the usage flow below, the new interface drastically reduces the complexity of setting up a specific configuration:
# cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=ffff;2=ffff;4=ffff;6=ffff;8=ffff;10=ffff;12=ffff;14=ffff;16=ffff;18=ffff;20=ffff;22=ffff;24=ffff;26=ffff;28=ffff;30=ffff;32=ffff;34=ffff;36=ffff;38=ffff;40=ffff;42=ffff;44=ffff;46=ffff;48=ffff;50=ffff;52=ffff
# echo 0=0;2=0;4=0;6=4;8=4;10=0;12=0;14=0;16=ffff;18=ffff;20=0;22=0;24=0;26=0;28=0;30=0;32=0;34=4;36=0;38=0;40=0;42=0;44=0;46=0;48=0;50=0;52=0 > /sys/fs/resctrl/info/L3/io_alloc_cbm
# After (using the new interface):
# Administrator uses the new interface to clear all domains automatically:
echo 0 > /sys/fs/resctrl/info/L3/io_alloc_min_cbm_all
# Then applies only the specific, custom masks needed:
echo 6=4;8=4;16=ffff;18=ffff;34=4 > /sys/fs/resctrl/info/L3/io_alloc_cbm
In essence, the new file automates the clearing phase across the entire topology, allowing the administrator to immediately proceed to the customization phase with a much shorter, focused command.
I believe the efficiency and guaranteed correctness for this specific use case justifies the addition. Please let me know if this clarifies the motivation and if you have an alternative suggestion for achieving this guaranteed full-topology reset.
If, after considering this clarification, you still feel this approach should not be merged, I will certainly defer to your judgment and withdraw the patch.
Kind regards,
Signature · 1 line
Aaron Tomlin
Luck, Tony
maintainerQuoted 4 lines
The intention of this new interface is not to hide lower-level details from the administrator, but rather to simplify a specific, high-overhead administration task and prevent human error, which I encountered during testing of your series.
If you do this often, make a bash script or function to do:
sed -i -e 's/\([0-9][0-9]*\)=\([0-9a-f][0-9a-f]*\)/\1=0/g' /sys/fs/resctrl/info/L3/io_alloc_cbm
[That regex would probably be more readable using extended syntax]
-Tony
Hi Aaron,
Quoted 41 lines · Aaron Tomlin
Quoted 11 lines · Babu
No, I don’t agree with introducing this new interface.
These settings are intended to be modified only by system administrators, not general users.
Administrators are already expected to have complete knowledge of the hardware and corresponding configuration details. They also typically rely on benchmark data to determine appropriate settings.
Additionally, this approach is not consistent with our existing CBM setting model.
Hi Babu,
I fully appreciate your point that system administrators are expected to have complete knowledge of the hardware configuration. I believe my initial motivation may have been unclear, so let me clarify the intention behind "
io_alloc_min_cbm_all".The intention of this new interface is not to hide lower-level details from the administrator, but rather to simplify a specific, high-overhead administration task and prevent human error, which I encountered during testing of your series.
By default, it is my understanding that when I/O allocation CBM is enabled, all applicable shared L3 resources typically have their CBM bits set (e.g., ffff). If an administrator wishes to revert to a clean baseline before applying a subset of dedicated bits, the manual process requires them to not only have knowledge of every single Domain ID
applicable to the shared L3 resource but manually construct a long, error-prone input string.The objective of "
io_alloc_min_cbm_all" is to provide a quick and accurate medium to revert this topology-dependent default configuration to the minimal supported state, thereby avoiding possible miscalculation or omission of a Domain ID in the CBM string. As shown in the usage flow below, the new interface drastically reduces the complexity of setting up a specific configuration:
Quoted 4 lines
# cat /sys/fs/resctrl/info/L3/io_alloc_cbm 0=ffff;2=ffff;4=ffff;6=ffff;8=ffff;10=ffff;12=ffff;14=ffff;16=ffff;18=ffff;20=ffff;22=ffff;24=ffff;26=ffff;28=ffff;30=ffff;32=ffff;34=ffff;36=ffff;38=ffff;40=ffff;42=ffff;44=ffff;46=ffff;48=ffff;50=ffff;52=ffff# echo 0=0;2=0;4=0;6=4;8=4;10=0;12=0;14=0;16=ffff;18=ffff;20=0;22=0;24=0;26=0;28=0;30=0;32=0;34=4;36=0;38=0;40=0;42=0;44=0;46=0;48=0;50=0;52=0 > /sys/fs/resctrl/info/L3/io_alloc_cbm
Does the following option work for you?
# echo "*=0" > /sys/fs/resctrl/info/L3/io_alloc_cbm
Here,|*| represents all domains.
This functionality was introduced when adding support for the*"mbm_event" assign mode* (see [1]).
[1]https://lore.kernel.org/lkml/b894ad853e6757d40da1469bf9fca4c64684df65.1757108044.git.babu.moger@amd.com/ <https://lore.kernel.org/lkml/b894ad853e6757d40da1469bf9fca4c64684df65.1757108044.git.babu.moger@amd.com/> <https://lore.kernel.org/lkml/b894ad853e6757d40da1469bf9fca4c64684df65.1757108044.git.babu.moger@amd.com/>
Also, this needs to be done for all the settings like L3, MBA also SMBA.
# echo "L3:*=f" > /sys/fs/resctrl/schemata
# echo "MB:*=128" > /sys/fs/resctrl/schemata
I’d like to hear from Reinette and Tony if this seems like an acceptable approach.
Thanks
Babu
Luck, Tony
maintainerQuoted 12 lines
Does the following option work for you?
# echo "*=0" > /sys/fs/resctrl/info/L3/io_alloc_cbmHere,|*| represents all domains.
This functionality was introduced when adding support for the*"mbm_event" assign mode* (see [1]).
[1]https://lore.kernel.org/lkml/b894ad853e6757d40da1469bf9fca4c64684df65.1757108044.git.babu.moger@amd.com/ <https://lore.kernel.org/lkml/b894ad853e6757d40da1469bf9fca4c64684df65.1757108044.git.babu.moger@amd.com/> <https://lore.kernel.org/lkml/b894ad853e6757d40da1469bf9fca4c64684df65.1757108044.git.babu.moger@amd.com/>
Also, this needs to be done for all the settings like L3, MBA also SMBA.
Quoted 8 lines
# echo "L3:*=f" > /sys/fs/resctrl/schemata# echo "MB:*=128" > /sys/fs/resctrl/schemataI’d like to hear from Reinette and Tony if this seems like an acceptable approach.
Thanks
Babu,
It does look like a logical extension of the mbm_event assignment syntax.
But might be awkward to use if the system has asymmetric domains. We don't currently. But if we wanted to support L2 cache allocation on hybrid platforms with a mix of P-core and E-core, those have historically supported different bit masks because the L2 caches may allow 12 bits for one core type and 16 for another. On such a platform:
# echo "L2:*=fff" > schemata
would work,. But
# echo "L2:*=ffff" > schemata
would try to set unimplemented bits on some cores and would fail.
-Tony
Hi Tony,
Quoted 30 lines · Tony
Quoted 12 lines
Does the following option work for you?
# echo "*=0" > /sys/fs/resctrl/info/L3/io_alloc_cbmHere,|*| represents all domains.
This functionality was introduced when adding support for the*"mbm_event" assign mode* (see [1]).
[1]https://lore.kernel.org/lkml/b894ad853e6757d40da1469bf9fca4c64684df65.1757108044.git.babu.moger@amd.com/ <https://lore.kernel.org/lkml/b894ad853e6757d40da1469bf9fca4c64684df65.1757108044.git.babu.moger@amd.com/> <https://lore.kernel.org/lkml/b894ad853e6757d40da1469bf9fca4c64684df65.1757108044.git.babu.moger@amd.com/>
Also, this needs to be done for all the settings like L3, MBA also SMBA.Quoted 8 lines
# echo "L3:*=f" > /sys/fs/resctrl/schemata# echo "MB:*=128" > /sys/fs/resctrl/schemataI’d like to hear from Reinette and Tony if this seems like an acceptable approach.
Thanks
Babu,
It does look like a logical extension of the
mbm_eventassignment syntax.But might be awkward to use if the system has asymmetric domains. We don't currently. But if we wanted to support L2 cache allocation on hybrid platforms with a mix of P-core and E-core, those have historically supported different bit masks because the L2 caches may allow 12 bits for one core type and 16 for another. On such a platform:
Quoted 7 lines
# echo "L2:*=fff" > schematawould work,. But
# echo "L2:*=ffff" > schematawould try to set unimplemented bits on some cores and would fail.
I would consider this a user error, as the user is expected to know the supported value for the domain. This situation can occur even now — we simply report the error and exit.
Thanks
Babu
Luck, Tony
maintainerQuoted 4 lines
Quoted 4 lines
# echo "L2:*=fff" > schematawould work,. But
Quoted 8 lines
Quoted 3 lines
# echo "L2:*=ffff" > schematawould try to set unimplemented bits on some cores and would fail.
I would consider this a user error, as the user is expected to know the supported value for the domain.
This situation can occur even now — we simply report the error and exit.
Babu
Maybe it was a poor explanation on my part.
On a hybrid P-core/E-core system with different L2 cache topology schemata may look like this (8 L2 domains of one type, 4 L2 domains of other type.
$ cat schemata L2:0=ffff;1=ffff;2=ffff;3=ffff;4=ffff;5=ffff;6=ffff;7=ffff;8=7f;9=7f;10=7f;11=7f
The proposed wildcard syntax is only useful to set all domains to a value that is legal for all domains. It cannot be used for the "reset back to defaults" case because different domains have different defaults.
-Tony
Reinette Chatre
maintainerHi Tony,
Quoted 20 lines · Tony
Quoted 4 lines
Quoted 4 lines
# echo "L2:*=fff" > schematawould work,. But
Quoted 8 lines
Quoted 3 lines
# echo "L2:*=ffff" > schematawould try to set unimplemented bits on some cores and would fail.
I would consider this a user error, as the user is expected to know the supported value for the domain.
This situation can occur even now — we simply report the error and exit.Babu
Maybe it was a poor explanation on my part.
On a hybrid P-core/E-core system with different L2 cache topology schemata may look like this (8 L2 domains of one type, 4 L2 domains of other type.
Quoted 6 lines
$ cat schemata L2:0=ffff;1=ffff;2=ffff;3=ffff;4=ffff;5=ffff;6=ffff;7=ffff;8=7f;9=7f;10=7f;11=7fThe proposed wildcard syntax is only useful to set all domains to a value that is legal for all domains. It cannot be used for the "reset back to defaults" case because different domains have different defaults.
Disabling and re-enabling of io_alloc may be substitute for "reset back to defaults".
The '*' syntax would be useful to initialize domains to minimal allocations ... assuming all cache instances support the same minimum.
Would it be an issue if user attempts to assign a value that is not supported to all domains? resctrl could fail on first invalid bitmask and the last_cmd_status can then be expected to indicate the details of error.
Reinette
Quoted 6 lines · Babu Moger
Does the following option work for you?
# echo "*=0" > /sys/fs/resctrl/info/L3/io_alloc_cbmHere,|*| represents all domains.
Hi Babu,
Thank you for your response.
Unfortunately, this approach will not work.
If I understand correctly, the assumption that echo 0 (which translates to a CBM of all zeros) would always be accepted as a "minimum" value is incorrect since r->cache.min_cbm_bits could be greater than zero (e.g., under Intel hardware). See rdt_init_res_defs_intel().
The goal is not just to "clear" the CBM, but to reset it to the smallest valid mask.
Kind regards,
Signature · 1 line
Aaron Tomlin
Luck, Tony
maintainerQuoted 2 lines
The goal is not just to "clear" the CBM, but to reset it to the smallest valid mask.
"smallest valid mask" seems like a fuzzy concept.
Intel had one CPU that required 2 bits to be set in an L3 mask. Subsequent CPUs only requires 1 bit.
AMD allows setting zero bits.
So for AMD "smallest valid mask" is zero. Very simple there.
But on Intel you must have either one or two bits set (but it doesn't matter which bits).
In some cases you might want to pick a bit that overlaps with the space shared in the cache for non-CPU devices (typically top two valid bits of the mask, but should check CPUID leaf 0x10 for the exact bits).
Or you might want a bit that does NOT overlap with those non-CPU allocations.
-Tony
Reinette Chatre
maintainerQuoted 8 lines · Tony
Quoted 2 lines
The goal is not just to "clear" the CBM, but to reset it to the smallest valid mask.
"smallest valid mask" seems like a fuzzy concept.
Intel had one CPU that required 2 bits to be set in an L3 mask. Subsequent CPUs only requires 1 bit.
Quoted 6 lines
AMD allows setting zero bits.
So for AMD "smallest valid mask" is zero. Very simple there.
But on Intel you must have either one or two bits set (but it doesn't matter which bits).
Right, and this is exposed to user space via, for example for L3, /sys/fs/resctrl/info/L3/min_cbm_bits.
Quoted 6 lines
In some cases you might want to pick a bit that overlaps with the space shared in the cache for non-CPU devices (typically top two valid bits of the mask, but should check CPUID leaf
0x10for the exact bits).
... and this is exposed to user space via /sys/fs/resctrl/info/L3/shareable_bits and for this new feature the domain specific values can be seen from io_alloc_cbm.
Quoted 4 lines
Or you might want a bit that does NOT overlap with those non-CPU allocations.
Seems like user space has needed information to perform a sane reset?
Reinette
Luck, Tony
maintainerQuoted 1 line
Seems like user space has needed information to perform a sane reset?
Like this:
1) Read info files to figure out what minimum mask is needed for this system
2) Use Babu's suggested syntax of
# echo "L3:*={min_mask_from_step_1}" > schemataRather than Aaron's
# echo "L3:*=0" > schemata
I'm OK with this for L3, but still see it being less useful for L2 with asymmetric domains.
It can meet the "set a minimum value across all domains" need.
But can fail setting a value that isn't supported by some of the domains.
-Tony
Reinette Chatre
maintainerHi Tony,
Quoted 7 lines · Tony
Quoted 1 line
Seems like user space has needed information to perform a sane reset?
Like this:
1) Read info files to figure out what minimum mask is needed for this system
2) Use Babu's suggested syntax of# echo "L3:*={min_mask_from_step_1}" > schemata
Exactly, but without the "L3:" and with s/schemata/io_alloc_cbm/. Specifically,
# echo "*={min_mask_from_step_1}" > /sys/fs/resctrl/info/L3/io_alloc_cbmI do not believe this feature is being considered for the schemata file (at this time?), just for io_alloc_cbm.
Quoted 6 lines
Rather than Aaron's
# echo "L3:*=0" > schemataI'm OK with this for L3, but still see it being less useful for L2 with asymmetric domains.
That would first require that these L2 with asymmetric domains be made available as resource for IO allocation. At this time the feature is limited to L3 but when/if it expands to L2 an interface like this could remain sane by allowing values that overlap all domains to be set on all domains with one user space call and a clear failure presented to user via last_cmd_status on first failure if it is not possible.
Quoted 2 lines
It can meet the "set a minimum value across all domains" need.
ack.
Quoted 3 lines
But can fail setting a value that isn't supported by some of the domains.
ack.
Reinette
Quoted 11 lines · Tony
Quoted 1 line
Seems like user space has needed information to perform a sane reset?
Like this:
1) Read info files to figure out what minimum mask is needed for this system
2) Use Babu's suggested syntax of# echo "L3:*={min_mask_from_step_1}" > schemataRather than Aaron's
# echo "L3:*=0" > schemata
Hi Tony,
I am satisfied with either approach.
However, to clarify, the primary function of the "io_alloc_min_cbm_all" interface is to efficiently set the lowest architecturally valid CBM across all shared L3 domains. This operation relies entirely on r->cache.min_cbm_bits. Since this value is guaranteed by the hardware to be valid, this approach is robust and will not return an error (e.g., -EINVAL) to userspace.
Kind regards,
Signature · 1 line
Aaron Tomlin
Hi Everyone,
Quoted 13 lines · Aaron Tomlin
Quoted 10 lines · Tony
Quoted 1 line
Seems like user space has needed information to perform a sane reset?
Like this:
1) Read info files to figure out what minimum mask is needed for this system
2) Use Babu's suggested syntax of# echo "L3:*={min_mask_from_step_1}" > schemataRather than Aaron's
# echo "L3:*=0" > schemataHi Tony,
Quoted 10 lines
I am satisfied with either approach.
However, to clarify, the primary function of the "
io_alloc_min_cbm_all" interface is to efficiently set the lowest architecturally valid CBM across all shared L3 domains. This operation relies entirely onr->cache.min_cbm_bits. Since this value is guaranteed by the hardware to be valid, this approach is robust and will not return an error (e.g.,-EINVAL) to userspace.
Here’s my understanding of the discussion from this thread:
We plan to support the following operation:
#echo "*=value" > /sys/fs/resctrl/info/L3/io_alloc_cbm
Its users responsibility to make sure the value is valid based on
/sys/fs/resctrl/info/L3/min_cbm_bits and /sys/fs/resctrl/info/L3/cbm_mask.
There’s no need for an additional interface like
|/sys/fs/resctrl/info/L3/io_alloc_min_cbm_all|.
Did I miss anything?
Thanks
Babu
Hi Reinette,
Quoted 28 lines · Babu Moger
Hi Everyone,
Quoted 15 lines · Aaron Tomlin
Quoted 10 lines · Tony
Quoted 1 line
Seems like user space has needed information to perform a sane reset?
Like this:
1) Read info files to figure out what minimum mask is needed for this system 2) Use Babu's suggested syntax of
# echo "L3:*={min_mask_from_step_1}" > schemataRather than Aaron's
# echo "L3:*=0" > schemataHi Tony,
I am satisfied with either approach.
Quoted 9 lines
However, to clarify, the primary function of the "
io_alloc_min_cbm_all" interface is to efficiently set the lowest architecturally valid CBM across all shared L3 domains. This operation relies entirely onr->cache.min_cbm_bits. Since this value is guaranteed by the hardware to be valid, this approach is robust and will not return an error (e.g.,-EINVAL)
to userspace.
Quoted 7 lines
Here’s my understanding of the discussion from this thread:
We plan to support the following operation:
#echo "*=value" >
/sys/fs/resctrl/info/L3/io_alloc_cbm
Looks like we are going with the above approach where "*" represents all the domain.
Couple of things to consider.
a. Send a separate patch to add this feature after [1] is merged.
b. Add this change as part of [1] series in patch 9. The series is mostly ready for merge. I can add the changes. Only concern is, it will might delay the series merge little bit. My expectation is to have this series ready for next merge window.
[1] https://lore.kernel.org/lkml/[email protected]/
Any thoughts?
Thanks
Babu
Quoted 19 lines · Babu Moger
Quoted 7 lines
Here’s my understanding of the discussion from this thread:
We plan to support the following operation:
#echo "*=value" >
/sys/fs/resctrl/info/L3/io_alloc_cbmLooks like we are going with the above approach where "*" represents all the domain.
Couple of things to consider.
a. Send a separate patch to add this feature after [1] is merged.
b. Add this change as part of [1] series in patch 9. The series is mostly ready for merge. I can add the changes. Only concern is, it will might delay the series merge little bit. My expectation is to have this series ready for next merge window.
Quoted 6 lines
[1] https://lore.kernel.org/lkml/[email protected]/
Any thoughts?
Thanks
Hi Babu, Tony, Reinette,
I believe the most prudent course of action would be to hold off on this particular change until the main series has been merged.
As I was the one who specifically requested this supporting functionality, I would be happy to prepare and submit the follow-up patch for this detail myself.
Kind regards,
Signature · 1 line
Aaron Tomlin
Hi Aaron,
Quoted 27 lines · Aaron Tomlin
Quoted 19 lines · Babu Moger
Quoted 7 lines
Here’s my understanding of the discussion from this thread:
We plan to support the following operation:
#echo "*=value" >
/sys/fs/resctrl/info/L3/io_alloc_cbmLooks like we are going with the above approach where "*" represents all the domain.
Couple of things to consider.
a. Send a separate patch to add this feature after [1] is merged.
b. Add this change as part of [1] series in patch 9. The series is mostly ready for merge. I can add the changes. Only concern is, it will might delay the series merge little bit. My expectation is to have this series ready for next merge window.
Quoted 6 lines
[1] https://lore.kernel.org/lkml/[email protected]/
Any thoughts?
Thanks
Quoted 8 lines
Hi Babu, Tony, Reinette,
I believe the most prudent course of action would be to hold off on this particular change until the main series has been merged.
As I was the one who specifically requested this supporting functionality, I would be happy to prepare and submit the follow-up patch for this detail myself.
Sounds good. I will go ahead with the current series. You can send the patch(s) after series is merged.
Thanks
Babu