Skip to contentSkip to conversation

trace_stat: keep original order

PATCH In review Lai Jiangshan 3 participants 5 messages Mar 25, 2009 – Mar 26, 2009 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 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.

---

kernel/trace/trace_stat.c +8 -10
index f71b85b..c08e7f1 100644
@@ -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);
Acked-by on v1 1/2
#1 lore raw
Quoted 39 lines · Lai Jiangshan

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.

---

kernel/trace/trace_stat.c +4 -10
index f71b85b..c08e7f1 100644
@@ -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);

kernel/trace/trace_stat.c static int stat_seq_init(struct tracer_stat_session *session) · line 145

Quoted 10 lines
kernel/trace/trace_stat.c +4 -0
 				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);

Nice!

#2 lore raw
In reply to Lai Jiangshan
Quoted 8 lines · Lai Jiangshan

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.

This doesn't reverse the order of the annotated branch profiler, does it?

-- Steve

Quoted 40 lines

---

kernel/trace/trace_stat.c +8 -10
index f71b85b..c08e7f1 100644
@@ -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);
#3 lore raw
Quoted 6 lines · Steven Rostedt
Quoted 5 lines · Lai Jiangshan

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.

Quoted 7 lines
Quoted 3 lines

Example, when we read trace_stat/workqueues, we get cpu#7's stat. at first, and then cpu#6... cpu#0.

This doesn't reverse the order of the annotated branch profiler, does it?

The annotated ftrace_branch_data are orderless. So it's OK with or without this fix.

(From code, not test) If this fix applied, __start_annotated_branch_profile is shown at the first, and then __start_annotated_branch_profile + 1... and __stop_annotated_branch_profile is shown at the last.

Lai

#4 lore raw
In reply to Lai Jiangshan
Commit-ID:  220ba351dfa57eca4bec5ce0098a276446a47958
Gitweb:     http://git.kernel.org/tip/220ba351dfa57eca4bec5ce0098a276446a47958
Author:     Lai Jiangshan <[email protected]>
AuthorDate: Wed, 25 Mar 2009 16:58:39 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 25 Mar 2009 18:32:34 +0100

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.

LKML-Reference: <[email protected]>

---
 kernel/trace/trace_stat.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
kernel/trace/trace_stat.c +8 -10
index 8c129dd..acdebd7 100644
@@ -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);