aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-sched.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-09-12 19:56:25 -0400
committerIngo Molnar <mingo@elte.hu>2009-09-13 04:22:47 -0400
commit66685678a03d0d8e8ba015472f280fb4f12f84c1 (patch)
tree60e9cbe8809c0977bf02e3257116d4a296ff798b /tools/perf/builtin-sched.c
parentc6ced61112f1e6139914149fab65695801a74f0f (diff)
perf sched: Export the total, max latency and total runtime to thread atoms list
Add a field in the thread atom list that keeps track of the total and max latencies and also the total runtime. This makes a faster output and also prepares for sorting. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-sched.c')
-rw-r--r--tools/perf/builtin-sched.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 61a80e8c9d0d..435702702789 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -884,6 +884,10 @@ struct task_atoms {
884 struct list_head snapshot_list; 884 struct list_head snapshot_list;
885 struct thread *thread; 885 struct thread *thread;
886 struct rb_node node; 886 struct rb_node node;
887 u64 max_lat;
888 u64 total_lat;
889 u64 nb_atoms;
890 u64 total_runtime;
887}; 891};
888 892
889static struct rb_root lat_snapshot_root; 893static struct rb_root lat_snapshot_root;
@@ -985,6 +989,7 @@ static void
985lat_sched_in(struct task_atoms *atoms, u64 timestamp) 989lat_sched_in(struct task_atoms *atoms, u64 timestamp)
986{ 990{
987 struct work_atom *snapshot; 991 struct work_atom *snapshot;
992 u64 delta;
988 993
989 if (list_empty(&atoms->snapshot_list)) 994 if (list_empty(&atoms->snapshot_list))
990 return; 995 return;
@@ -1002,6 +1007,13 @@ lat_sched_in(struct task_atoms *atoms, u64 timestamp)
1002 1007
1003 snapshot->state = THREAD_SCHED_IN; 1008 snapshot->state = THREAD_SCHED_IN;
1004 snapshot->sched_in_time = timestamp; 1009 snapshot->sched_in_time = timestamp;
1010
1011 delta = snapshot->sched_in_time - snapshot->wake_up_time;
1012 atoms->total_lat += delta;
1013 if (delta > atoms->max_lat)
1014 atoms->max_lat = delta;
1015 atoms->nb_atoms++;
1016 atoms->total_runtime += snapshot->runtime;
1005} 1017}
1006 1018
1007static void 1019static void
@@ -1099,43 +1111,27 @@ static u64 all_count;
1099 1111
1100static void output_lat_thread(struct task_atoms *atom_list) 1112static void output_lat_thread(struct task_atoms *atom_list)
1101{ 1113{
1102 struct work_atom *atom;
1103 int count = 0;
1104 int i; 1114 int i;
1105 int ret; 1115 int ret;
1106 u64 max = 0, avg; 1116 u64 avg;
1107 u64 total = 0, delta;
1108 u64 total_runtime = 0;
1109
1110 list_for_each_entry(atom, &atom_list->snapshot_list, list) {
1111 total_runtime += atom->runtime;
1112
1113 if (atom->state != THREAD_SCHED_IN)
1114 continue;
1115
1116 count++;
1117 1117
1118 delta = atom->sched_in_time - atom->wake_up_time; 1118 if (!atom_list->nb_atoms)
1119 if (delta > max)
1120 max = delta;
1121 total += delta;
1122 }
1123
1124 all_runtime += total_runtime;
1125 all_count += count;
1126
1127 if (!count)
1128 return; 1119 return;
1129 1120
1121 all_runtime += atom_list->total_runtime;
1122 all_count += atom_list->nb_atoms;
1123
1130 ret = printf(" %s ", atom_list->thread->comm); 1124 ret = printf(" %s ", atom_list->thread->comm);
1131 1125
1132 for (i = 0; i < 19 - ret; i++) 1126 for (i = 0; i < 19 - ret; i++)
1133 printf(" "); 1127 printf(" ");
1134 1128
1135 avg = total / count; 1129 avg = atom_list->total_lat / atom_list->nb_atoms;
1136 1130
1137 printf("|%9.3f ms |%9d | avg:%9.3f ms | max:%9.3f ms |\n", 1131 printf("|%9.3f ms |%9llu | avg:%9.3f ms | max:%9.3f ms |\n",
1138 (double)total_runtime/1e9, count, (double)avg/1e9, (double)max/1e9); 1132 (double)atom_list->total_runtime / 1e9,
1133 atom_list->nb_atoms, (double)avg / 1e9,
1134 (double)atom_list->max_lat / 1e9);
1139} 1135}
1140 1136
1141static void __cmd_lat(void) 1137static void __cmd_lat(void)