public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats
@ 2026-02-22 20:40 Thorsten Blum
  0 siblings, 0 replies; 5+ messages in thread
From: Thorsten Blum @ 2026-02-22 20:40 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long
  Cc: Thorsten Blum, linux-kernel

Replace snprintf("%s", ...) with the faster and more direct strscpy().

Reviewed-by: Waiman Long <longman@redhat.com>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 kernel/locking/lockdep_proc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index 1916db9aa46b..e458fa258d05 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -19,6 +19,7 @@
 #include <linux/debug_locks.h>
 #include <linux/vmalloc.h>
 #include <linux/sort.h>
+#include <linux/string.h>
 #include <linux/uaccess.h>
 #include <asm/div64.h>
 
@@ -488,9 +489,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
 		const char *key_name;
 
 		key_name = __get_key_name(ckey, str);
-		snprintf(name, namelen, "%s", key_name);
+		strscpy(name, key_name, namelen);
 	} else {
-		snprintf(name, namelen, "%s", cname);
+		strscpy(name, cname, namelen);
 	}
 	rcu_read_unlock_sched();
 
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats
@ 2026-03-18  0:14 Thorsten Blum
  2026-03-18 15:43 ` Waiman Long
  2026-03-18 20:37 ` Peter Zijlstra
  0 siblings, 2 replies; 5+ messages in thread
From: Thorsten Blum @ 2026-03-18  0:14 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long
  Cc: Thorsten Blum, linux-kernel

Replace snprintf("%s", ...) with the faster and more direct strscpy().

Reviewed-by: Waiman Long <longman@redhat.com>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 kernel/locking/lockdep_proc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index 1916db9aa46b..e458fa258d05 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -19,6 +19,7 @@
 #include <linux/debug_locks.h>
 #include <linux/vmalloc.h>
 #include <linux/sort.h>
+#include <linux/string.h>
 #include <linux/uaccess.h>
 #include <asm/div64.h>
 
@@ -488,9 +489,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
 		const char *key_name;
 
 		key_name = __get_key_name(ckey, str);
-		snprintf(name, namelen, "%s", key_name);
+		strscpy(name, key_name, namelen);
 	} else {
-		snprintf(name, namelen, "%s", cname);
+		strscpy(name, cname, namelen);
 	}
 	rcu_read_unlock_sched();
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats
  2026-03-18  0:14 Thorsten Blum
@ 2026-03-18 15:43 ` Waiman Long
  2026-03-18 16:44   ` Boqun Feng
  2026-03-18 20:37 ` Peter Zijlstra
  1 sibling, 1 reply; 5+ messages in thread
From: Waiman Long @ 2026-03-18 15:43 UTC (permalink / raw)
  To: Thorsten Blum, Peter Zijlstra, Ingo Molnar, Will Deacon,
	Boqun Feng
  Cc: linux-kernel


On 3/17/26 8:14 PM, Thorsten Blum wrote:
> Replace snprintf("%s", ...) with the faster and more direct strscpy().
>
> Reviewed-by: Waiman Long <longman@redhat.com>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>   kernel/locking/lockdep_proc.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
> index 1916db9aa46b..e458fa258d05 100644
> --- a/kernel/locking/lockdep_proc.c
> +++ b/kernel/locking/lockdep_proc.c
> @@ -19,6 +19,7 @@
>   #include <linux/debug_locks.h>
>   #include <linux/vmalloc.h>
>   #include <linux/sort.h>
> +#include <linux/string.h>
>   #include <linux/uaccess.h>
>   #include <asm/div64.h>
>   
> @@ -488,9 +489,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
>   		const char *key_name;
>   
>   		key_name = __get_key_name(ckey, str);
> -		snprintf(name, namelen, "%s", key_name);
> +		strscpy(name, key_name, namelen);
>   	} else {
> -		snprintf(name, namelen, "%s", cname);
> +		strscpy(name, cname, namelen);
>   	}
>   	rcu_read_unlock_sched();
>   
>
Acked-by: Waiman Long <longman@redhat.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats
  2026-03-18 15:43 ` Waiman Long
