Re: latencytop: optimize LT_BACKTRACEDEPTH loops a bit

From: Arjan van de Ven
Date: Sat Feb 02 2008 - 19:13:36 EST


Dmitry Adamushko wrote:
Subject: latencytop: optimize LT_BACKTRACEDEPTH loops a bit.

It looks like there is no need to loop any longer when 'same == 0'.

thanks for the contribution!
while I like your patch, I wonder if we should go even a little further in
cleaning this up

@@ -73,12 +73,12 @@ account_global_scheduler_latency(struct task_struct *tsk, struct latency_record
continue;
}
for (q = 0 ; q < LT_BACKTRACEDEPTH ; q++) {
- if (latency_record[i].backtrace[q] !=
- lat->backtrace[q])
+ unsigned long record = lat->backtrace[q];
+
+ if (latency_record[i].backtrace[q] != record)
same = 0;
- if (same && lat->backtrace[q] == 0)
- break;
- if (same && lat->backtrace[q] == ULONG_MAX)
+
+ if (!same || record == 0 || record == ULONG_MAX)
break;
}

I mean, we could make it look like this:

if (latency_record[i].backtrace[q] != record) {
same = 0;
break;
}
/* 0 and ULONG_MAX entries denote the end of backtrace */
if (record == 0)
break;
if (record == ULONG_MAX)
break;


to me at least this is a bit more readable/simple than the good first step you've
already taken..
Do you want to do it this way? I'd sure encourage/endorse such a patch...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/