tracing/user_events: More efficient data output in user_seq_show()
Subsystems (2)
cover tracing/user_events: More efficient data output in user_seq_show()
From: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 14:00:56 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Simplify data output
Use seq_putc()
Replace a seq_printf() call by seq_puts()
kernel/trace/trace_events_user.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.54.0
PATCH 1/3 tracing/user_events: Simplify data output in user_seq_show()
From: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 13:33:43 +0200
Move the specification for a line break from a seq_puts() call to a seq_printf() call.
The source code was transformed by using the Coccinelle software.
--- kernel/trace/trace_events_user.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/trace/trace_events_user.c +1 -2
@@ -2800,8 +2800,7 @@ static int user_seq_show(struct seq_file *m, void *p)mutex_unlock (&group->reg_mutex); -seq_puts (m,"\n" ); -seq_printf (m,"Active: %d\n" , active); +seq_printf (m,"\nActive: %d\n" , active);seq_printf (m,"Busy: %d\n" , busy);return 0 ;
Signature · 1 line
2.54.0
Steven Rostedt
maintainerRe: [PATCH 1/3] tracing/user_events: Simplify data output in user_seq_show()
kernel/trace/trace_events_user.c static int user_seq_show(struct seq_file *m, void *p) · line 2804
Quoted 10 lines · On Thu, 4 Jun 2026 14:07:45 +0200 Markus Elfring <[email protected]> wrote:
kernel/trace/trace_events_user.c +1
-2@@ -2800,8 +2800,7 @@ static int user_seq_show(struct seq_file *m, void *p)mutex_unlock (&group->reg_mutex); -seq_puts (m,"\n" ); -seq_printf (m,"Active: %d\n" , active); +seq_printf (m,"\nActive: %d\n" , active);seq_printf (m,"Busy: %d\n" , busy);
This isn't a critical section and I find the original way easier to read. But the other two patches are fine.
-- Steve
Re: [PATCH 1/3] tracing/user_events: Simplify data output in user_seq_show()
Quoted 10 lines
kernel/trace/trace_events_user.c static int user_seq_show(struct seq_file *m, void *p) · line 2804
Quoted 8 lines
kernel/trace/trace_events_user.c +1
-2@@ -2800,8 +2800,7 @@ static int user_seq_show(struct seq_file *m, void *p)mutex_unlock (&group->reg_mutex); -seq_puts (m,"\n" ); -seq_printf (m,"Active: %d\n" , active); +seq_printf (m,"\nActive: %d\n" , active);seq_printf (m,"Busy: %d\n" , busy);This isn't a critical section and I find the original way easier to read.
Would you prefer to use a seq_putc() call instead at such a source code place?
https://elixir.bootlin.com/linux/v7.1-rc7/source/kernel/trace/trace_events_user.c#L2803
Quoted 1 line
But the other two patches are fine.
Thanks for another bit of positive feedback.
Regards,
Markus
Steven Rostedt
maintainerRe: [PATCH 1/3] tracing/user_events: Simplify data output in user_seq_show()
Quoted 11 lines · On Tue, 9 Jun 2026 18:44:04 +0200 Markus Elfring <[email protected]> wrote:
Quoted 10 lines
kernel/trace/trace_events_user.c static int user_seq_show(struct seq_file *m, void *p) · line 2804
Quoted 8 lines
kernel/trace/trace_events_user.c +1
-2@@ -2800,8 +2800,7 @@ static int user_seq_show(struct seq_file *m, void *p)mutex_unlock (&group->reg_mutex); -seq_puts (m,"\n" ); -seq_printf (m,"Active: %d\n" , active); +seq_printf (m,"\nActive: %d\n" , active);seq_printf (m,"Busy: %d\n" , busy);This isn't a critical section and I find the original way easier to read.
Quoted 2 lines
Would you prefer to use a
seq_putc()call instead at such a source code place?
https://elixir.bootlin.com/linux/v7.1-rc7/source/kernel/trace/trace_events_user.c#L2803
Sure, why not.
-- Steve
v2 cover tracing/user_events: More efficient data output in two functions
From: Markus Elfring <[email protected]>
Date: Mon, 22 Jun 2026 16:58:32 +0200
Two update suggestions were taken into account from static source code analysis.
Markus Elfring (2):
Use seq_putc() in two functions
Replace a seq_printf() call by seq_puts() in user_seq_show()
v2:
Steven Rostedt requested to use seq_putc() calls more often.
kernel/trace/trace_events_user.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.54.0
PATCH v2 1/2 tracing/user_events: Use seq_putc() in two functions
From: Markus Elfring <[email protected]>
Date: Mon, 22 Jun 2026 16:37:18 +0200
Single characters should be put into a sequence. Thus use the corresponding function “seq_putc” for selected calls.
The source code was transformed by using the Coccinelle software.
--- kernel/trace/trace_events_user.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/trace/trace_events_user.c +4 -4
@@ -1813,7 +1813,7 @@ static int user_event_show(struct seq_file *m, struct dyn_event *ev)list_for_each_entry_reverse (field, head, link) {if (depth ==0 ) -seq_puts (m," " ); +seq_putc (m,' ' );else seq_puts (m,"; " );
@@ -1825,7 +1825,7 @@ static int user_event_show(struct seq_file *m, struct dyn_event *ev) depth++; } -seq_puts (m,"\n" ); +seq_putc (m,'\n' );return 0 ; }
@@ -2794,13 +2794,13 @@ static int user_seq_show(struct seq_file *m, void *p) busy++; } -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); active++; }mutex_unlock (&group->reg_mutex); -seq_puts (m,"\n" ); +seq_putc (m,'\n' );seq_printf (m,"Active: %d\n" , active);seq_printf (m,"Busy: %d\n" , busy);
Signature · 1 line
2.54.0
PATCH v2 2/2 tracing/user_events: Replace a seq_printf() call by seq_puts() in user_seq_show()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 22 Jun 2026 16:42:07 +0200
A single string should be put into a sequence within a loop. Thus use the corresponding function “seq_puts” for one selected call.
The source code was transformed by using the Coccinelle software.
--- kernel/trace/trace_events_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_user.c +1 -1
@@ -2781,7 +2781,7 @@ static int user_seq_show(struct seq_file *m, void *p)hash_for_each (group->register_table, i, user, node) { status = user->status; -seq_printf (m,"%s" ,EVENT_TP_NAME (user)); +seq_puts (m,EVENT_TP_NAME (user));if (status !=0 ) {seq_puts (m," # Used by" );
Signature · 1 line
2.54.0
PATCH 2/3 tracing/user_events: Use seq_putc() in user_seq_show()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 13:40:38 +0200
A line break should be put into a sequence within a loop. Thus use the corresponding function “seq_putc” for one selected call.
The source code was transformed by using the Coccinelle software.
--- kernel/trace/trace_events_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_user.c +1 -1
@@ -2794,7 +2794,7 @@ static int user_seq_show(struct seq_file *m, void *p) busy++; } -seq_puts (m,"\n" ); +seq_putc (m,'\n' ); active++; }
Signature · 1 line
2.54.0
PATCH 3/3 tracing/user_events: Replace a seq_printf() call by seq_puts() in user_seq_show()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 4 Jun 2026 13:45:48 +0200
A single string should be put into a sequence within a loop. Thus use the corresponding function “seq_puts” for one selected call.
The source code was transformed by using the Coccinelle software.
--- kernel/trace/trace_events_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_user.c +1 -1
@@ -2781,7 +2781,7 @@ static int user_seq_show(struct seq_file *m, void *p)hash_for_each (group->register_table, i, user, node) { status = user->status; -seq_printf (m,"%s" ,EVENT_TP_NAME (user)); +seq_puts (m,EVENT_TP_NAME (user));if (status !=0 ) {seq_puts (m," # Used by" );
Signature · 1 line
2.54.0