Commit 19fb518c authored by Dmitry Adamushko's avatar Dmitry Adamushko Committed by Ingo Molnar

latencytop: optimize LT_BACKTRACEDEPTH loops a bit

There is no need to loop any longer when 'same == 0'.
Signed-off-by: default avatarDmitry Adamushko <dmitry.adamushko@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 50df5d6a
...@@ -64,8 +64,8 @@ account_global_scheduler_latency(struct task_struct *tsk, struct latency_record ...@@ -64,8 +64,8 @@ account_global_scheduler_latency(struct task_struct *tsk, struct latency_record
return; return;
for (i = 0; i < MAXLR; i++) { for (i = 0; i < MAXLR; i++) {
int q; int q, same = 1;
int same = 1;
/* Nothing stored: */ /* Nothing stored: */
if (!latency_record[i].backtrace[0]) { if (!latency_record[i].backtrace[0]) {
if (firstnonnull > i) if (firstnonnull > i)
...@@ -73,12 +73,15 @@ account_global_scheduler_latency(struct task_struct *tsk, struct latency_record ...@@ -73,12 +73,15 @@ account_global_scheduler_latency(struct task_struct *tsk, struct latency_record
continue; continue;
} }
for (q = 0 ; q < LT_BACKTRACEDEPTH ; q++) { for (q = 0 ; q < LT_BACKTRACEDEPTH ; q++) {
if (latency_record[i].backtrace[q] != unsigned long record = lat->backtrace[q];
lat->backtrace[q])
if (latency_record[i].backtrace[q] != record) {
same = 0; same = 0;
if (same && lat->backtrace[q] == 0)
break; break;
if (same && lat->backtrace[q] == ULONG_MAX) }
/* 0 and ULONG_MAX entries mean end of backtrace: */
if (record == 0 || record == ULONG_MAX)
break; break;
} }
if (same) { if (same) {
...@@ -143,14 +146,18 @@ account_scheduler_latency(struct task_struct *tsk, int usecs, int inter) ...@@ -143,14 +146,18 @@ account_scheduler_latency(struct task_struct *tsk, int usecs, int inter)
for (i = 0; i < LT_SAVECOUNT ; i++) { for (i = 0; i < LT_SAVECOUNT ; i++) {
struct latency_record *mylat; struct latency_record *mylat;
int same = 1; int same = 1;
mylat = &tsk->latency_record[i]; mylat = &tsk->latency_record[i];
for (q = 0 ; q < LT_BACKTRACEDEPTH ; q++) { for (q = 0 ; q < LT_BACKTRACEDEPTH ; q++) {
if (mylat->backtrace[q] != unsigned long record = lat.backtrace[q];
lat.backtrace[q])
if (mylat->backtrace[q] != record) {
same = 0; same = 0;
if (same && lat.backtrace[q] == 0)
break; break;
if (same && lat.backtrace[q] == ULONG_MAX) }
/* 0 and ULONG_MAX entries mean end of backtrace: */
if (record == 0 || record == ULONG_MAX)
break; break;
} }
if (same) { if (same) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment