]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
trace_stat: keep original order
authorLai Jiangshan <laijs@cn.fujitsu.com>
Wed, 25 Mar 2009 08:58:39 +0000 (16:58 +0800)
committerIngo Molnar <mingo@elte.hu>
Wed, 25 Mar 2009 17:32:34 +0000 (18:32 +0100)
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>
kernel/trace/trace_stat.c

index 8c129dd480ade8b17fff243b92487c74db580bb6..acdebd771a93b9623e57b8ed922c988524254ba7 100644 (file)
@@ -125,23 +125,21 @@ static int stat_seq_init(struct tracer_stat_session *session)
                INIT_LIST_HEAD(&new_entry->list);
                new_entry->stat = stat;
 
-               list_for_each_entry(iter_entry, &session->stat_list, list) {
+               list_for_each_entry_reverse(iter_entry, &session->stat_list,
+                               list) {
 
                        /* Insertion with a descendent sorting */
-                       if (ts->stat_cmp(new_entry->stat,
-                                               iter_entry->stat) > 0) {
+                       if (ts->stat_cmp(iter_entry->stat,
+                                       new_entry->stat) >= 0) {
 
-                               list_add_tail(&new_entry->list,
-                                               &iter_entry->list);
-                               break;
-
-                       /* The current smaller value */
-                       } else if (list_is_last(&iter_entry->list,
-                                               &session->stat_list)) {
                                list_add(&new_entry->list, &iter_entry->list);
                                break;
                        }
                }
+
+               /* The current larger value */
+               if (list_empty(&new_entry->list))
+                       list_add(&new_entry->list, &session->stat_list);
        }
 exit:
        mutex_unlock(&session->stat_mutex);