Skip to content

Commit 220ba35

Browse files
Lai JiangshanIngo Molnar
authored andcommitted
trace_stat: keep original order
Impact: make trace_stat files show items with the original order trace_stat tracer reverse the items, it makes the output looks a little ugly. Example, when we read trace_stat/workqueues, we get cpu#7's stat. at first, and then cpu#6... cpu#0. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Acked-by: Steven Rostedt <srostedt@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <49C9F23F.5040307@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent e6f4890 commit 220ba35

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

‎kernel/trace/trace_stat.c‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,21 @@ static int stat_seq_init(struct tracer_stat_session *session)
125125
INIT_LIST_HEAD(&new_entry->list);
126126
new_entry->stat = stat;
127127

128-
list_for_each_entry(iter_entry, &session->stat_list, list) {
128+
list_for_each_entry_reverse(iter_entry, &session->stat_list,
129+
list) {
129130

130131
/* Insertion with a descendent sorting */
131-
if (ts->stat_cmp(new_entry->stat,
132-
iter_entry->stat) > 0) {
132+
if (ts->stat_cmp(iter_entry->stat,
133+
new_entry->stat) >= 0) {
133134

134-
list_add_tail(&new_entry->list,
135-
&iter_entry->list);
136-
break;
137-
138-
/* The current smaller value */
139-
} else if (list_is_last(&iter_entry->list,
140-
&session->stat_list)) {
141135
list_add(&new_entry->list, &iter_entry->list);
142136
break;
143137
}
144138
}
139+
140+
/* The current larger value */
141+
if (list_empty(&new_entry->list))
142+
list_add(&new_entry->list, &session->stat_list);
145143
}
146144
exit:
147145
mutex_unlock(&session->stat_mutex);

0 commit comments

Comments
 (0)