* [PATCH] x86/resctrl: Avoid overflow in MB settings in bw_validate()
@ 2024-09-16 10:37 Martin Kletzander
2024-09-16 13:06 ` Martin Kletzander
0 siblings, 1 reply; 2+ messages in thread
From: Martin Kletzander @ 2024-09-16 10:37 UTC (permalink / raw)
To: Fenghua Yu, Reinette Chatre, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, linux-kernel
When resctrl is mounted with the "mba_MBps" option the default (maximum)
bandwidth is the maximum unsigned value for the type. However when
using the same value that already exists in the schemata file it is then
rounded up to the bandwidth granularity and overflows to a small number
instead, making it difficult to reset memory bandwidth allocation value
back to its default.
Since the granularity and minimum bandwidth are not used when the
software controller is used (resctrl is mounted with the "mba_MBps"),
skip the rounding up as well and return early from bw_validate().
Signed-off-by: Martin Kletzander <nert.pinx@gmail.com>
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index 50fa1fe9a073..7e6014176a29 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -48,8 +48,11 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
return false;
}
- if ((bw < r->membw.min_bw || bw > r->default_ctrl) &&
- !is_mba_sc(r)) {
+ /* Nothing else to do if software controller is enabled */
+ if (is_mba_sc(r))
+ return true;
+
+ if (bw < r->membw.min_bw || bw > r->default_ctrl) {
rdt_last_cmd_printf("MB value %ld out of range [%d,%d]\n", bw,
r->membw.min_bw, r->default_ctrl);
return false;
--
2.46.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] x86/resctrl: Avoid overflow in MB settings in bw_validate()
2024-09-16 10:37 [PATCH] x86/resctrl: Avoid overflow in MB settings in bw_validate() Martin Kletzander
@ 2024-09-16 13:06 ` Martin Kletzander
0 siblings, 0 replies; 2+ messages in thread
From: Martin Kletzander @ 2024-09-16 13:06 UTC (permalink / raw)
To: Fenghua Yu, Reinette Chatre, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, linux-kernel
On Mon, Sep 16, 2024 at 12:37:13PM +0200, Martin Kletzander wrote:
>When resctrl is mounted with the "mba_MBps" option the default (maximum)
>bandwidth is the maximum unsigned value for the type. However when
>using the same value that already exists in the schemata file it is then
>rounded up to the bandwidth granularity and overflows to a small number
>instead, making it difficult to reset memory bandwidth allocation value
>back to its default.
>
>Since the granularity and minimum bandwidth are not used when the
>software controller is used (resctrl is mounted with the "mba_MBps"),
>skip the rounding up as well and return early from bw_validate().
>
>Signed-off-by: Martin Kletzander <nert.pinx@gmail.com>
>---
> arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
>diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
>index 50fa1fe9a073..7e6014176a29 100644
>--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
>+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
>@@ -48,8 +48,11 @@ static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
> return false;
> }
>
>- if ((bw < r->membw.min_bw || bw > r->default_ctrl) &&
>- !is_mba_sc(r)) {
>+ /* Nothing else to do if software controller is enabled */
>+ if (is_mba_sc(r))
>+ return true;
I'm so sorry, I sent an incomplete patch. This still needs to modify
the *data argument. I'll send a v2 shortly.
>+
>+ if (bw < r->membw.min_bw || bw > r->default_ctrl) {
> rdt_last_cmd_printf("MB value %ld out of range [%d,%d]\n", bw,
> r->membw.min_bw, r->default_ctrl);
> return false;
>--
>2.46.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-16 13:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-16 10:37 [PATCH] x86/resctrl: Avoid overflow in MB settings in bw_validate() Martin Kletzander
2024-09-16 13:06 ` Martin Kletzander
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®