* [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add()
@ 2026-08-21 8:11 Dmitry Antipov
2026-08-21 8:11 ` [PATCH v2 2/2] fs/resctrl: Simplify pseudo_lock_measure_trigger() Dmitry Antipov
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Dmitry Antipov @ 2026-08-21 8:11 UTC (permalink / raw)
To: Reinette Chatre
Cc: Tony Luck, Dave Martin, James Morse, Babu Moger, x86,
linux-kernel, Dmitry Antipov
After passing an overflow check, it's safe to assume that snprintf()
returns the number of characters emitted. So drop the unnecessary
call to strlen().
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v2: adjust title and commit message (Reinette)
---
fs/resctrl/rdtgroup.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 5dcbb0a964e8..68be9b903ac6 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2858,7 +2858,7 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
{
struct resctrl_schema *s;
const char *suffix = "";
- int ret, cl;
+ int cl;
s = kzalloc_obj(*s);
if (!s)
@@ -2882,14 +2882,12 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
break;
}
- ret = snprintf(s->name, sizeof(s->name), "%s%s", r->name, suffix);
- if (ret >= sizeof(s->name)) {
+ cl = snprintf(s->name, sizeof(s->name), "%s%s", r->name, suffix);
+ if (cl >= sizeof(s->name)) {
kfree(s);
return -EINVAL;
}
- cl = strlen(s->name);
-
/*
* If CDP is supported by this resource, but not enabled,
* include the suffix. This ensures the tabular format of the
--
2.55.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/2] fs/resctrl: Simplify pseudo_lock_measure_trigger()
2026-08-21 8:11 [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add() Dmitry Antipov
@ 2026-08-21 8:11 ` Dmitry Antipov
2026-08-25 18:25 ` Reinette Chatre
2026-09-17 21:26 ` [tip: x86/cache] " tip-bot2 for Dmitry Antipov
2026-08-25 18:25 ` [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add() Reinette Chatre
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Dmitry Antipov @ 2026-08-21 8:11 UTC (permalink / raw)
To: Reinette Chatre
Cc: Tony Luck, Dave Martin, James Morse, Babu Moger, x86,
linux-kernel, Dmitry Antipov
Use convenient kstrtoint_from_user() to simplify pseudo_lock_measure_trigger().
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v2: adjust title and commit message (Reinette)
---
fs/resctrl/pseudo_lock.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c
index dea2b4bf966f..56ab63f19bad 100644
--- a/fs/resctrl/pseudo_lock.c
+++ b/fs/resctrl/pseudo_lock.c
@@ -750,17 +750,10 @@ static ssize_t pseudo_lock_measure_trigger(struct file *file,
size_t count, loff_t *ppos)
{
struct rdtgroup *rdtgrp = file->private_data;
- size_t buf_size;
- char buf[32];
int ret;
int sel;
- buf_size = min(count, (sizeof(buf) - 1));
- if (copy_from_user(buf, user_buf, buf_size))
- return -EFAULT;
-
- buf[buf_size] = '\0';
- ret = kstrtoint(buf, 10, &sel);
+ ret = kstrtoint_from_user(user_buf, count, 10, &sel);
if (ret == 0) {
if (sel != 1 && sel != 2 && sel != 3)
return -EINVAL;
--
2.55.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add()
2026-08-21 8:11 [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add() Dmitry Antipov
2026-08-21 8:11 ` [PATCH v2 2/2] fs/resctrl: Simplify pseudo_lock_measure_trigger() Dmitry Antipov
@ 2026-08-25 18:25 ` Reinette Chatre
2026-09-03 15:42 ` Reinette Chatre
2026-09-17 21:26 ` [tip: x86/cache] " tip-bot2 for Dmitry Antipov
3 siblings, 0 replies; 10+ messages in thread
From: Reinette Chatre @ 2026-08-25 18:25 UTC (permalink / raw)
To: Dmitry Antipov
Cc: Tony Luck, Dave Martin, James Morse, Babu Moger, x86, linux-kernel
Hi Dmitry,
On 8/21/26 1:11 AM, Dmitry Antipov wrote:
> After passing an overflow check, it's safe to assume that snprintf()
> returns the number of characters emitted. So drop the unnecessary
> call to strlen().
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
Thank you.
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reinette
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] fs/resctrl: Simplify pseudo_lock_measure_trigger()
2026-08-21 8:11 ` [PATCH v2 2/2] fs/resctrl: Simplify pseudo_lock_measure_trigger() Dmitry Antipov
@ 2026-08-25 18:25 ` Reinette Chatre
2026-09-17 21:26 ` [tip: x86/cache] " tip-bot2 for Dmitry Antipov
1 sibling, 0 replies; 10+ messages in thread
From: Reinette Chatre @ 2026-08-25 18:25 UTC (permalink / raw)
To: Dmitry Antipov
Cc: Tony Luck, Dave Martin, James Morse, Babu Moger, x86, linux-kernel
Hi Dmitry,
On 8/21/26 1:11 AM, Dmitry Antipov wrote:
> Use convenient kstrtoint_from_user() to simplify pseudo_lock_measure_trigger().
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
Thank you.
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reinette
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add()
2026-08-21 8:11 [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add() Dmitry Antipov
2026-08-21 8:11 ` [PATCH v2 2/2] fs/resctrl: Simplify pseudo_lock_measure_trigger() Dmitry Antipov
2026-08-25 18:25 ` [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add() Reinette Chatre
@ 2026-09-03 15:42 ` Reinette Chatre
2026-09-17 15:54 ` Borislav Petkov
2026-09-17 21:26 ` [tip: x86/cache] " tip-bot2 for Dmitry Antipov
3 siblings, 1 reply; 10+ messages in thread
From: Reinette Chatre @ 2026-09-03 15:42 UTC (permalink / raw)
To: Dmitry Antipov, Borislav Petkov, x86
Cc: Tony Luck, Dave Martin, James Morse, Babu Moger, linux-kernel
Dear x86 maintainers,
Could you please consider both cleanups in this series for inclusion?
Thank you very much.
Reinette
On 8/21/26 1:11 AM, Dmitry Antipov wrote:
> After passing an overflow check, it's safe to assume that snprintf()
> returns the number of characters emitted. So drop the unnecessary
> call to strlen().
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> v2: adjust title and commit message (Reinette)
> ---
> fs/resctrl/rdtgroup.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
> index 5dcbb0a964e8..68be9b903ac6 100644
> --- a/fs/resctrl/rdtgroup.c
> +++ b/fs/resctrl/rdtgroup.c
> @@ -2858,7 +2858,7 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
> {
> struct resctrl_schema *s;
> const char *suffix = "";
> - int ret, cl;
> + int cl;
>
> s = kzalloc_obj(*s);
> if (!s)
> @@ -2882,14 +2882,12 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
> break;
> }
>
> - ret = snprintf(s->name, sizeof(s->name), "%s%s", r->name, suffix);
> - if (ret >= sizeof(s->name)) {
> + cl = snprintf(s->name, sizeof(s->name), "%s%s", r->name, suffix);
> + if (cl >= sizeof(s->name)) {
> kfree(s);
> return -EINVAL;
> }
>
> - cl = strlen(s->name);
> -
> /*
> * If CDP is supported by this resource, but not enabled,
> * include the suffix. This ensures the tabular format of the
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add()
2026-09-03 15:42 ` Reinette Chatre
@ 2026-09-17 15:54 ` Borislav Petkov
2026-09-17 16:17 ` Reinette Chatre
0 siblings, 1 reply; 10+ messages in thread
From: Borislav Petkov @ 2026-09-17 15:54 UTC (permalink / raw)
To: Reinette Chatre
Cc: Dmitry Antipov, x86, Tony Luck, Dave Martin, James Morse,
Babu Moger, linux-kernel
On Thu, Sep 03, 2026 at 08:42:47AM -0700, Reinette Chatre wrote:
> Dear x86 maintainers,
>
> Could you please consider both cleanups in this series for inclusion?
I see Sashiko is complaining about two pre-existing issues:
https://sashiko.dev/#/patchset/20260821081128.19242-1-dmantipov%40yandex.ru
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add()
2026-09-17 15:54 ` Borislav Petkov
@ 2026-09-17 16:17 ` Reinette Chatre
2026-09-17 17:37 ` Borislav Petkov
0 siblings, 1 reply; 10+ messages in thread
From: Reinette Chatre @ 2026-09-17 16:17 UTC (permalink / raw)
To: Borislav Petkov
Cc: Dmitry Antipov, x86, Tony Luck, Dave Martin, James Morse,
Babu Moger, linux-kernel
Hi Boris,
On 9/17/26 8:54 AM, Borislav Petkov wrote:
> On Thu, Sep 03, 2026 at 08:42:47AM -0700, Reinette Chatre wrote:
>> Dear x86 maintainers,
>>
>> Could you please consider both cleanups in this series for inclusion?
>
> I see Sashiko is complaining about two pre-existing issues:
>
> https://sashiko.dev/#/patchset/20260821081128.19242-1-dmantipov%40yandex.ru
>
These same pseudo-locking related issues were reported by Sashiko during a previous
resctrl submission:
https://sashiko.dev/#/patchset/20260515193944.15114-1-tony.luck%40intel.com
There was an effort to address these issues, latest attempt can be seen at:
https://lore.kernel.org/lkml/cover.1779476724.git.reinette.chatre@intel.com/
These attempts at fixes just exposed more corner cases related to pseudo-locking, for example:
https://lore.kernel.org/all/e40a924f-5398-43bd-821a-2ff9873c5a4c@intel.com/
All of these issues are related to intricate races that could be triggered by user space stress
of the pseudo-locking files that is only possible on very specific ten-year old hardware.
Since such usage is contrary to the pseudo-locking usage model which requires care by default
I decided to drop that work.
Reinette
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add()
2026-09-17 16:17 ` Reinette Chatre
@ 2026-09-17 17:37 ` Borislav Petkov
0 siblings, 0 replies; 10+ messages in thread
From: Borislav Petkov @ 2026-09-17 17:37 UTC (permalink / raw)
To: Reinette Chatre
Cc: Dmitry Antipov, x86, Tony Luck, Dave Martin, James Morse,
Babu Moger, linux-kernel
On Thu, Sep 17, 2026 at 09:17:23AM -0700, Reinette Chatre wrote:
> Hi Boris,
>
> On 9/17/26 8:54 AM, Borislav Petkov wrote:
> > On Thu, Sep 03, 2026 at 08:42:47AM -0700, Reinette Chatre wrote:
> >> Dear x86 maintainers,
> >>
> >> Could you please consider both cleanups in this series for inclusion?
> >
> > I see Sashiko is complaining about two pre-existing issues:
> >
> > https://sashiko.dev/#/patchset/20260821081128.19242-1-dmantipov%40yandex.ru
> >
>
> These same pseudo-locking related issues were reported by Sashiko during a previous
> resctrl submission:
>
> https://sashiko.dev/#/patchset/20260515193944.15114-1-tony.luck%40intel.com
>
> There was an effort to address these issues, latest attempt can be seen at:
>
> https://lore.kernel.org/lkml/cover.1779476724.git.reinette.chatre@intel.com/
>
> These attempts at fixes just exposed more corner cases related to pseudo-locking, for example:
>
> https://lore.kernel.org/all/e40a924f-5398-43bd-821a-2ff9873c5a4c@intel.com/
>
> All of these issues are related to intricate races that could be triggered by user space stress
> of the pseudo-locking files that is only possible on very specific ten-year old hardware.
> Since such usage is contrary to the pseudo-locking usage model which requires care by default
> I decided to drop that work.
Thanks, we probably should start tracking all those Sashiko complaints which
we're not going to address.
/me notes these links.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 10+ messages in thread
* [tip: x86/cache] fs/resctrl: Simplify pseudo_lock_measure_trigger()
2026-08-21 8:11 ` [PATCH v2 2/2] fs/resctrl: Simplify pseudo_lock_measure_trigger() Dmitry Antipov
2026-08-25 18:25 ` Reinette Chatre
@ 2026-09-17 21:26 ` tip-bot2 for Dmitry Antipov
1 sibling, 0 replies; 10+ messages in thread
From: tip-bot2 for Dmitry Antipov @ 2026-09-17 21:26 UTC (permalink / raw)
To: linux-tip-commits
Cc: Dmitry Antipov, Borislav Petkov (AMD),
Reinette Chatre, x86, linux-kernel
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: a3f5e6eba41885dcffb635b54d6c4a18aa579cd5
Gitweb: https://git.kernel.org/tip/a3f5e6eba41885dcffb635b54d6c4a18aa579cd5
Author: Dmitry Antipov <dmantipov@yandex.ru>
AuthorDate: Fri, 21 Aug 2026 11:11:28 +03:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Thu, 17 Sep 2026 12:08:47 -07:00
fs/resctrl: Simplify pseudo_lock_measure_trigger()
Use convenient kstrtoint_from_user() to simplify pseudo_lock_measure_trigger().
No functional changes.
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://patch.msgid.link/20260821081128.19242-2-dmantipov@yandex.ru
---
fs/resctrl/pseudo_lock.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/fs/resctrl/pseudo_lock.c b/fs/resctrl/pseudo_lock.c
index dea2b4b..56ab63f 100644
--- a/fs/resctrl/pseudo_lock.c
+++ b/fs/resctrl/pseudo_lock.c
@@ -750,17 +750,10 @@ static ssize_t pseudo_lock_measure_trigger(struct file *file,
size_t count, loff_t *ppos)
{
struct rdtgroup *rdtgrp = file->private_data;
- size_t buf_size;
- char buf[32];
int ret;
int sel;
- buf_size = min(count, (sizeof(buf) - 1));
- if (copy_from_user(buf, user_buf, buf_size))
- return -EFAULT;
-
- buf[buf_size] = '\0';
- ret = kstrtoint(buf, 10, &sel);
+ ret = kstrtoint_from_user(user_buf, count, 10, &sel);
if (ret == 0) {
if (sel != 1 && sel != 2 && sel != 3)
return -EINVAL;
^ permalink raw reply [flat|nested] 10+ messages in thread
* [tip: x86/cache] fs/resctrl: Avoid extra call to strlen() in schemata_list_add()
2026-08-21 8:11 [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add() Dmitry Antipov
` (2 preceding siblings ...)
2026-09-03 15:42 ` Reinette Chatre
@ 2026-09-17 21:26 ` tip-bot2 for Dmitry Antipov
3 siblings, 0 replies; 10+ messages in thread
From: tip-bot2 for Dmitry Antipov @ 2026-09-17 21:26 UTC (permalink / raw)
To: linux-tip-commits
Cc: Dmitry Antipov, Borislav Petkov (AMD),
Reinette Chatre, x86, linux-kernel
The following commit has been merged into the x86/cache branch of tip:
Commit-ID: 4b31656d917c46c6d9f874162ede4f54b2a5959f
Gitweb: https://git.kernel.org/tip/4b31656d917c46c6d9f874162ede4f54b2a5959f
Author: Dmitry Antipov <dmantipov@yandex.ru>
AuthorDate: Fri, 21 Aug 2026 11:11:27 +03:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Thu, 17 Sep 2026 10:41:53 -07:00
fs/resctrl: Avoid extra call to strlen() in schemata_list_add()
After passing an overflow check, it's safe to assume that snprintf()
returns the number of characters emitted. So drop the unnecessary
call to strlen().
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://patch.msgid.link/20260821081128.19242-1-dmantipov@yandex.ru
---
fs/resctrl/rdtgroup.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 5dcbb0a..68be9b9 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2858,7 +2858,7 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
{
struct resctrl_schema *s;
const char *suffix = "";
- int ret, cl;
+ int cl;
s = kzalloc_obj(*s);
if (!s)
@@ -2882,14 +2882,12 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
break;
}
- ret = snprintf(s->name, sizeof(s->name), "%s%s", r->name, suffix);
- if (ret >= sizeof(s->name)) {
+ cl = snprintf(s->name, sizeof(s->name), "%s%s", r->name, suffix);
+ if (cl >= sizeof(s->name)) {
kfree(s);
return -EINVAL;
}
- cl = strlen(s->name);
-
/*
* If CDP is supported by this resource, but not enabled,
* include the suffix. This ensures the tabular format of the
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-09-17 21:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-21 8:11 [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add() Dmitry Antipov
2026-08-21 8:11 ` [PATCH v2 2/2] fs/resctrl: Simplify pseudo_lock_measure_trigger() Dmitry Antipov
2026-08-25 18:25 ` Reinette Chatre
2026-09-17 21:26 ` [tip: x86/cache] " tip-bot2 for Dmitry Antipov
2026-08-25 18:25 ` [PATCH v2 1/2] fs/resctrl: Avoid extra call to strlen() in schemata_list_add() Reinette Chatre
2026-09-03 15:42 ` Reinette Chatre
2026-09-17 15:54 ` Borislav Petkov
2026-09-17 16:17 ` Reinette Chatre
2026-09-17 17:37 ` Borislav Petkov
2026-09-17 21:26 ` [tip: x86/cache] " tip-bot2 for Dmitry Antipov
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®