Skip to contentSkip to conversation

tracing/user_events: More efficient data output in user_seq_show()

PATCH Superseded Markus Elfring 2 participants 10 messages Jun 4 – Jun 22

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index c4ba484f7b38..a089ac30e407 100644
@@ -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
maintainer
#2 lore raw

Re: [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

#3 lore raw

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

maintainer
#4 lore raw

Re: [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

#5 lore raw

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
#6 lore raw

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
index c4ba484f7b38..a79b7c07dabb 100644
@@ -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
#7 lore raw

PATCH v2 2/2 tracing/user_events: Replace a seq_printf() call by seq_puts() in user_seq_show()

In reply to Markus Elfring

From: 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
index a79b7c07dabb..ba9cc168280d 100644
@@ -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
#8 lore raw

PATCH 2/3 tracing/user_events: Use seq_putc() in user_seq_show()

In reply to Markus Elfring

From: 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
index a089ac30e407..1a0569110bfd 100644
@@ -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
#9 lore raw

PATCH 3/3 tracing/user_events: Replace a seq_printf() call by seq_puts() in user_seq_show()

In reply to Markus Elfring

From: 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
index 1a0569110bfd..57a78de4dc98 100644
@@ -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