diff options
author | Dmitry Adamushko <dmitry.adamushko@gmail.com> | 2008-02-17 16:34:07 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-19 13:44:57 -0400 |
commit | 19fb518c2a0c5d88ed22bba7083b7e7bc2a9c231 (patch) | |
tree | 4233d31e9124110fe73aa83cb3ec4c390924d448 /kernel/latencytop.c | |
parent | 50df5d6aea6694ca481b8005900401e8c95c2603 (diff) |
latencytop: optimize LT_BACKTRACEDEPTH loops a bit
There is no need to loop any longer when 'same == 0'.
Signed-off-by: Dmitry Adamushko <dmitry.adamushko@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/latencytop.c')
-rw-r--r-- | kernel/latencytop.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/kernel/latencytop.c b/kernel/latencytop.c index b4e3c85abe74..7c74dab0d21b 100644 --- a/kernel/latencytop.c +++ b/kernel/latencytop.c | |||
@@ -64,8 +64,8 @@ account_global_scheduler_latency(struct task_struct *tsk, struct latency_record | |||
64 | return; | 64 | return; |
65 | 65 | ||
66 | for (i = 0; i < MAXLR; i++) { | 66 | for (i = 0; i < MAXLR; i++) { |
67 | int q; | 67 | int q, same = 1; |
68 | int same = 1; | 68 | |
69 | /* Nothing stored: */ | 69 | /* Nothing stored: */ |
70 | if (!latency_record[i].backtrace[0]) { | 70 | if (!latency_record[i].backtrace[0]) { |
71 | if (firstnonnull > i) | 71 | if (firstnonnull > i) |
@@ -73,12 +73,15 @@ account_global_scheduler_latency(struct task_struct *tsk, struct latency_record | |||
73 | continue; | 73 | continue; |
74 | } | 74 | } |
75 | for (q = 0 ; q < LT_BACKTRACEDEPTH ; q++) { | 75 | for (q = 0 ; q < LT_BACKTRACEDEPTH ; q++) { |
76 | if (latency_record[i].backtrace[q] != | 76 | unsigned long record = lat->backtrace[q]; |
77 | lat->backtrace[q]) | 77 | |
78 | if (latency_record[i].backtrace[q] != record) { | ||
78 | same = 0; | 79 | same = 0; |
79 | if (same && lat->backtrace[q] == 0) | ||
80 | break; | 80 | break; |
81 | if (same && lat->backtrace[q] == ULONG_MAX) | 81 | } |
82 | |||
83 | /* 0 and ULONG_MAX entries mean end of backtrace: */ | ||
84 | if (record == 0 || record == ULONG_MAX) | ||
82 | break; | 85 | break; |
83 | } | 86 | } |
84 | if (same) { | 87 | if (same) { |
@@ -143,14 +146,18 @@ account_scheduler_latency(struct task_struct *tsk, int usecs, int inter) | |||
143 | for (i = 0; i < LT_SAVECOUNT ; i++) { | 146 | for (i = 0; i < LT_SAVECOUNT ; i++) { |
144 | struct latency_record *mylat; | 147 | struct latency_record *mylat; |
145 | int same = 1; | 148 | int same = 1; |
149 | |||
146 | mylat = &tsk->latency_record[i]; | 150 | mylat = &tsk->latency_record[i]; |
147 | for (q = 0 ; q < LT_BACKTRACEDEPTH ; q++) { | 151 | for (q = 0 ; q < LT_BACKTRACEDEPTH ; q++) { |
148 | if (mylat->backtrace[q] != | 152 | unsigned long record = lat.backtrace[q]; |
149 | lat.backtrace[q]) | 153 | |
154 | if (mylat->backtrace[q] != record) { | ||
150 | same = 0; | 155 | same = 0; |
151 | if (same && lat.backtrace[q] == 0) | ||
152 | break; | 156 | break; |
153 | if (same && lat.backtrace[q] == ULONG_MAX) | 157 | } |
158 | |||
159 | /* 0 and ULONG_MAX entries mean end of backtrace: */ | ||
160 | if (record == 0 || record == ULONG_MAX) | ||
154 | break; | 161 | break; |
155 | } | 162 | } |
156 | if (same) { | 163 | if (same) { |