[lkml]   [2002]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] sched.c
Lahti Oy wrote:
> Small patch that makes NR_CPUS loops decrement from 31 to 0 in sched.c to
> squeeze out some cycles (of course only on SMP machines). Also deprecated a
> macro that was only used once in the code and changed one if-conditional to
> else if.
> ...
> - for (i = 0; i < NR_CPUS; i++)
> + for (i = NR_CPUS; i; i--)
> sum += cpu_rq(i)->nr_running;

Off-by-one there. You'd want

for (i = NR_CPUS; --i >= 0; )

or something similarly foul ;)

But these are not performance-critical functions. And by far the
most inefficient part of them is that they're reading data for
CPUs which cannot exist. That can be fixed with a `cpu_possible(i)'
test in there, but Rusty was going to give us a `for_each_cpu' macro.
We haven't seen that yet.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:22    [W:0.930 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site