Re: [patch] O(1) scheduler, -D1, 2.5.2-pre9, 2.4.17

Ivan Kokshaysky
2002-01-10T17:05:27Z

On Wed, Jan 09, 2002 at 05:09:28PM -0800, Richard Henderson wrote:
> Careful. The following is really quite a bit better on Alpha:
>
> static inline int
> sched_find_first_zero_bit(unsigned long *bitmap)
> {
> unsigned long b0 = bitmap[0];
> unsigned long b1 = bitmap[1];
> unsigned long b2 = bitmap[2];
> unsigned long ofs = MAX_RT_PRIO;
>
> if (unlikely(~(b0 & b1) != 0)) {
> b2 = (~b0 == 0 ? b0 : b1);
> ofs = (~b0 == 0 ? 0 : 64);
> }
>
> return ffz(b2) + ofs;
> }

True. Minor correction:
- b2 = (~b0 == 0 ? b0 : b1);
- ofs = (~b0 == 0 ? 0 : 64);
+ b2 = (~b0 ? b0 : b1);
+ ofs = (~b0 ? 0 : 64);

Note that comment for this function is a bit confusing:
* ... It's the fastest
* way of searching a 168-bit bitmap where the first 128 bits are
* unlikely to be set.

s/set/cleared/

> While we're on the subject of sched_find_first_zero_bit, I'd
> like to complain about Ingo's choice of header file. Why in
> the world did you choose mmu_context.h? Invent a new asm/sched.h
> if you must, but please don't choose headers at random.

Agreed. Apparently asm/bitops.h?

Ivan.