* [PATCH v11 1/8] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags
2024-12-06 16:31 [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Tony Luck
@ 2024-12-06 16:31 ` Tony Luck
2024-12-13 21:02 ` [tip: x86/cache] " tip-bot2 for Babu Moger
2024-12-06 16:31 ` [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control Tony Luck
` (7 subsequent siblings)
8 siblings, 1 reply; 31+ messages in thread
From: Tony Luck @ 2024-12-06 16:31 UTC (permalink / raw)
To: Fenghua Yu, Reinette Chatre, Peter Newman, Jonathan Corbet, x86
Cc: James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches,
Tony Luck
From: Babu Moger <babu.moger@amd.com>
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]
Signed-off-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
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(-)
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 955999aecfca..faaff9d64102 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -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);
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index b681c2e07dbf..f3ee5859b69d 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -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;
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 5fcb3d635d91..69bdc11bacf8 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -1224,11 +1224,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);
}
}
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index d906a1cd8491..d333570e893d 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -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;
}
/**
--
2.47.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [tip: x86/cache] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags
2024-12-06 16:31 ` [PATCH v11 1/8] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags Tony Luck
@ 2024-12-13 21:02 ` tip-bot2 for Babu Moger
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot2 for Babu Moger @ 2024-12-13 21:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Babu Moger, Tony Luck, Borislav Petkov (AMD), Reinette Chatre,
x86, linux-kernel
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 2937f9c361f7a8b230cd599e4af5264798bf4ce7
Gitweb: https://git.kernel.org/tip/2937f9c361f7a8b230cd599e4af5264798bf4ce7
Author: Babu Moger <babu.moger@amd.com>
AuthorDate: Fri, 06 Dec 2024 08:31:41 -08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 09 Dec 2024 21:37:01 +01:00
x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags
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. ]
Signed-off-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://lore.kernel.org/r/20241206163148.83828-2-tony.luck@intel.com
---
arch/x86/kernel/cpu/resctrl/core.c | 4 +++-
arch/x86/kernel/cpu/resctrl/internal.h | 3 +--
arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++--
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 ++-------------
4 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index b681c2e..f3ee585 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -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;
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 955999a..faaff9d 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -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);
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 5fcb3d6..69bdc11 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -1224,11 +1224,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);
}
}
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index d906a1c..d333570 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -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;
}
/**
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-06 16:31 [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Tony Luck
2024-12-06 16:31 ` [PATCH v11 1/8] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags Tony Luck
@ 2024-12-06 16:31 ` Tony Luck
2024-12-09 20:45 ` Borislav Petkov
2024-12-13 21:02 ` [tip: x86/cache] " tip-bot2 for Tony Luck
2024-12-06 16:31 ` [PATCH v11 3/8] x86/resctrl: Modify update_mba_bw() to use per CTRL_MON group event Tony Luck
` (6 subsequent siblings)
8 siblings, 2 replies; 31+ messages in thread
From: Tony Luck @ 2024-12-06 16:31 UTC (permalink / raw)
To: Fenghua Yu, Reinette Chatre, Peter Newman, Jonathan Corbet, x86
Cc: James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches,
Tony Luck
Resctrl 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 filesystem 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.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
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 | 13 +++++++++++++
4 files changed, 20 insertions(+)
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index d94abba1c716..fd05b937e2f4 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -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
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index faaff9d64102..485800055a7d 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -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;
};
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index f3ee5859b69d..94bf559966d6 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -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);
}
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index d333570e893d..8a52b25ce26b 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -65,6 +65,15 @@ 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 +2362,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 +3622,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;
--
2.47.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-06 16:31 ` [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control Tony Luck
@ 2024-12-09 20:45 ` Borislav Petkov
2024-12-09 22:05 ` Luck, Tony
2024-12-13 21:02 ` [tip: x86/cache] " tip-bot2 for Tony Luck
1 sibling, 1 reply; 31+ messages in thread
From: Borislav Petkov @ 2024-12-09 20:45 UTC (permalink / raw)
To: Tony Luck
Cc: Fenghua Yu, Reinette Chatre, Peter Newman, Jonathan Corbet, x86,
James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches
On Fri, Dec 06, 2024 at 08:31:42AM -0800, Tony Luck wrote:
> diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
> index d94abba1c716..fd05b937e2f4 100644
> --- a/include/linux/resctrl.h
> +++ b/include/linux/resctrl.h
> @@ -49,6 +49,8 @@ enum resctrl_event_id {
> QOS_L3_MBM_LOCAL_EVENT_ID = 0x03,
> };
>
> +extern enum resctrl_event_id mba_mbps_default_event;
Any reason this extern isn't in
arch/x86/kernel/cpu/resctrl/internal.h
?
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 31+ messages in thread* RE: [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-09 20:45 ` Borislav Petkov
@ 2024-12-09 22:05 ` Luck, Tony
2024-12-09 22:20 ` Borislav Petkov
0 siblings, 1 reply; 31+ messages in thread
From: Luck, Tony @ 2024-12-09 22:05 UTC (permalink / raw)
To: Borislav Petkov
Cc: Yu, Fenghua, Chatre, Reinette, Peter Newman, Jonathan Corbet,
x86@kernel.org, James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
> > diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
> > index d94abba1c716..fd05b937e2f4 100644
> > --- a/include/linux/resctrl.h
> > +++ b/include/linux/resctrl.h
> > @@ -49,6 +49,8 @@ enum resctrl_event_id {
> > QOS_L3_MBM_LOCAL_EVENT_ID = 0x03,
> > };
> >
> > +extern enum resctrl_event_id mba_mbps_default_event;
>
> Any reason this extern isn't in
>
> arch/x86/kernel/cpu/resctrl/internal.h
Trying to avoid making more work for the ARM folks as they split resctrl
into "file system" and "architecture specific" bits.
mba_mbps_default_event isn't architecture specific. The mba_MBps
feedback code could be implemented on any architecture that supports
both measurement and control of memory bandwidth.
-Tony
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-09 22:05 ` Luck, Tony
@ 2024-12-09 22:20 ` Borislav Petkov
2024-12-09 22:35 ` Luck, Tony
0 siblings, 1 reply; 31+ messages in thread
From: Borislav Petkov @ 2024-12-09 22:20 UTC (permalink / raw)
To: Luck, Tony
Cc: Yu, Fenghua, Chatre, Reinette, Peter Newman, Jonathan Corbet,
x86@kernel.org, James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
On Mon, Dec 09, 2024 at 10:05:43PM +0000, Luck, Tony wrote:
> mba_mbps_default_event isn't architecture specific. The mba_MBps
> feedback code could be implemented on any architecture that supports
> both measurement and control of memory bandwidth.
Yes, and it should be moved to that header then, right?
But not earlier.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 31+ messages in thread* RE: [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-09 22:20 ` Borislav Petkov
@ 2024-12-09 22:35 ` Luck, Tony
2024-12-09 23:40 ` Reinette Chatre
0 siblings, 1 reply; 31+ messages in thread
From: Luck, Tony @ 2024-12-09 22:35 UTC (permalink / raw)
To: Borislav Petkov
Cc: Yu, Fenghua, Chatre, Reinette, Peter Newman, Jonathan Corbet,
x86@kernel.org, James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
> > mba_mbps_default_event isn't architecture specific. The mba_MBps
> > feedback code could be implemented on any architecture that supports
> > both measurement and control of memory bandwidth.
>
> Yes, and it should be moved to that header then, right?
>
> But not earlier.
If you feel strongly about it then go ahead and cut the line from <linux/rectrl.h>
and paste it into <asm/resctrl.h>
-Tony
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-09 22:35 ` Luck, Tony
@ 2024-12-09 23:40 ` Reinette Chatre
2024-12-10 0:00 ` Luck, Tony
0 siblings, 1 reply; 31+ messages in thread
From: Reinette Chatre @ 2024-12-09 23:40 UTC (permalink / raw)
To: Luck, Tony, Borislav Petkov
Cc: Yu, Fenghua, Peter Newman, Jonathan Corbet, x86@kernel.org,
James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
Hi Tony,
On 12/9/24 2:35 PM, Luck, Tony wrote:
>>> mba_mbps_default_event isn't architecture specific. The mba_MBps
>>> feedback code could be implemented on any architecture that supports
>>> both measurement and control of memory bandwidth.
>>
>> Yes, and it should be moved to that header then, right?
>>
>> But not earlier.
>
> If you feel strongly about it then go ahead and cut the line from <linux/rectrl.h>
> and paste it into <asm/resctrl.h>
I am not sure about this ... I expect the code needing this initially will
form part of the filesystem code so it may be more intuitive to have it
be located in arch/x86/kernel/cpu/resctrl/internal.h as Boris suggested.
As part of the arch/fs split it may then move to fs/resctrl/internal.h
mba_mbps_default_event may even stay internal to the fs/resctrl code with an
arch helper created later to initialize it. This is because I think
the initialization of mba_mbps_default_event may move out of
get_rdt_mon_resources() into resctrl_mon_resource_init() that is being
created as part of the MPAM work [1]. An example of current fs initialization
done in arch code that is moved to it can be found in [2].
Reinette
[1] https://lore.kernel.org/all/20241004180347.19985-17-james.morse@arm.com/
[2] https://lore.kernel.org/all/20241004180347.19985-20-james.morse@arm.com/
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-09 23:40 ` Reinette Chatre
@ 2024-12-10 0:00 ` Luck, Tony
2024-12-10 10:13 ` Borislav Petkov
0 siblings, 1 reply; 31+ messages in thread
From: Luck, Tony @ 2024-12-10 0:00 UTC (permalink / raw)
To: Reinette Chatre
Cc: Borislav Petkov, Yu, Fenghua, Peter Newman, Jonathan Corbet,
x86@kernel.org, James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
On Mon, Dec 09, 2024 at 03:40:12PM -0800, Reinette Chatre wrote:
> Hi Tony,
>
> On 12/9/24 2:35 PM, Luck, Tony wrote:
> >>> mba_mbps_default_event isn't architecture specific. The mba_MBps
> >>> feedback code could be implemented on any architecture that supports
> >>> both measurement and control of memory bandwidth.
> >>
> >> Yes, and it should be moved to that header then, right?
> >>
> >> But not earlier.
> >
> > If you feel strongly about it then go ahead and cut the line from <linux/rectrl.h>
> > and paste it into <asm/resctrl.h>
>
> I am not sure about this ... I expect the code needing this initially will
> form part of the filesystem code so it may be more intuitive to have it
> be located in arch/x86/kernel/cpu/resctrl/internal.h as Boris suggested.
> As part of the arch/fs split it may then move to fs/resctrl/internal.h
>
> mba_mbps_default_event may even stay internal to the fs/resctrl code with an
> arch helper created later to initialize it. This is because I think
> the initialization of mba_mbps_default_event may move out of
> get_rdt_mon_resources() into resctrl_mon_resource_init() that is being
> created as part of the MPAM work [1]. An example of current fs initialization
> done in arch code that is moved to it can be found in [2].
Reinette is right. The post-split home of this is not <linux/resctrl.h>
but fs/resctrl/internal.h which doesn't exist yet.
So Boris is right, this declaration should be added to arch/x86/kernel/cpu/resctrl/internal.h
by this patch to be moved later.
>
> [1] https://lore.kernel.org/all/20241004180347.19985-17-james.morse@arm.com/
> [2] https://lore.kernel.org/all/20241004180347.19985-20-james.morse@arm.com/
-Tony
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-10 0:00 ` Luck, Tony
@ 2024-12-10 10:13 ` Borislav Petkov
2024-12-10 18:42 ` Reinette Chatre
0 siblings, 1 reply; 31+ messages in thread
From: Borislav Petkov @ 2024-12-10 10:13 UTC (permalink / raw)
To: Luck, Tony
Cc: Reinette Chatre, Yu, Fenghua, Peter Newman, Jonathan Corbet,
x86@kernel.org, James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
On Mon, Dec 09, 2024 at 04:00:54PM -0800, Luck, Tony wrote:
> Reinette is right. The post-split home of this is not <linux/resctrl.h>
> but fs/resctrl/internal.h which doesn't exist yet.
>
> So Boris is right, this declaration should be added to arch/x86/kernel/cpu/resctrl/internal.h
> by this patch to be moved later.
Done:
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 485800055a7d..542d01c055aa 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -510,6 +510,7 @@ extern struct mutex rdtgroup_mutex;
extern struct rdt_hw_resource rdt_resources_all[];
extern struct rdtgroup rdtgroup_default;
extern struct dentry *debugfs_resctrl;
+extern enum resctrl_event_id mba_mbps_default_event;
enum resctrl_res_level {
RDT_RESOURCE_L3,
@@ -653,5 +654,4 @@ 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);
-
#endif /* _ASM_X86_RESCTRL_INTERNAL_H */
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index fd05b937e2f4..d94abba1c716 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -49,8 +49,6 @@ 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
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-10 10:13 ` Borislav Petkov
@ 2024-12-10 18:42 ` Reinette Chatre
2024-12-10 18:59 ` Borislav Petkov
0 siblings, 1 reply; 31+ messages in thread
From: Reinette Chatre @ 2024-12-10 18:42 UTC (permalink / raw)
To: Borislav Petkov, Luck, Tony
Cc: Yu, Fenghua, Peter Newman, Jonathan Corbet, x86@kernel.org,
James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
Hi Boris,
On 12/10/24 2:13 AM, Borislav Petkov wrote:
> On Mon, Dec 09, 2024 at 04:00:54PM -0800, Luck, Tony wrote:
>> Reinette is right. The post-split home of this is not <linux/resctrl.h>
>> but fs/resctrl/internal.h which doesn't exist yet.
>>
>> So Boris is right, this declaration should be added to arch/x86/kernel/cpu/resctrl/internal.h
>> by this patch to be moved later.
>
> Done:
>
> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index 485800055a7d..542d01c055aa 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h
> @@ -510,6 +510,7 @@ extern struct mutex rdtgroup_mutex;
> extern struct rdt_hw_resource rdt_resources_all[];
> extern struct rdtgroup rdtgroup_default;
> extern struct dentry *debugfs_resctrl;
> +extern enum resctrl_event_id mba_mbps_default_event;
>
> enum resctrl_res_level {
> RDT_RESOURCE_L3,
> @@ -653,5 +654,4 @@ 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);
> -
> #endif /* _ASM_X86_RESCTRL_INTERNAL_H */
> diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
> index fd05b937e2f4..d94abba1c716 100644
> --- a/include/linux/resctrl.h
> +++ b/include/linux/resctrl.h
> @@ -49,8 +49,6 @@ 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
>
Thank you very much for catching the issue and taking the time to create
the fix.
The middle hunk looks to be an unrelated change. I squashed the first and
last hunk of this change into the original patch and all my tests pass.
I am still waiting the 0day test report though.
What would work best for you to have this fix included?
Reinette
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-10 18:42 ` Reinette Chatre
@ 2024-12-10 18:59 ` Borislav Petkov
0 siblings, 0 replies; 31+ messages in thread
From: Borislav Petkov @ 2024-12-10 18:59 UTC (permalink / raw)
To: Reinette Chatre
Cc: Luck, Tony, Yu, Fenghua, Peter Newman, Jonathan Corbet,
x86@kernel.org, James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
On Tue, Dec 10, 2024 at 10:42:33AM -0800, Reinette Chatre wrote:
> Thank you very much for catching the issue and taking the time to create
> the fix.
For nothing. :)
> The middle hunk looks to be an unrelated change.
Yeah, I zapped the superfluous newline while at it.
> I squashed the first and
> last hunk of this change into the original patch and all my tests pass.
> I am still waiting the 0day test report though.
>
> What would work best for you to have this fix included?
Already folded into Tony's patchset.
Will push out once I've gone through the set.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 31+ messages in thread
* [tip: x86/cache] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
2024-12-06 16:31 ` [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control Tony Luck
2024-12-09 20:45 ` Borislav Petkov
@ 2024-12-13 21:02 ` tip-bot2 for Tony Luck
1 sibling, 0 replies; 31+ messages in thread
From: tip-bot2 for Tony Luck @ 2024-12-13 21:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Tony Luck, Borislav Petkov (AMD), Reinette Chatre, Babu Moger,
x86, linux-kernel
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 3b49c37a2f4657730dd38a050b9d221363889dea
Gitweb: https://git.kernel.org/tip/3b49c37a2f4657730dd38a050b9d221363889dea
Author: Tony Luck <tony.luck@intel.com>
AuthorDate: Fri, 06 Dec 2024 08:31:42 -08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 10 Dec 2024 11:13:48 +01:00
x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control
Resctrl 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 filesystem 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.
[ bp: Move mba_mbps_default_event extern into the arch header. ]
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/r/20241206163148.83828-3-tony.luck@intel.com
---
arch/x86/kernel/cpu/resctrl/core.c | 3 +++
arch/x86/kernel/cpu/resctrl/internal.h | 4 +++-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 13 +++++++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index f3ee585..94bf559 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -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);
}
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index faaff9d..542d01c 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -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;
};
@@ -508,6 +510,7 @@ extern struct mutex rdtgroup_mutex;
extern struct rdt_hw_resource rdt_resources_all[];
extern struct rdtgroup rdtgroup_default;
extern struct dentry *debugfs_resctrl;
+extern enum resctrl_event_id mba_mbps_default_event;
enum resctrl_res_level {
RDT_RESOURCE_L3,
@@ -651,5 +654,4 @@ 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);
-
#endif /* _ASM_X86_RESCTRL_INTERNAL_H */
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index d333570..8a52b25 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -65,6 +65,15 @@ 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 +2362,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 +3622,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;
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v11 3/8] x86/resctrl: Modify update_mba_bw() to use per CTRL_MON group event
2024-12-06 16:31 [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Tony Luck
2024-12-06 16:31 ` [PATCH v11 1/8] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags Tony Luck
2024-12-06 16:31 ` [PATCH v11 2/8] x86/resctrl: Prepare for per-CTRL_MON group mba_MBps control Tony Luck
@ 2024-12-06 16:31 ` Tony Luck
2024-12-13 21:02 ` [tip: x86/cache] " tip-bot2 for Tony Luck
2024-12-06 16:31 ` [PATCH v11 4/8] x86/resctrl: Compute memory bandwidth for all supported events Tony Luck
` (5 subsequent siblings)
8 siblings, 1 reply; 31+ messages in thread
From: Tony Luck @ 2024-12-06 16:31 UTC (permalink / raw)
To: Fenghua Yu, Reinette Chatre, Peter Newman, Jonathan Corbet, x86
Cc: James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches,
Tony Luck
update_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.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
arch/x86/kernel/cpu/resctrl/monitor.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 69bdc11bacf8..adb18f088979 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -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;
}
--
2.47.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [tip: x86/cache] x86/resctrl: Modify update_mba_bw() to use per CTRL_MON group event
2024-12-06 16:31 ` [PATCH v11 3/8] x86/resctrl: Modify update_mba_bw() to use per CTRL_MON group event Tony Luck
@ 2024-12-13 21:02 ` tip-bot2 for Tony Luck
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot2 for Tony Luck @ 2024-12-13 21:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Tony Luck, Borislav Petkov (AMD), Reinette Chatre, Babu Moger,
x86, linux-kernel
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 481d363748b2df881df21569f3697b3c7fcf8fc1
Gitweb: https://git.kernel.org/tip/481d363748b2df881df21569f3697b3c7fcf8fc1
Author: Tony Luck <tony.luck@intel.com>
AuthorDate: Fri, 06 Dec 2024 08:31:43 -08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 10 Dec 2024 11:15:19 +01:00
x86/resctrl: Modify update_mba_bw() to use per CTRL_MON group event
update_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.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/r/20241206163148.83828-4-tony.luck@intel.com
---
arch/x86/kernel/cpu/resctrl/monitor.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index 69bdc11..adb18f0 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -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;
}
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v11 4/8] x86/resctrl: Compute memory bandwidth for all supported events
2024-12-06 16:31 [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Tony Luck
` (2 preceding siblings ...)
2024-12-06 16:31 ` [PATCH v11 3/8] x86/resctrl: Modify update_mba_bw() to use per CTRL_MON group event Tony Luck
@ 2024-12-06 16:31 ` Tony Luck
2024-12-13 21:02 ` [tip: x86/cache] " tip-bot2 for Tony Luck
2024-12-06 16:31 ` [PATCH v11 5/8] x86/resctrl: Make mba_sc use total bandwidth if local is not supported Tony Luck
` (4 subsequent siblings)
8 siblings, 1 reply; 31+ messages in thread
From: Tony Luck @ 2024-12-06 16:31 UTC (permalink / raw)
To: Fenghua Yu, Reinette Chatre, Peter Newman, Jonathan Corbet, x86
Cc: James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches,
Tony Luck
Switching 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.
Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
arch/x86/kernel/cpu/resctrl/monitor.c | 72 ++++++++++++---------------
1 file changed, 33 insertions(+), 39 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index adb18f088979..94a1d9780461 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -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);
}
/*
--
2.47.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [tip: x86/cache] x86/resctrl: Compute memory bandwidth for all supported events
2024-12-06 16:31 ` [PATCH v11 4/8] x86/resctrl: Compute memory bandwidth for all supported events Tony Luck
@ 2024-12-13 21:02 ` tip-bot2 for Tony Luck
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot2 for Tony Luck @ 2024-12-13 21:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Reinette Chatre, Tony Luck, Borislav Petkov (AMD), Babu Moger,
x86, linux-kernel
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 2c272fadb58b590eb973c6c447b039f10631f5f7
Gitweb: https://git.kernel.org/tip/2c272fadb58b590eb973c6c447b039f10631f5f7
Author: Tony Luck <tony.luck@intel.com>
AuthorDate: Fri, 06 Dec 2024 08:31:44 -08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 10 Dec 2024 16:13:48 +01:00
x86/resctrl: Compute memory bandwidth for all supported events
Switching 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.
Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/r/20241206163148.83828-5-tony.luck@intel.com
---
arch/x86/kernel/cpu/resctrl/monitor.c | 72 +++++++++++---------------
1 file changed, 33 insertions(+), 39 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c
index adb18f0..94a1d97 100644
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -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);
}
/*
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v11 5/8] x86/resctrl: Make mba_sc use total bandwidth if local is not supported
2024-12-06 16:31 [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Tony Luck
` (3 preceding siblings ...)
2024-12-06 16:31 ` [PATCH v11 4/8] x86/resctrl: Compute memory bandwidth for all supported events Tony Luck
@ 2024-12-06 16:31 ` Tony Luck
2024-12-13 21:02 ` [tip: x86/cache] " tip-bot2 for Tony Luck
2024-12-06 16:31 ` [PATCH v11 6/8] x86/resctrl: Add "mba_MBps_event" file to CTRL_MON directories Tony Luck
` (3 subsequent siblings)
8 siblings, 1 reply; 31+ messages in thread
From: Tony Luck @ 2024-12-06 16:31 UTC (permalink / raw)
To: Fenghua Yu, Reinette Chatre, Peter Newman, Jonathan Corbet, x86
Cc: James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches,
Tony Luck
The 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.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
arch/x86/kernel/cpu/resctrl/core.c | 2 ++
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 94bf559966d6..3d1735ed8d1f 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -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);
}
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 8a52b25ce26b..0659b8e2a71b 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -2341,7 +2341,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);
}
@@ -2768,7 +2768,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;
--
2.47.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [tip: x86/cache] x86/resctrl: Make mba_sc use total bandwidth if local is not supported
2024-12-06 16:31 ` [PATCH v11 5/8] x86/resctrl: Make mba_sc use total bandwidth if local is not supported Tony Luck
@ 2024-12-13 21:02 ` tip-bot2 for Tony Luck
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot2 for Tony Luck @ 2024-12-13 21:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Tony Luck, Borislav Petkov (AMD), Reinette Chatre, Babu Moger,
x86, linux-kernel
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 141cb5c482b38d7e494a207f881d0fe61e4848ef
Gitweb: https://git.kernel.org/tip/141cb5c482b38d7e494a207f881d0fe61e4848ef
Author: Tony Luck <tony.luck@intel.com>
AuthorDate: Fri, 06 Dec 2024 08:31:45 -08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 10 Dec 2024 16:15:14 +01:00
x86/resctrl: Make mba_sc use total bandwidth if local is not supported
The 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.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/r/20241206163148.83828-6-tony.luck@intel.com
---
arch/x86/kernel/cpu/resctrl/core.c | 2 ++
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 94bf559..3d1735e 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -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);
}
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 8a52b25..0659b8e 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -2341,7 +2341,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);
}
@@ -2768,7 +2768,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;
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v11 6/8] x86/resctrl: Add "mba_MBps_event" file to CTRL_MON directories
2024-12-06 16:31 [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Tony Luck
` (4 preceding siblings ...)
2024-12-06 16:31 ` [PATCH v11 5/8] x86/resctrl: Make mba_sc use total bandwidth if local is not supported Tony Luck
@ 2024-12-06 16:31 ` Tony Luck
2024-12-13 21:02 ` [tip: x86/cache] " tip-bot2 for Tony Luck
2024-12-06 16:31 ` [PATCH v11 7/8] x86/resctrl: Add write option to "mba_MBps_event" file Tony Luck
` (2 subsequent siblings)
8 siblings, 1 reply; 31+ messages in thread
From: Tony Luck @ 2024-12-06 16:31 UTC (permalink / raw)
To: Fenghua Yu, Reinette Chatre, Peter Newman, Jonathan Corbet, x86
Cc: James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches,
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_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.
Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
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(+)
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 485800055a7d..ce10a883ecf8 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -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,
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 200d89a64027..5fa37b4ecc7a 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -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)
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 0659b8e2a71b..6eb930b8bdfd 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -1950,6 +1950,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,
@@ -2355,6 +2361,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))
@@ -2369,6 +2376,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;
}
--
2.47.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [tip: x86/cache] x86/resctrl: Add "mba_MBps_event" file to CTRL_MON directories
2024-12-06 16:31 ` [PATCH v11 6/8] x86/resctrl: Add "mba_MBps_event" file to CTRL_MON directories Tony Luck
@ 2024-12-13 21:02 ` tip-bot2 for Tony Luck
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot2 for Tony Luck @ 2024-12-13 21:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Reinette Chatre, Tony Luck, Borislav Petkov (AMD), Babu Moger,
x86, linux-kernel
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: f5cd0e316f14d79c9eb0cf8fe7e60cee3a657aa8
Gitweb: https://git.kernel.org/tip/f5cd0e316f14d79c9eb0cf8fe7e60cee3a657aa8
Author: Tony Luck <tony.luck@intel.com>
AuthorDate: Fri, 06 Dec 2024 08:31:46 -08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Thu, 12 Dec 2024 11:27:28 +01:00
x86/resctrl: Add "mba_MBps_event" file to CTRL_MON directories
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_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.
Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/r/20241206163148.83828-7-tony.luck@intel.com
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 30 ++++++++++++++++++++++-
arch/x86/kernel/cpu/resctrl/internal.h | 2 +-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 +++++++-
3 files changed, 42 insertions(+)
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 200d89a..5fa37b4 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -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)
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 542d01c..1bd61ed 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -610,6 +610,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,
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 0659b8e..6eb930b 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -1951,6 +1951,12 @@ static struct rftype res_common_files[] = {
.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,
.kf_ops = &rdtgroup_kf_single_ops,
@@ -2355,6 +2361,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))
@@ -2369,6 +2376,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;
}
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v11 7/8] x86/resctrl: Add write option to "mba_MBps_event" file
2024-12-06 16:31 [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Tony Luck
` (5 preceding siblings ...)
2024-12-06 16:31 ` [PATCH v11 6/8] x86/resctrl: Add "mba_MBps_event" file to CTRL_MON directories Tony Luck
@ 2024-12-06 16:31 ` Tony Luck
2024-12-13 21:02 ` [tip: x86/cache] " tip-bot2 for Tony Luck
2024-12-06 16:31 ` [PATCH v11 8/8] x86/resctrl: Document the new " Tony Luck
2024-12-09 17:10 ` [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Reinette Chatre
8 siblings, 1 reply; 31+ messages in thread
From: Tony Luck @ 2024-12-06 16:31 UTC (permalink / raw)
To: Fenghua Yu, Reinette Chatre, Peter Newman, Jonathan Corbet, x86
Cc: James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches,
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_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.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
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(-)
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index ce10a883ecf8..6345ab3e0890 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -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,
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 5fa37b4ecc7a..536351159cc2 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -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)
{
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 6eb930b8bdfd..6419e04d8a7b 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -1952,8 +1952,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,
},
{
--
2.47.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [tip: x86/cache] x86/resctrl: Add write option to "mba_MBps_event" file
2024-12-06 16:31 ` [PATCH v11 7/8] x86/resctrl: Add write option to "mba_MBps_event" file Tony Luck
@ 2024-12-13 21:02 ` tip-bot2 for Tony Luck
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot2 for Tony Luck @ 2024-12-13 21:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Tony Luck, Borislav Petkov (AMD), Reinette Chatre, Babu Moger,
x86, linux-kernel
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 8e931105acae688ff0fc8f875a6c05e5aed8ab79
Gitweb: https://git.kernel.org/tip/8e931105acae688ff0fc8f875a6c05e5aed8ab79
Author: Tony Luck <tony.luck@intel.com>
AuthorDate: Fri, 06 Dec 2024 08:31:47 -08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Thu, 12 Dec 2024 11:27:37 +01:00
x86/resctrl: Add write option to "mba_MBps_event" file
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_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.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/r/20241206163148.83828-8-tony.luck@intel.com
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 40 ++++++++++++++++++++++-
arch/x86/kernel/cpu/resctrl/internal.h | 2 +-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 3 +-
3 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 5fa37b4..5363511 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -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)
{
diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
index 1bd61ed..20c898f 100644
--- a/arch/x86/kernel/cpu/resctrl/internal.h
+++ b/arch/x86/kernel/cpu/resctrl/internal.h
@@ -610,6 +610,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,
diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 6eb930b..6419e04 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -1952,8 +1952,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,
},
{
^ permalink raw reply related [flat|nested] 31+ messages in thread
* [PATCH v11 8/8] x86/resctrl: Document the new "mba_MBps_event" file
2024-12-06 16:31 [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Tony Luck
` (6 preceding siblings ...)
2024-12-06 16:31 ` [PATCH v11 7/8] x86/resctrl: Add write option to "mba_MBps_event" file Tony Luck
@ 2024-12-06 16:31 ` Tony Luck
2024-12-13 21:02 ` [tip: x86/cache] " tip-bot2 for Tony Luck
2024-12-09 17:10 ` [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Reinette Chatre
8 siblings, 1 reply; 31+ messages in thread
From: Tony Luck @ 2024-12-06 16:31 UTC (permalink / raw)
To: Fenghua Yu, Reinette Chatre, Peter Newman, Jonathan Corbet, x86
Cc: James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches,
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_MON group.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
Documentation/arch/x86/resctrl.rst | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/resctrl.rst
index a824affd741d..6768fc1fad16 100644
--- a/Documentation/arch/x86/resctrl.rst
+++ b/Documentation/arch/x86/resctrl.rst
@@ -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
-------------------------
--
2.47.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [tip: x86/cache] x86/resctrl: Document the new "mba_MBps_event" file
2024-12-06 16:31 ` [PATCH v11 8/8] x86/resctrl: Document the new " Tony Luck
@ 2024-12-13 21:02 ` tip-bot2 for Tony Luck
0 siblings, 0 replies; 31+ messages in thread
From: tip-bot2 for Tony Luck @ 2024-12-13 21:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Tony Luck, Borislav Petkov (AMD), Reinette Chatre, Babu Moger,
x86, linux-kernel
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: faf6ef673787956ec4d33ac8bf56f8ea929abf37
Gitweb: https://git.kernel.org/tip/faf6ef673787956ec4d33ac8bf56f8ea929abf37
Author: Tony Luck <tony.luck@intel.com>
AuthorDate: Fri, 06 Dec 2024 08:31:48 -08:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Thu, 12 Dec 2024 11:27:43 +01:00
x86/resctrl: Document the new "mba_MBps_event" file
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_MON group.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lore.kernel.org/r/20241206163148.83828-9-tony.luck@intel.com
---
Documentation/arch/x86/resctrl.rst | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/resctrl.rst
index a824aff..6768fc1 100644
--- a/Documentation/arch/x86/resctrl.rst
+++ b/Documentation/arch/x86/resctrl.rst
@@ -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
-------------------------
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement
2024-12-06 16:31 [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Tony Luck
` (7 preceding siblings ...)
2024-12-06 16:31 ` [PATCH v11 8/8] x86/resctrl: Document the new " Tony Luck
@ 2024-12-09 17:10 ` Reinette Chatre
2024-12-09 17:28 ` Borislav Petkov
8 siblings, 1 reply; 31+ messages in thread
From: Reinette Chatre @ 2024-12-09 17:10 UTC (permalink / raw)
To: Tony Luck, Fenghua Yu, Peter Newman, Jonathan Corbet, x86,
Borislav Petkov
Cc: James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches
Hi Boris,
On 12/6/24 8:31 AM, Tony Luck wrote:
> 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 v10:
> Link: https://lore.kernel.org/all/20241122235832.27498-1-tony.luck@intel.com/
>
> Patch Change
> ----- ------
>
> 2 s/filesystm/filesystem/
> Reformat block comment above definition of mba_mbps_default_event using
> more of 80 column width
>
> 3 s/Update_mba_bw()/update_mba_bw()
>
> Added Reinette's Reviewed-by tag to parts 2-8
Could you please consider this series for inclusion?
>
> N.B. v6.13-rc1 introduced a locking change in commit f1be1788a32e ("block:
> model freeze & enter queue as lock for supporting lockdep") that throws
> a lockdep splat when mounting the resctrl filesystem (with certain
> CONFIG options).
>
> Proposed patches that fix this are here:
> Link: https://lore.kernel.org/all/20241206111611.978870-2-ming.lei@redhat.com/
> Link: https://lore.kernel.org/all/20241206111611.978870-3-ming.lei@redhat.com/
>
>
This fix has been merged into v6.13-rc2.
Thank you very much.
Reinette
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement
2024-12-09 17:10 ` [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement Reinette Chatre
@ 2024-12-09 17:28 ` Borislav Petkov
2024-12-09 17:53 ` Luck, Tony
0 siblings, 1 reply; 31+ messages in thread
From: Borislav Petkov @ 2024-12-09 17:28 UTC (permalink / raw)
To: Reinette Chatre
Cc: Tony Luck, Fenghua Yu, Peter Newman, Jonathan Corbet, x86,
James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel, linux-doc, patches
On Mon, Dec 09, 2024 at 09:10:20AM -0800, Reinette Chatre wrote:
> Could you please consider this series for inclusion?
Lemme take a look...
> This fix has been merged into v6.13-rc2.
You mean, I should queue the set ontop of -rc2?
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 31+ messages in thread* RE: [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement
2024-12-09 17:28 ` Borislav Petkov
@ 2024-12-09 17:53 ` Luck, Tony
2024-12-09 17:57 ` Borislav Petkov
0 siblings, 1 reply; 31+ messages in thread
From: Luck, Tony @ 2024-12-09 17:53 UTC (permalink / raw)
To: Borislav Petkov, Chatre, Reinette
Cc: Yu, Fenghua, Peter Newman, Jonathan Corbet, x86@kernel.org,
James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
> > Could you please consider this series for inclusion?
>
> Lemme take a look...
>
> > This fix has been merged into v6.13-rc2.
>
> You mean, I should queue the set ontop of -rc2?
v6.13-rc1 may give a lockdep splat when mounting /sys/fs/resctrl
(known CONFIG options to trigger this are:
PROVE_LOCKING && SELINUX && (EXT4 || BTRFS)
but there may be others).
These resctrl patches are not directly dependent on the fixes that
went into -rc2:
22465bbac53c blk-mq: move cpuhp callback registering out of q->sysfs_lock
4bf485a7db5d blk-mq: register cpuhp callback after hctx is added to xarray table
they work ok on top of -rc1 (as long as you ignore the lockdep splat).
I see you already have one patch in TIP x86/cache on top of v6.13-rc1
Your choice whether to rebase that to -rc2 and then apply my series. It
might make testing smoother.
-Tony
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement
2024-12-09 17:53 ` Luck, Tony
@ 2024-12-09 17:57 ` Borislav Petkov
2024-12-09 19:15 ` Moger, Babu
0 siblings, 1 reply; 31+ messages in thread
From: Borislav Petkov @ 2024-12-09 17:57 UTC (permalink / raw)
To: Luck, Tony
Cc: Chatre, Reinette, Yu, Fenghua, Peter Newman, Jonathan Corbet,
x86@kernel.org, James Morse, Jamie Iles, Babu Moger, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
On Mon, Dec 09, 2024 at 05:53:12PM +0000, Luck, Tony wrote:
> v6.13-rc1 may give a lockdep splat when mounting /sys/fs/resctrl
> (known CONFIG options to trigger this are:
>
> PROVE_LOCKING && SELINUX && (EXT4 || BTRFS)
>
> but there may be others).
>
> These resctrl patches are not directly dependent on the fixes that
> went into -rc2:
>
> 22465bbac53c blk-mq: move cpuhp callback registering out of q->sysfs_lock
> 4bf485a7db5d blk-mq: register cpuhp callback after hctx is added to xarray table
>
> they work ok on top of -rc1 (as long as you ignore the lockdep splat).
Thanks for the details.
> I see you already have one patch in TIP x86/cache on top of v6.13-rc1
>
> Your choice whether to rebase that to -rc2 and then apply my series. It
> might make testing smoother.
Yah, I can rebase. Not worth the hassle of dealing with bogus reports.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH v11 0/8] x86/resctrl: mba_MBps enhancement
2024-12-09 17:57 ` Borislav Petkov
@ 2024-12-09 19:15 ` Moger, Babu
0 siblings, 0 replies; 31+ messages in thread
From: Moger, Babu @ 2024-12-09 19:15 UTC (permalink / raw)
To: Borislav Petkov, Luck, Tony
Cc: Chatre, Reinette, Yu, Fenghua, Peter Newman, Jonathan Corbet,
x86@kernel.org, James Morse, Jamie Iles, Randy Dunlap,
Shaopeng Tan (Fujitsu), linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, patches@lists.linux.dev
On 12/9/24 11:57, Borislav Petkov wrote:
> On Mon, Dec 09, 2024 at 05:53:12PM +0000, Luck, Tony wrote:
>> v6.13-rc1 may give a lockdep splat when mounting /sys/fs/resctrl
>> (known CONFIG options to trigger this are:
>>
>> PROVE_LOCKING && SELINUX && (EXT4 || BTRFS)
>>
>> but there may be others).
>>
>> These resctrl patches are not directly dependent on the fixes that
>> went into -rc2:
>>
>> 22465bbac53c blk-mq: move cpuhp callback registering out of q->sysfs_lock
>> 4bf485a7db5d blk-mq: register cpuhp callback after hctx is added to xarray table
>>
>> they work ok on top of -rc1 (as long as you ignore the lockdep splat).
>
> Thanks for the details.
>
>> I see you already have one patch in TIP x86/cache on top of v6.13-rc1
>>
>> Your choice whether to rebase that to -rc2 and then apply my series. It
>> might make testing smoother.
>
> Yah, I can rebase. Not worth the hassle of dealing with bogus reports.
>
Sanity tested on AMD system. Changes look good.
Tested-by: Babu Moger <babu.moger@amd.com>
--
Thanks
Babu Moger
^ permalink raw reply [flat|nested] 31+ messages in thread