@ 2026-03-18 16:44   ` Boqun Feng
  0 siblings, 0 replies; 5+ messages in thread
From: Boqun Feng @ 2026-03-18 16:44 UTC (permalink / raw)
  To: Waiman Long
  Cc: Thorsten Blum, Peter Zijlstra, Ingo Molnar, Will Deacon,
	linux-kernel

On Wed, Mar 18, 2026 at 11:43:49AM -0400, Waiman Long wrote:
> 
> On 3/17/26 8:14 PM, Thorsten Blum wrote:
> > Replace snprintf("%s", ...) with the faster and more direct strscpy().
> > 
> > Reviewed-by: Waiman Long <longman@redhat.com>
> > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> > ---
> >   kernel/locking/lockdep_proc.c | 5 +++--
> >   1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
> > index 1916db9aa46b..e458fa258d05 100644
> > --- a/kernel/locking/lockdep_proc.c
> > +++ b/kernel/locking/lockdep_proc.c
> > @@ -19,6 +19,7 @@
> >   #include <linux/debug_locks.h>
> >   #include <linux/vmalloc.h>
> >   #include <linux/sort.h>
> > +#include <linux/string.h>
> >   #include <linux/uaccess.h>
> >   #include <asm/div64.h>
> > @@ -488,9 +489,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
> >   		const char *key_name;
> >   		key_name = __get_key_name(ckey, str);
> > -		snprintf(name, namelen, "%s", key_name);
> > +		strscpy(name, key_name, namelen);
> >   	} else {
> > -		snprintf(name, namelen, "%s", cname);
> > +		strscpy(name, cname, namelen);
> >   	}
> >   	rcu_read_unlock_sched();
> > 
> Acked-by: Waiman Long <longman@redhat.com>
> 

Queued, thank you both!

Regards,
Boqun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats
  2026-03-18  0:14 Thorsten Blum
  2026-03-18 15:43 ` Waiman Long
@ 2026-03-18 20:37 ` Peter Zijlstra
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2026-03-18 20:37 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long, linux-kernel

On Wed, Mar 18, 2026 at 01:14:27AM +0100, Thorsten Blum wrote:
> Replace snprintf("%s", ...) with the faster and more direct strscpy().
> 
> Reviewed-by: Waiman Long <longman@redhat.com>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  kernel/locking/lockdep_proc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
> index 1916db9aa46b..e458fa258d05 100644
> --- a/kernel/locking/lockdep_proc.c
> +++ b/kernel/locking/lockdep_proc.c
> @@ -19,6 +19,7 @@
>  #include <linux/debug_locks.h>
>  #include <linux/vmalloc.h>
>  #include <linux/sort.h>
> +#include <linux/string.h>
>  #include <linux/uaccess.h>
>  #include <asm/div64.h>
>  
> @@ -488,9 +489,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
>  		const char *key_name;
>  
>  		key_name = __get_key_name(ckey, str);
> -		snprintf(name, namelen, "%s", key_name);
> +		strscpy(name, key_name, namelen);
>  	} else {
> -		snprintf(name, namelen, "%s", cname);
> +		strscpy(name, cname, namelen);
>  	}
>  	rcu_read_unlock_sched();

Why though? I suppose it doesn't matter, but this hardly seems worth the
electrons is was sent with :/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-18 20:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-22 20:40 [PATCH RESEND] locking/lockdep: Replace snprintf with strscpy in seq_stats Thorsten Blum
  -- strict thread matches above, loose matches on Subject: below --
2026-03-18  0:14 Thorsten Blum
2026-03-18 15:43 ` Waiman Long
2026-03-18 16:44   ` Boqun Feng
2026-03-18 20:37 ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox