lkml.org 
[lkml]   [2008]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: latencytop: optimize LT_BACKTRACEDEPTH loops a bit
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...


\
 
 \ /
  Last update: 2008-02-03 01:15    [W:0.225 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site