x86/resctrl: mba_MBps enhancement
Subsystems (3)
Tony Luck
maintainerv10 cover x86/resctrl: mba_MBps enhancement
Background
----------
The resctrl filesystem supports a mount option that allows users to specify a memory bandwidth limit in MiB/s for each domain of a CTRL_MON group. The underlying implementation uses data collected from the local memory bandwidth monitoring event for the CTRL_MON group and all of its MON subgroups as input to a feedback loop that adjusts the memory bandwidth allocation control percentage up or down to keep the group within the limit set by the user.
Problem statement
-----------------
Hard coding the local memory bandwidth monitoring event has the following issues:
1) Some systems may support total memory bandwidth monitoring but not local. The user cannot use this mount option on such systems.
2) For large workloads that span NUMA domains using local bandwidth monitoring will not throttle jobs correctly.
3) Users may have a mix of large and small workloads and may want to use different input events per CTRL_MON group.
Solution
--------
A) Provide a new user interface to choose which event is used for each CTRL_MON group.
B) Allow systems that only support total memory bandwidth monitoring to use total bandwidth event.
Changes since v9
Globally s/ctrl_mon/CTRL_MON/ in commit comments.
Patch Change
1 * Moved "Reviewed-by:" tag after Signed-off-by tags
* Added comment that I dropped the __init attribute that was in Babu's original patch
2 * More detail in commit comment
* Added block comment above definition of mba_mbps_default_event global variable
* Fixed bug reported by Reinette that changes to event used for default group persist across unmount/mount. Did this by moving initialization from rdtgroup_setup_default to set_mba_sc() to catch both mount and unmount.
3 * Write commit commemt with problem & fix sections
* Add note to commit comment that check for is_mbm_local_enabled() is deleted by this patch.
* Delete redundant check of is_mbm_local_enabled()
4 * Write commit commemt with problem & fix sections
* Reword legacy comment to avoid "we".
5 * Merged old patch 9 into this patch
* Write commit commemt with problem & fix sections
6 * Remove "historical" paragraph from commit comment
* Add note that "mba_MBps_event" file is only visible when the "mba_MBps" mount option is in use.
7 * Remove "historical" paragraph from commit comment
8 * No change
Babu Moger (1):
x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags
Tony Luck (7):
x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control x86/resctrl: Modify update_mba_bw() to use per CTRL_MON group event x86/resctrl: Compute memory bandwidth for all supported events x86/resctrl: Make mba_sc use total bandwidth if local is not supported x86/resctrl: Add "mba_MBps_event" file to CTRL_MON directories x86/resctrl: Add write option to "mba_MBps_event" file x86/resctrl: Document the new "mba_MBps_event" file
Documentation/arch/x86/resctrl.rst | 10 +++ include/linux/resctrl.h | 2 + arch/x86/kernel/cpu/resctrl/internal.h | 9 ++- arch/x86/kernel/cpu/resctrl/core.c | 9 ++- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 70 +++++++++++++++++ arch/x86/kernel/cpu/resctrl/monitor.c | 94 +++++++++++------------ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 45 +++++++---- 7 files changed, 173 insertions(+), 66 deletions(-)
base-commit: adc218676eef25575469234709c2d87185ca223a
Signature · 1 line
2.47.0
Tony Luck
maintainerPATCH v10 1/8 x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags
From: Babu Moger <[email protected]>
thread_throttle_mode_init() and mbm_config_rftype_init() both initialize fflags for resctrl files.
Adding new files will involve adding another function to initialize the fflags. This can be simplified by adding a new function resctrl_file_fflags_init() and passing the file name and flags to be initialized.
Consolidate fflags initialization into resctrl_file_fflags_init() and remove thread_throttle_mode_init() and mbm_config_rftype_init().
[Tony: Drop __init attribute so resctrl_file_fflags_init() can be used at run time]
--- arch/x86/kernel/cpu/resctrl/internal.h | 3 +-- arch/x86/kernel/cpu/resctrl/core.c | 4 +++- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 ++------------- 4 files changed, 10 insertions(+), 18 deletions(-)
arch/x86/kernel/cpu/resctrl/internal.h +1 -2
@@ -647,8 +647,7 @@ void cqm_handle_limbo(struct work_struct *work);bool has_busy_rmid (struct rdt_mon_domain *d);void __check_limbo (struct rdt_mon_domain *d,bool force_free);void rdt_domain_reconfigure_cdp (struct rdt_resource *r); -void __init thread_throttle_mode_init (void ); -void __init mbm_config_rftype_init (const char *config); +void resctrl_file_fflags_init (const char *config,unsigned long fflags);void rdt_staged_configs_clear (void );bool closid_allocated (unsigned int closid);int resctrl_find_cleanest_closid (void );
arch/x86/kernel/cpu/resctrl/core.c +3 -1
@@ -234,7 +234,9 @@ static __init bool __get_mem_config_intel(struct rdt_resource *r) r->membw.throttle_mode =THREAD_THROTTLE_PER_THREAD ; else r->membw.throttle_mode = THREAD_THROTTLE_MAX; -thread_throttle_mode_init (); + +resctrl_file_fflags_init ("thread_throttle_mode" , +RFTYPE_CTRL_INFO |RFTYPE_RES_MB ); r->alloc_capable = true;
arch/x86/kernel/cpu/resctrl/monitor.c +4 -2
@@ -1223,11 +1223,13 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)if (rdt_cpu_has (X86_FEATURE_CQM_MBM_TOTAL )) { mbm_total_event.configurable = true; -mbm_config_rftype_init ("mbm_total_bytes_config" ); +resctrl_file_fflags_init ("mbm_total_bytes_config" , +RFTYPE_MON_INFO |RFTYPE_RES_CACHE ); }if (rdt_cpu_has (X86_FEATURE_CQM_MBM_LOCAL )) { mbm_local_event.configurable = true; -mbm_config_rftype_init ("mbm_local_bytes_config" ); +resctrl_file_fflags_init ("mbm_local_bytes_config" , +RFTYPE_MON_INFO |RFTYPE_RES_CACHE ); } }
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2 -13
@@ -2020,24 +2020,13 @@ static struct rftype *rdtgroup_get_rftype_by_name(const char *name)return NULL ; } -void __init thread_throttle_mode_init (void ) -{ -struct rftype *rft; - - rft =rdtgroup_get_rftype_by_name ("thread_throttle_mode" ); -if (!rft) -return ; - - rft->fflags =RFTYPE_CTRL_INFO |RFTYPE_RES_MB ; -} - -void __init mbm_config_rftype_init (const char *config) +void resctrl_file_fflags_init (const char *config,unsigned long fflags) {struct rftype *rft; rft =rdtgroup_get_rftype_by_name (config);if (rft) - rft->fflags =RFTYPE_MON_INFO |RFTYPE_RES_CACHE ; + rft->fflags = fflags; }/**
Signature · 1 line
2.47.0
Tony Luck
maintainerPATCH v10 2/8 x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
In reply to Tony LuckResctrl uses local memory bandwidth event as input to the feedback loop when the mba_MBps mount option is used. This means that this mount option cannot be used on systems that only support monitoring of total bandwidth.
Prepare to allow users to choose the input event independently for each CTRL_MON group by adding a global variable "mba_mbps_default_event" used to set the default event for each CTRL_MON group, and a new field "mba_mbps_event" in struct rdtgroup to track which event is used for each CTRL_MON group.
Notes:
1) Both of these are only used when the user mounts the filesystm with the "mba_MBps" option.
2) Only check for support of local bandwidth event when initializing mba_mbps_default_event. Support for total bandwidth event can be added after other routines in resctrl have been updated to handle total bandwidth event.
--- include/linux/resctrl.h | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/core.c | 3 +++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 +++++++++++++++ 4 files changed, 22 insertions(+)
include/linux/resctrl.h +2 -0
@@ -49,6 +49,8 @@ enum resctrl_event_id { QOS_L3_MBM_LOCAL_EVENT_ID = 0x03, }; +extern enum resctrl_event_id mba_mbps_default_event; +/** * struct resctrl_staged_config - parsed configuration to be applied * @new_ctrl: new ctrl value to be loaded
arch/x86/kernel/cpu/resctrl/internal.h +2 -0
@@ -283,6 +283,7 @@ struct pseudo_lock_region {* monitor only or ctrl_mon group * @mon: mongroup related data * @mode: mode of resource group +* @mba_mbps_event: input monitoring event id when mba_sc is enabled * @plr: pseudo-locked region */ struct rdtgroup {
@@ -295,6 +296,7 @@ struct rdtgroup {enum rdt_group_type type;struct mongroup mon;enum rdtgrp_mode mode; +enum resctrl_event_id mba_mbps_event;struct pseudo_lock_region *plr; };
arch/x86/kernel/cpu/resctrl/core.c +3 -0
@@ -963,6 +963,9 @@ static __init bool get_rdt_mon_resources(void)if (!rdt_mon_features)return false; +if (is_mbm_local_enabled ()) + mba_mbps_default_event =QOS_L3_MBM_LOCAL_EVENT_ID ; +return !rdt_get_mon_l3_config (r); }
arch/x86/kernel/cpu/resctrl/rdtgroup.c +15 -0
@@ -65,6 +65,17 @@ static void rdtgroup_destroy_root(void);struct dentry *debugfs_resctrl; +/* +* Memory bandwidth monitoring event to use for the +* default CTRL_MON group and each new CTRL_MON +* group created by the user. +* Only relevant when the filesystem is mounted +* with the "mba_MBps" option so it does not matter +* that it remains uninitialized on systems that do +* not support the "mba_MBps" option. +*/ +enum resctrl_event_id mba_mbps_default_event; +static bool resctrl_debug;void rdt_last_cmd_clear (void )
@@ -2353,6 +2364,8 @@ static int set_mba_sc(bool mba_sc) r->membw.mba_sc = mba_sc; + rdtgroup_default.mba_mbps_event = mba_mbps_default_event; +list_for_each_entry (d, &r->ctrl_domains, hdr.list) {for (i =0 ; i < num_closid; i++) d->mbps_val[i] =MBA_MAX_MBPS ;
@@ -3611,6 +3624,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,rdt_last_cmd_puts ("kernfs subdir error\n" ); goto out_del_list; } +if (is_mba_sc (NULL )) + rdtgrp->mba_mbps_event = mba_mbps_default_event; } goto out_unlock;
Signature · 1 line
2.47.0
Reinette Chatre
maintainerRe: [PATCH v10 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
Hi Tony,
Quoted 5 lines · Tony Luck
Resctrl uses local memory bandwidth event as input to the feedback loop when the
mba_MBpsmount option is used. This means that this mount option cannot be used on systems that only support monitoring of total bandwidth.
Quoted 8 lines
Prepare to allow users to choose the input event independently for each
CTRL_MONgroup by adding a global variable "mba_mbps_default_event" used to set the default event for eachCTRL_MONgroup, and a new field "mba_mbps_event" in struct rdtgroup to track which event is used for eachCTRL_MONgroup.Notes:
1) Both of these are only used when the user mounts the filesystm with
filesystm -> filesystem
Quoted 8 lines
the "
mba_MBps" option.
2) Only check for support of local bandwidth event when initializingmba_mbps_default_event. Support for total bandwidth event can be added after other routines in resctrl have been updated to handle total bandwidth event.Signed-off-by Tony Luck <[email protected]>---
...
Quoted 7 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +0
-0@@ -65,6 +65,17 @@ static void rdtgroup_destroy_root(void);struct dentry *debugfs_resctrl;
arch/x86/kernel/cpu/resctrl/rdtgroup.c static void rdtgroup_destroy_root(void); · line 76
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/rdtgroup.c +9
-0+/* +* Memory bandwidth monitoring event to use for the +* default CTRL_MON group and each new CTRL_MON +* group created by the user. +* Only relevant when the filesystem is mounted +* with the "mba_MBps" option so it does not matter +* that it remains uninitialized on systems that do +* not support the "mba_MBps" option. +*/
These lines are trimmed unnecessarily. Could you please make use of the 80 columns available?
With typo and style change:
| Reviewed-by: Reinette Chatre <[email protected]>
Reinette
Tony Luck
maintainerPATCH v10 3/8 x86/resctrl: Modify update_mba_bw() to use per CTRL_MON group event
In reply to Tony LuckUpdate_mba_bw() hard codes use of the memory bandwidth local event which prevents more flexible options from being deployed.
Change this function to use the event specified in the rdtgroup that is being processed.
Mount time checks for the "mba_MBps" option ensure that local memory bandwidth is enabled. So drop the redundant is_mbm_local_enabled() check.
--- arch/x86/kernel/cpu/resctrl/monitor.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/resctrl/monitor.c +9 -7
@@ -752,20 +752,20 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_mon_domain *dom_mbm)u32 closid, rmid, cur_msr_val, new_msr_val;struct mbm_state *pmbm_data, *cmbm_data;struct rdt_ctrl_domain *dom_mba; +enum resctrl_event_id evt_id;struct rdt_resource *r_mba; -u32 cur_bw, user_bw, idx;struct list_head *head;struct rdtgroup *entry; - -if (!is_mbm_local_enabled ()) -return ; +u32 cur_bw, user_bw; r_mba = &rdt_resources_all[RDT_RESOURCE_MBA ].r_resctrl; + evt_id = rgrp->mba_mbps_event; closid = rgrp->closid; rmid = rgrp->mon.rmid; - idx =resctrl_arch_rmid_idx_encode (closid, rmid); - pmbm_data = &dom_mbm->mbm_local[idx]; + pmbm_data =get_mbm_state (dom_mbm, closid, rmid, evt_id); +if (WARN_ON_ONCE (!pmbm_data)) +return ; dom_mba =get_ctrl_domain_from_cpu (smp_processor_id (), r_mba);if (!dom_mba) {
@@ -784,7 +784,9 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_mon_domain *dom_mbm)*/ head = &rgrp->mon.crdtgrp_list;list_for_each_entry (entry, head, mon.crdtgrp_list) { - cmbm_data = &dom_mbm->mbm_local[entry->mon.rmid]; + cmbm_data =get_mbm_state (dom_mbm, entry->closid, entry->mon.rmid, evt_id); +if (WARN_ON_ONCE (!cmbm_data)) +return ; cur_bw += cmbm_data->prev_bw; }
Signature · 1 line
2.47.0
Reinette Chatre
maintainerRe: [PATCH v10 3/8] x86/resctrl: Modify update_mba_bw() to use per CTRL_MON group event
Hi Tony,
Quoted 1 line · Tony Luck
Update_mba_bw()hard codes use of the memory bandwidth local event which
Update_mba_bw() -> update_mba_bw()
Quoted 10 lines
prevents more flexible options from being deployed.
Change this function to use the event specified in the rdtgroup that is being processed.
Mount time checks for the "
mba_MBps" option ensure that local memory bandwidth is enabled. So drop the redundantis_mbm_local_enabled()check.Signed-off-by Tony Luck <[email protected]>---
With typo fixed:
| Reviewed-by: Reinette Chatre <[email protected]>
Reinette
Tony Luck
maintainerPATCH v10 4/8 x86/resctrl: Compute memory bandwidth for all supported events
In reply to Tony LuckSwitching between local and total memory bandwidth events as the input to the mba_sc feedback loop would be cumbersome and take effect slowly in the current implementation as the bandwidth is only known after two consecutive readings of the same event.
Compute the bandwidth for all supported events. This doesn't add significant overhead and will make changing which event is used simple.
--- arch/x86/kernel/cpu/resctrl/monitor.c | 72 ++++++++++++--------------- 1 file changed, 33 insertions(+), 39 deletions(-)
arch/x86/kernel/cpu/resctrl/monitor.c +33 -39
@@ -663,9 +663,12 @@ static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr)*/ static void mbm_bw_count (u32 closid,u32 rmid,struct rmid_read *rr) { -u32 idx =resctrl_arch_rmid_idx_encode (closid, rmid); -struct mbm_state *m = &rr->d->mbm_local[idx];u64 cur_bw, bytes, cur_bytes; +struct mbm_state *m; + + m =get_mbm_state (rr->d, closid, rmid, rr->evtid); +if (WARN_ON_ONCE (!m)) +return ; cur_bytes = rr->val; bytes = cur_bytes - m->prev_bw_bytes;
@@ -815,54 +818,45 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_mon_domain *dom_mbm)resctrl_arch_update_one (r_mba, dom_mba, closid,CDP_NONE , new_msr_val); } -static void mbm_update (struct rdt_resource *r,struct rdt_mon_domain *d, -u32 closid,u32 rmid) +static void mbm_update_one_event (struct rdt_resource *r,struct rdt_mon_domain *d, +u32 closid,u32 rmid,enum resctrl_event_id evtid) {struct rmid_read rr = {0 }; rr.r = r; rr.d = d; + rr.evtid = evtid; + rr.arch_mon_ctx =resctrl_arch_mon_ctx_alloc (rr.r, rr.evtid); +if (IS_ERR (rr.arch_mon_ctx)) { +pr_warn_ratelimited ("Failed to allocate monitor context: %ld" , +PTR_ERR (rr.arch_mon_ctx)); +return ; + } + +__mon_event_count (closid, rmid, &rr);/* -* This is protected from concurrent reads from user -* as both the user and we hold the global mutex. +* If the software controller is enabled, compute the +* bandwidth for this event id. */ -if (is_mbm_total_enabled ()) { - rr.evtid =QOS_L3_MBM_TOTAL_EVENT_ID ; - rr.val =0 ; - rr.arch_mon_ctx =resctrl_arch_mon_ctx_alloc (rr.r, rr.evtid); -if (IS_ERR (rr.arch_mon_ctx)) { -pr_warn_ratelimited ("Failed to allocate monitor context: %ld" , -PTR_ERR (rr.arch_mon_ctx)); -return ; - } +if (is_mba_sc (NULL )) +mbm_bw_count (closid, rmid, &rr); -__mon_event_count (closid, rmid, &rr); - -resctrl_arch_mon_ctx_free (rr.r, rr.evtid, rr.arch_mon_ctx); - } -if (is_mbm_local_enabled ()) { - rr.evtid =QOS_L3_MBM_LOCAL_EVENT_ID ; - rr.val =0 ; - rr.arch_mon_ctx =resctrl_arch_mon_ctx_alloc (rr.r, rr.evtid); -if (IS_ERR (rr.arch_mon_ctx)) { -pr_warn_ratelimited ("Failed to allocate monitor context: %ld" , -PTR_ERR (rr.arch_mon_ctx)); -return ; - } - -__mon_event_count (closid, rmid, &rr); +resctrl_arch_mon_ctx_free (rr.r, rr.evtid, rr.arch_mon_ctx); +} -/* -* Call the MBA software controller only for the -* control groups and when user has enabled -* the software controller explicitly. -*/ -if (is_mba_sc (NULL )) -mbm_bw_count (closid, rmid, &rr); +static void mbm_update (struct rdt_resource *r,struct rdt_mon_domain *d, +u32 closid,u32 rmid) +{ +/* +* This is protected from concurrent reads from user as both +* the user and overflow handler hold the global mutex. +*/ +if (is_mbm_total_enabled ()) +mbm_update_one_event (r, d, closid, rmid,QOS_L3_MBM_TOTAL_EVENT_ID ); -resctrl_arch_mon_ctx_free (rr.r, rr.evtid, rr.arch_mon_ctx); - } +if (is_mbm_local_enabled ()) +mbm_update_one_event (r, d, closid, rmid,QOS_L3_MBM_LOCAL_EVENT_ID ); }/*
Signature · 1 line
2.47.0
Re: [PATCH v10 4/8] x86/resctrl: Compute memory bandwidth for all supported events
Hi Tony,
Quoted 5 lines · Tony Luck
Switching between local and total memory bandwidth events as the input to the
mba_scfeedback loop would be cumbersome and take effect slowly in the current implementation as the bandwidth is only known after two consecutive readings of the same event.
Quoted 7 lines
Compute the bandwidth for all supported events. This doesn't add significant overhead and will make changing which event is used simple.
Suggested-by Reinette Chatre <[email protected]>Signed-off-by Tony Luck <[email protected]>---
Reinette
Tony Luck
maintainerPATCH v10 5/8 x86/resctrl: Make mba_sc use total bandwidth if local is not supported
In reply to Tony LuckThe default input measurement to the mba_sc feedback loop for memory bandwidth control when the user mounts with the "mba_MBps" option is the local bandwidth event.
But some systems may not support a local bandwidth event.
When local bandwidth event is not supported, check for support of total bandwidth and use that instead.
Relax the mount option check to allow use of the "mba_MBps" option for systems when only total bandwidth monitoring is supported. Also update the error message.
--- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/resctrl/core.c +2 -0
@@ -965,6 +965,8 @@ static __init bool get_rdt_mon_resources(void)if (is_mbm_local_enabled ()) mba_mbps_default_event =QOS_L3_MBM_LOCAL_EVENT_ID ; +else if (is_mbm_total_enabled ()) + mba_mbps_default_event =QOS_L3_MBM_TOTAL_EVENT_ID ;return !rdt_get_mon_l3_config (r); }
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2 -2
@@ -2343,7 +2343,7 @@ static bool supports_mba_mbps(void)struct rdt_resource *rmbm = &rdt_resources_all[RDT_RESOURCE_L3 ].r_resctrl;struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA ].r_resctrl; -return (is_mbm_local_enabled () && +return (is_mbm_enabled () && r->alloc_capable &&is_mba_linear () && r->ctrl_scope == rmbm->mon_scope); }
@@ -2770,7 +2770,7 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param) ctx->enable_cdpl2 = true;return 0 ;case Opt_mba_mbps: - msg ="mba_MBps requires local MBM and linear scale MBA at L3 scope" ; + msg ="mba_MBps requires MBM and linear scale MBA at L3 scope" ;if (!supports_mba_mbps ())return invalfc (fc, msg); ctx->enable_mba_mbps = true;
Signature · 1 line
2.47.0
Re: [PATCH v10 5/8] x86/resctrl: Make mba_sc use total bandwidth if local is not supported
Hi Tony,
Quoted 9 lines · Tony Luck
The default input measurement to the
mba_scfeedback loop for memory bandwidth control when the user mounts with the "mba_MBps" option is the local bandwidth event.But some systems may not support a local bandwidth event.
When local bandwidth event is not supported, check for support of total bandwidth and use that instead.
Quoted 6 lines
Relax the mount option check to allow use of the "
mba_MBps" option for systems when only total bandwidth monitoring is supported. Also update the error message.Signed-off-by Tony Luck <[email protected]>---
Reinette
Tony Luck
maintainerPATCH v10 6/8 x86/resctrl: Add "mba_MBps_event" file to CTRL_MON directories
In reply to Tony LuckThe "mba_MBps" mount option provides an alternate method to control memory bandwidth. Instead of specifying allowable bandwidth as a percentage of maximum possible, the user provides a MiB/s limit value.
In preparation to allow the user to pick the memory bandwidth monitoring event used as input to the feedback loop, provide a file in each CTRL_MON group directory that shows the event currently in use. Note that this file is only visible when the "mba_MBps" mount option is in use.
--- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 30 +++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 ++++++++ 3 files changed, 42 insertions(+)
arch/x86/kernel/cpu/resctrl/internal.h +2 -0
@@ -609,6 +609,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off);int rdtgroup_schemata_show (struct kernfs_open_file *of,struct seq_file *s,void *v); +int rdtgroup_mba_mbps_event_show (struct kernfs_open_file *of, +struct seq_file *s,void *v);bool rdtgroup_cbm_overlaps (struct resctrl_schema *s,struct rdt_ctrl_domain *d,unsigned long cbm,int closid,bool exclusive); unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_ctrl_domain *d,
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +30 -0
@@ -518,6 +518,36 @@ static int smp_mon_event_count(void *arg)return 0 ; } +int rdtgroup_mba_mbps_event_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) { +switch (rdtgrp->mba_mbps_event) { +case QOS_L3_MBM_LOCAL_EVENT_ID : +seq_puts (s,"mbm_local_bytes\n" ); +break ; +case QOS_L3_MBM_TOTAL_EVENT_ID : +seq_puts (s,"mbm_total_bytes\n" ); +break ; +default : +pr_warn_once ("Bad event %d\n" , rdtgrp->mba_mbps_event); + ret = -EINVAL ; +break ; + } + }else { + ret = -ENOENT ; + } + +rdtgroup_kn_unlock (of->kn); + +return ret; +} +void mon_event_read (struct rmid_read *rr,struct rdt_resource *r,struct rdt_mon_domain *d,struct rdtgroup *rdtgrp,cpumask_t *cpumask,int evtid,int first)
arch/x86/kernel/cpu/resctrl/rdtgroup.c +10 -0
@@ -1952,6 +1952,12 @@ static struct rftype res_common_files[] = { .seq_show = rdtgroup_schemata_show, .fflags = RFTYPE_CTRL_BASE, }, + { + .name = "mba_MBps_event", + .mode = 0444, + .kf_ops = &rdtgroup_kf_single_ops, + .seq_show = rdtgroup_mba_mbps_event_show, + }, { .name = "mode", .mode = 0644,
@@ -2357,6 +2363,7 @@ static int set_mba_sc(bool mba_sc)struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA ].r_resctrl;u32 num_closid =resctrl_arch_get_num_closid (r);struct rdt_ctrl_domain *d; +unsigned long fflags;int i;if (!supports_mba_mbps () || mba_sc ==is_mba_sc (r))
@@ -2371,6 +2378,9 @@ static int set_mba_sc(bool mba_sc) d->mbps_val[i] =MBA_MAX_MBPS ; } + fflags = mba_sc ?RFTYPE_CTRL_BASE |RFTYPE_MON_BASE :0 ; +resctrl_file_fflags_init ("mba_MBps_event" , fflags); +return 0 ; }
Signature · 1 line
2.47.0
Re: [PATCH v10 6/8] x86/resctrl: Add "mba_MBps_event" file to CTRL_MON directories
Hi Tony,
Quoted 11 lines · Tony Luck
The "
mba_MBps" mount option provides an alternate method to control memory bandwidth. Instead of specifying allowable bandwidth as a percentage of maximum possible, the user provides a MiB/s limit value.In preparation to allow the user to pick the memory bandwidth monitoring event used as input to the feedback loop, provide a file in each
CTRL_MONgroup directory that shows the event currently in use. Note that this file is only visible when the "mba_MBps" mount option is in use.
Quoted 3 lines
Suggested-by Reinette Chatre <[email protected]>Signed-off-by Tony Luck <[email protected]>---
Reinette
Tony Luck
maintainerPATCH v10 7/8 x86/resctrl: Add write option to "mba_MBps_event" file
In reply to Tony LuckThe "mba_MBps" mount option provides an alternate method to control memory bandwidth. Instead of specifying allowable bandwidth as a percentage of maximum possible, the user provides a MiB/s limit value.
There is a file in each CTRL_MON group directory that shows the event currently in use.
Allow writing that file to choose a different event.
A user can choose any of the memory bandwidth monitoring events listed in /sys/fs/resctrl/info/L3_mon/mon_features independently for each CTRL_MON group by writing to each of the "mba_MBps_event" files.
--- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 40 +++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 3 +- 3 files changed, 44 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/resctrl/internal.h +2 -0
@@ -609,6 +609,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off);int rdtgroup_schemata_show (struct kernfs_open_file *of,struct seq_file *s,void *v); +ssize_t rdtgroup_mba_mbps_event_write (struct kernfs_open_file *of, +char *buf,size_t nbytes,loff_t off);int rdtgroup_mba_mbps_event_show (struct kernfs_open_file *of,struct seq_file *s,void *v); bool rdtgroup_cbm_overlaps(struct resctrl_schema *s, struct rdt_ctrl_domain *d,
arch/x86/kernel/cpu/resctrl/ctrlmondata.c +40 -0
@@ -518,6 +518,46 @@ static int smp_mon_event_count(void *arg)return 0 ; } +ssize_t rdtgroup_mba_mbps_event_write (struct kernfs_open_file *of, +char *buf,size_t nbytes,loff_t off) +{ +struct rdtgroup *rdtgrp; +int ret =0 ; + +/* Valid input requires a trailing newline */ +if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) +return -EINVAL ; + buf[nbytes -1 ] ='\0' ; + + rdtgrp =rdtgroup_kn_lock_live (of->kn); +if (!rdtgrp) { +rdtgroup_kn_unlock (of->kn); +return -ENOENT ; + } +rdt_last_cmd_clear (); + +if (!strcmp (buf,"mbm_local_bytes" )) { +if (is_mbm_local_enabled ()) + rdtgrp->mba_mbps_event =QOS_L3_MBM_LOCAL_EVENT_ID ; +else + ret = -EINVAL ; + }else if (!strcmp (buf,"mbm_total_bytes" )) { +if (is_mbm_total_enabled ()) + rdtgrp->mba_mbps_event =QOS_L3_MBM_TOTAL_EVENT_ID ; +else + ret = -EINVAL ; + }else { + ret = -EINVAL ; + } + +if (ret) +rdt_last_cmd_printf ("Unsupported event id '%s'\n" , buf); + +rdtgroup_kn_unlock (of->kn); + +return ret ?: nbytes; +} +int rdtgroup_mba_mbps_event_show (struct kernfs_open_file *of,struct seq_file *s,void *v) {
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2 -1
@@ -1954,8 +1954,9 @@ static struct rftype res_common_files[] = { }, { .name = "mba_MBps_event", - .mode = 0444, + .mode = 0644, .kf_ops = &rdtgroup_kf_single_ops, + .write = rdtgroup_mba_mbps_event_write, .seq_show = rdtgroup_mba_mbps_event_show, }, {
Signature · 1 line
2.47.0
Re: [PATCH v10 7/8] x86/resctrl: Add write option to "mba_MBps_event" file
Hi Tony,
Quoted 7 lines · Tony Luck
The "
mba_MBps" mount option provides an alternate method to control memory bandwidth. Instead of specifying allowable bandwidth as a percentage of maximum possible, the user provides a MiB/s limit value.There is a file in each
CTRL_MONgroup directory that shows the event currently in use.
Quoted 8 lines
Allow writing that file to choose a different event.
A user can choose any of the memory bandwidth monitoring events listed in
/sys/fs/resctrl/info/L3_mon/mon_featuresindependently for eachCTRL_MONgroup by writing to each of the "mba_MBps_event" files.Signed-off-by Tony Luck <[email protected]>---
Reinette
Tony Luck
maintainerPATCH v10 8/8 x86/resctrl: Document the new "mba_MBps_event" file
In reply to Tony LuckAdd a section to document a new read/write file that shows/sets the memory bandwidth event used to control bandwidth used by each CTRL_MON group.
--- Documentation/arch/x86/resctrl.rst | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/arch/x86/resctrl.rst +10 -0
@@ -384,6 +384,16 @@ When monitoring is enabled all MON groups will also contain: Available only with debug option. The identifier used by hardware for the monitor group. On x86 this is the RMID. +When the "mba_MBps" mount option is used all CTRL_MON groups will also contain: + +"mba_MBps_event": + Reading this file shows which memory bandwidth event is used + as input to the software feedback loop that keeps memory bandwidth + below the value specified in the schemata file. Writing the + name of one of the supported memory bandwidth events found in + /sys/fs/resctrl/info/L3_MON/mon_features changes the input + event. + Resource allocation rules -------------------------
Signature · 1 line
2.47.0
Re: [PATCH v10 8/8] x86/resctrl: Document the new "mba_MBps_event" file
Hi Tony,
Quoted 5 lines · Tony Luck
Add a section to document a new read/write file that shows/sets the memory bandwidth event used to control bandwidth used by each
CTRL_MONgroup.Signed-off-by Tony Luck <[email protected]>---
Reinette