locking/lockdep: Use seq_putc() in five functions
Subsystems (2)
PATCH 1/1 locking/lockdep: Use seq_putc() in five functions
From: Markus Elfring <[email protected]>
Date: Sun, 14 Jul 2024 12:18:16 +0200
Single characters should be put into a sequence.
Thus use the corresponding function “seq_putc”.
This issue was transformed by using the Coccinelle software.
--- kernel/locking/lockdep_proc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
kernel/locking/lockdep_proc.c +12 -12
@@ -101,17 +101,17 @@ static int l_show(struct seq_file *m, void *v)seq_printf (m,": " );print_name (m, class); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );if (IS_ENABLED (CONFIG_PROVE_LOCKING )) {list_for_each_entry (entry, &class->locks_after, entry) {if (entry->distance ==1 ) {seq_printf (m," -> [%p] " , entry->class->key);print_name (m, entry->class); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); } } -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); }return 0 ;
@@ -175,9 +175,9 @@ static int lc_show(struct seq_file *m, void *v)seq_printf (m,"[%p] " , class->key);print_name (m, class); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); } -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
@@ -379,7 +379,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v)/* * Zapped classes and lockdep data buffers reuse statistics. */ -seq_puts (m,"\n" ); +seq_putc (m,'\n' );seq_printf (m," zapped classes: %11lu\n" , nr_zapped_classes);#ifdef CONFIG_PROVE_LOCKING
@@ -422,10 +422,10 @@ static void seq_line(struct seq_file *m, char c, int offset, int length)int i;for (i =0 ; i < offset; i++) -seq_puts (m," " ); +seq_putc (m,' ' );for (i =0 ; i < length; i++)seq_printf (m,"%c" , c); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); }static void snprint_time (char *buf,size_t bufsiz,s64 nr)
@@ -512,7 +512,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)seq_lock_time (m, &stats->write_waittime);seq_printf (m," %14lu " , stats->bounces[bounce_acquired_write]);seq_lock_time (m, &stats->write_holdtime); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); }if (stats->read_holdtime.nr) {
@@ -521,7 +521,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)seq_lock_time (m, &stats->read_waittime);seq_printf (m," %14lu " , stats->bounces[bounce_acquired_read]);seq_lock_time (m, &stats->read_holdtime); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); }if (stats->read_waittime.nr + stats->write_waittime.nr ==0 )
@@ -561,9 +561,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data) ip, (void *)class->contending_point[i]); }if (i) { -seq_puts (m,"\n" ); +seq_putc (m,'\n' );seq_line (m,'.' ,0 ,40 +1 +12 * (14 +1 )); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); } }
--
2.45.2
Quoted 103 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 14 Jul 2024 12:18:16 +0200Single characters should be put into a sequence.
Thus use the corresponding function “seq_putc”.This issue was transformed by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- kernel/locking/lockdep_proc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)kernel/locking/lockdep_proc.c +12
-13@@ -101,17 +101,17 @@ static int l_show(struct seq_file *m, void *v)seq_printf (m,": " );print_name (m, class); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );if (IS_ENABLED (CONFIG_PROVE_LOCKING )) {list_for_each_entry (entry, &class->locks_after, entry) {if (entry->distance ==1 ) {seq_printf (m," -> [%p] " , entry->class->key);print_name (m, entry->class); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); } } -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); }return 0 ;@@ -175,9 +175,9 @@ static int lc_show(struct seq_file *m, void *v)seq_printf (m,"[%p] " , class->key);print_name (m, class); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); } -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }@@ -379,7 +379,7 @@ static int lockdep_stats_show(struct seq_file *m, void *v)/* * Zapped classes and lockdep data buffers reuse statistics. */ -seq_puts (m,"\n" ); +seq_putc (m,'\n' );seq_printf (m," zapped classes: %11lu\n" , nr_zapped_classes);#ifdef CONFIG_PROVE_LOCKING @@ -422,10 +422,10 @@ static void seq_line(struct seq_file *m, char c, int offset, int length)int i;for (i =0 ; i < offset; i++) -seq_puts (m," " ); +seq_putc (m,' ' );for (i =0 ; i < length; i++)seq_printf (m,"%c" , c); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); }static void snprint_time (char *buf,size_t bufsiz,s64 nr)@@ -512,7 +512,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)seq_lock_time (m, &stats->write_waittime);seq_printf (m," %14lu " , stats->bounces[bounce_acquired_write]);seq_lock_time (m, &stats->write_holdtime); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); }if (stats->read_holdtime.nr) {@@ -521,7 +521,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)seq_lock_time (m, &stats->read_waittime);seq_printf (m," %14lu " , stats->bounces[bounce_acquired_read]);seq_lock_time (m, &stats->read_holdtime); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); }if (stats->read_waittime.nr + stats->write_waittime.nr ==0 )@@ -561,9 +561,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data) ip, (void *)class->contending_point[i]); }if (i) { -seq_puts (m,"\n" ); +seq_putc (m,'\n' );seq_line (m,'.' ,0 ,40 +1 +12 * (14 +1 )); -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); } } --
Quoted 2 lines
2.45.2
Le 14/07/2024 à 23:31, Waiman Long a écrit :
Quoted 11 lines · Markus Elfring
Quoted 10 lines
From: Markus Elfring <[email protected]>
Date: Sun, 14 Jul 2024 12:18:16 +0200Single characters should be put into a sequence.
Thus use the corresponding function “seq_putc”.This issue was transformed by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
...
Quoted 7 lines
kernel/locking/lockdep_proc.c static void seq_line(struct seq_file *m, char c, · line 426
Quoted 7 lines
kernel/locking/lockdep_proc.c +1
-1@@ -422,10 +422,10 @@ static void seq_line(struct seq_file *m, char c, int offset, int length) int i; for (i = 0; i < offset; i++) - seq_puts(m, " "); + seq_putc(m, ' ');
Hi,
Most of the time, this kind of modification is useless because it is already done by the compiler, see [1].
Quoted 2 lines
kernel/locking/lockdep_proc.c static void seq_line(struct seq_file *m, char c, int offset, int length) · line 427
Quoted 2 lines
kernel/locking/lockdep_proc.c +0
-0for (i = 0; i < length; i++) seq_printf(m, "%c", c);
But changing this seq_printf() into a seq_putc() would, IMHO, make sense and save a few cycles, should it matter.
CJ
[1]: https://elixir.bootlin.com/linux/v6.10-rc7/source/include/linux/seq_file.h#L123
Quoted 4 lines
Quoted 4 lines
kernel/locking/lockdep_proc.c +1
-1- seq_puts(m, "\n"); + seq_putc(m, '\n'); }
...
Quoted 5 lines
Quoted 3 lines
Signature · 1 line
2.45.2Acked-by Waiman Long <[email protected]>
PATCH 1/1 locking/lockdep: Simplify character output in seq_line()
From: Markus Elfring <[email protected]>
Date: Mon, 15 Jul 2024 10:42:17 +0200
Single characters should be put into a sequence.
Thus use the corresponding function “seq_putc” for one selected call.
This issue was transformed by using the Coccinelle software.
--- kernel/locking/lockdep_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/lockdep_proc.c +1 -1
@@ -424,7 +424,7 @@ static void seq_line(struct seq_file *m, char c, int offset, int length)for (i =0 ; i < offset; i++)seq_puts (m," " );for (i =0 ; i < length; i++) -seq_printf (m,"%c" , c); +seq_putc (m, c);seq_puts (m,"\n" ); }
--
2.45.2
Re: [PATCH] locking/lockdep: Simplify character output in seq_line()
Quoted 10 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 15 Jul 2024 10:42:17 +0200Single characters should be put into a sequence.
Thus use the corresponding function “seq_putc” for one selected call.This issue was transformed by using the Coccinelle software.
Suggested-by Christophe Jaillet <[email protected]>Signed-off-by Markus Elfring <[email protected]>
Queued this at:
https://git.kernel.org/pub/scm/linux/kernel/git/boqun/linux.git/ lockdep-for-tip
Thanks! And given Christophe's comment, the original one is not needed, so drop it.
Regards,
Boqun
Quoted 20 lines
--- kernel/locking/lockdep_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/locking/lockdep_proc.c +1
-2@@ -424,7 +424,7 @@ static void seq_line(struct seq_file *m, char c, int offset, int length)for (i =0 ; i < offset; i++)seq_puts (m," " );for (i =0 ; i < length; i++) -seq_printf (m,"%c" , c); +seq_putc (m, c);seq_puts (m,"\n" ); } --2.45.2
[tip: locking/core] locking/lockdep: Simplify character output in seq_line()
In reply to Markus ElfringThe following commit has been merged into the locking/core branch of tip:
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 39dea484e2bb9066abbc01e2c5e03b6917b0b775 Gitweb: https://git.kernel.org/tip/39dea484e2bb9066abbc01e2c5e03b6917b0b775 Author: Markus Elfring <[email protected]> AuthorDate: Mon, 15 Jul 2024 10:42:17 +02:00 Committer: Boqun Feng <[email protected]> CommitterDate: Tue, 06 Aug 2024 10:46:43 -07:00
locking/lockdep: Simplify character output in seq_line()
Single characters should be put into a sequence.
Thus use the corresponding function “seq_putc” for one selected call.
This issue was transformed by using the Coccinelle software.
--- kernel/locking/lockdep_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/lockdep_proc.c +1 -1
@@ -424,7 +424,7 @@ static void seq_line(struct seq_file *m, char c, int offset, int length)for (i =0 ; i < offset; i++)seq_puts (m," " );for (i =0 ; i < length; i++) -seq_printf (m,"%c" , c); +seq_putc (m, c);seq_puts (m,"\n" ); }