Skip to content

Commit a943188

Browse files
Eric Vaughnrostedt
authored andcommitted
tracing/user_events: Optimize safe list traversals
Several of the list traversals in the user_events facility use safe list traversals where they could be using the unsafe versions instead. Replace these safe traversals with their unsafe counterparts in the interest of optimization. Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Suggested-by: Beau Belgrave <[email protected]> Signed-off-by: Eric Vaughn <[email protected]> Acked-by: Beau Belgrave <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent c8f05f2 commit a943188

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

kernel/trace/trace_events_user.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,14 +1328,14 @@ static int user_field_set_string(struct ftrace_event_field *field,
13281328

13291329
static int user_event_set_print_fmt(struct user_event *user, char *buf, int len)
13301330
{
1331-
struct ftrace_event_field *field, *next;
1331+
struct ftrace_event_field *field;
13321332
struct list_head *head = &user->fields;
13331333
int pos = 0, depth = 0;
13341334
const char *str_func;
13351335

13361336
pos += snprintf(buf + pos, LEN_OR_ZERO, "\"");
13371337

1338-
list_for_each_entry_safe_reverse(field, next, head, link) {
1338+
list_for_each_entry_reverse(field, head, link) {
13391339
if (depth != 0)
13401340
pos += snprintf(buf + pos, LEN_OR_ZERO, " ");
13411341

@@ -1347,7 +1347,7 @@ static int user_event_set_print_fmt(struct user_event *user, char *buf, int len)
13471347

13481348
pos += snprintf(buf + pos, LEN_OR_ZERO, "\"");
13491349

1350-
list_for_each_entry_safe_reverse(field, next, head, link) {
1350+
list_for_each_entry_reverse(field, head, link) {
13511351
if (user_field_is_dyn_string(field->type, &str_func))
13521352
pos += snprintf(buf + pos, LEN_OR_ZERO,
13531353
", %s(%s)", str_func, field->name);
@@ -1732,15 +1732,15 @@ static int user_event_create(const char *raw_command)
17321732
static int user_event_show(struct seq_file *m, struct dyn_event *ev)
17331733
{
17341734
struct user_event *user = container_of(ev, struct user_event, devent);
1735-
struct ftrace_event_field *field, *next;
1735+
struct ftrace_event_field *field;
17361736
struct list_head *head;
17371737
int depth = 0;
17381738

17391739
seq_printf(m, "%s%s", USER_EVENTS_PREFIX, EVENT_NAME(user));
17401740

17411741
head = trace_get_fields(&user->call);
17421742

1743-
list_for_each_entry_safe_reverse(field, next, head, link) {
1743+
list_for_each_entry_reverse(field, head, link) {
17441744
if (depth == 0)
17451745
seq_puts(m, " ");
17461746
else
@@ -1816,13 +1816,14 @@ static bool user_field_match(struct ftrace_event_field *field, int argc,
18161816
static bool user_fields_match(struct user_event *user, int argc,
18171817
const char **argv)
18181818
{
1819-
struct ftrace_event_field *field, *next;
1819+
struct ftrace_event_field *field;
18201820
struct list_head *head = &user->fields;
18211821
int i = 0;
18221822

1823-
list_for_each_entry_safe_reverse(field, next, head, link)
1823+
list_for_each_entry_reverse(field, head, link) {
18241824
if (!user_field_match(field, argc, argv, &i))
18251825
return false;
1826+
}
18261827

18271828
if (i != argc)
18281829
return false;

0 commit comments

Comments
 (0)