[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240326184645.8660-1-Maxim.Moskalets@kaspersky.com>
Date: Tue, 26 Mar 2024 21:46:45 +0300
From: Maxim Moskalets <maximmosk4@...il.com>
To: linux-kernel@...r.kernel.org
Cc: maximmosk4@...il.com,
Maxim Moskalets <Maxim.Moskalets@...persky.com>
Subject: [PATCH 3/8] trace: replace seq_puts by seq_putc
Using seq_putc for single characters is faster and more appropriate
than seq_puts, since only one character is passed and there is no need
to use a more powerful and less fast function.
Signed-off-by: Maxim Moskalets <Maxim.Moskalets@...persky.com>
---
kernel/trace/trace_events_hist.c | 26 +++++++++++++-------------
kernel/trace/trace_events_user.c | 8 ++++----
kernel/trace/trace_hwlat.c | 4 ++--
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 6ece1308d36a..5992278cbfb5 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -4898,14 +4898,14 @@ static void print_action_spec(struct seq_file *m,
for (i = 0; i < hist_data->n_save_vars; i++) {
seq_printf(m, "%s", hist_data->save_vars[i]->var->var.name);
if (i < hist_data->n_save_vars - 1)
- seq_puts(m, ",");
+ seq_putc(m, ',');
}
} else if (data->action == ACTION_TRACE) {
if (data->use_trace_keyword)
seq_printf(m, "%s", data->synth_event_name);
for (i = 0; i < data->n_params; i++) {
if (i || data->use_trace_keyword)
- seq_puts(m, ",");
+ seq_putc(m, ',');
seq_printf(m, "%s", data->params[i]);
}
}
@@ -4924,7 +4924,7 @@ static void print_track_data_spec(struct seq_file *m,
print_action_spec(m, hist_data, data);
- seq_puts(m, ")");
+ seq_putc(m, ')');
}
static void print_onmatch_spec(struct seq_file *m,
@@ -4938,7 +4938,7 @@ static void print_onmatch_spec(struct seq_file *m,
print_action_spec(m, hist_data, data);
- seq_puts(m, ")");
+ seq_putc(m, ')');
}
static bool actions_match(struct hist_trigger_data *hist_data,
@@ -5413,9 +5413,9 @@ static void hist_trigger_print_key(struct seq_file *m,
}
if (!multiline)
- seq_puts(m, " ");
+ seq_putc(m, ' ');
- seq_puts(m, "}");
+ seq_putc(m, '}');
}
/* Get the 100 times of the percentage of @val in @total */
@@ -5511,13 +5511,13 @@ static void hist_trigger_entry_print(struct seq_file *m,
if (flags & HIST_FIELD_FL_VAR || flags & HIST_FIELD_FL_EXPR)
continue;
- seq_puts(m, " ");
+ seq_putc(m, ' ');
hist_trigger_print_val(m, i, field_name, flags, stats, elt);
}
print_actions(m, hist_data, elt);
- seq_puts(m, "\n");
+ seq_putc(m, '\n');
}
static int print_entries(struct seq_file *m,
@@ -5971,7 +5971,7 @@ static int event_hist_trigger_print(struct seq_file *m,
field = hist_data->fields[i];
if (i > hist_data->n_vals)
- seq_puts(m, ",");
+ seq_putc(m, ',');
if (field->flags & HIST_FIELD_FL_STACKTRACE) {
if (field->field)
@@ -5997,7 +5997,7 @@ static int event_hist_trigger_print(struct seq_file *m,
seq_puts(m, "hitcount");
} else {
if (show_val)
- seq_puts(m, ",");
+ seq_putc(m, ',');
hist_field_print(m, field);
}
show_val = true;
@@ -6006,14 +6006,14 @@ static int event_hist_trigger_print(struct seq_file *m,
if (have_var) {
unsigned int n = 0;
- seq_puts(m, ":");
+ seq_putc(m, ':');
for_each_hist_val_field(i, hist_data) {
field = hist_data->fields[i];
if (field->flags & HIST_FIELD_FL_VAR) {
if (n++)
- seq_puts(m, ",");
+ seq_putc(m, ',');
hist_field_print(m, field);
}
}
@@ -6035,7 +6035,7 @@ static int event_hist_trigger_print(struct seq_file *m,
return -EINVAL;
if (i > 0)
- seq_puts(m, ",");
+ seq_putc(m, ',');
if (idx == HITCOUNT_IDX)
seq_puts(m, "hitcount");
diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 70d428c394b6..762f8b4667ca 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -1823,7 +1823,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, "; ");
@@ -1835,7 +1835,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;
}
@@ -2733,13 +2733,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);
diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index b791524a6536..874a81cf9bb7 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -636,14 +636,14 @@ static int s_mode_show(struct seq_file *s, void *v)
seq_printf(s, "%s", thread_mode_str[mode]);
if (mode < MODE_MAX - 1) /* if mode is any but last */
- seq_puts(s, " ");
+ seq_putc(s, ' ');
return 0;
}
static void s_mode_stop(struct seq_file *s, void *v)
{
- seq_puts(s, "\n");
+ seq_putc(s, '\n');
mutex_unlock(&hwlat_data.lock);
}
--
2.39.2
Powered by blists - more mailing lists