Messages in this thread | | | Date | Tue, 27 Aug 2002 20:33:19 +0200 | From | Willy Tarreau <> | Subject | Re: [PATCH] sched.c |
| |
On Tue, Aug 27, 2002 at 09:15:03PM +0300, Lahti Oy wrote:
> - for (i = 0; i < NR_CPUS; i++) > + for (i = NR_CPUS; i; i--) > sum += cpu_rq(i)->nr_running;
you change isn't equivalent : previously, we called cpu_rq() for 0..NR_CPUS-1, and now you call it for 1..NR_CPUS.
You should have written : + for (i = NR_CPUS - 1; i>=0; i--) which might still be a win towards the former version. But of course, this is only valid if i is SIGNED, and it isn't here. Another valid form which would work with unsigned int is : + for (i = NR_CPUS; i--; )
but I'm not sure it will save some cycles because increments/decrements within conditions are not always well optimizable.
Same comments for other locations.
Cheers, Willy
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |