All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Anton Blanchard <anton@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	Linus Torvalds <torvalds@transmeta.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [patch] O(1) scheduler, -D1, 2.5.2-pre9, 2.4.17
Date: Wed, 9 Jan 2002 17:09:28 -0800	[thread overview]
Message-ID: <20020109170928.A4365@twiddle.net> (raw)
In-Reply-To: <20020108114355.GA25718@krispykreme> <Pine.LNX.4.33.0201081533270.7255-100000@localhost.localdomain> <20020109231513.GA10002@krispykreme>
In-Reply-To: <20020109231513.GA10002@krispykreme>; from anton@samba.org on Thu, Jan 10, 2002 at 10:15:14AM +1100

On Thu, Jan 10, 2002 at 10:15:14AM +1100, Anton Blanchard wrote:
> I expect most architectures have a reasonably fast find_first_zero_bit
> so they can simply do:
> 
> static inline int sched_find_first_zero_bit(unsigned long *bitmap)
> {
> 	return find_first_zero_bit(bitmap, MAX_PRIO);
> }

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;
}

It compiles down to 

        ldq $2,0($16)
        ldq $3,8($16)
        lda $5,128($31)
        ldq $0,16($16)
        and $2,$3,$1
        ornot $31,$2,$4
        ornot $31,$1,$1
        bne $1,$L8
$L2:
        ornot $31,$0,$0
        cttz $0,$0
        addl $0,$5,$0
        ret $31,($26),1
$L8:
        mov $2,$0
        cmpult $31,$4,$5
        cmovne $4,$3,$0
        sll $5,6,$5
        br $31,$L2

which is a fair bit better than find_first_zero_bit if for
no other reason than we collect all the memory accesses
right up at the beginning.

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.


r~

  reply	other threads:[~2002-01-10  1:09 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200201071922.g07JMN106760@penguin.transmeta.com>
2002-01-07 21:36 ` [patch] O(1) scheduler, -D1, 2.5.2-pre9, 2.4.17 Ingo Molnar
2002-01-08  8:49   ` FD Cami
2002-01-08 18:44     ` J Sloan
2002-01-08 11:32   ` Anton Blanchard
2002-01-08 11:43     ` Anton Blanchard
2002-01-08 14:34       ` Ingo Molnar
2002-01-09 23:15         ` Anton Blanchard
2002-01-10  1:09           ` Richard Henderson [this message]
2002-01-10 17:04             ` Ivan Kokshaysky
2002-01-10 20:42               ` george anzinger
2002-01-10 23:56               ` Ingo Molnar
2002-01-08 14:32     ` [patch] O(1) scheduler, -E1, 2.5.2-pre10, 2.4.17 Ingo Molnar
2002-01-07 20:24 [patch] O(1) scheduler, -D1, 2.5.2-pre9, 2.4.17 Ingo Molnar
2002-01-07 19:03 ` Brian Gerst
2002-01-07 21:19   ` Ingo Molnar
2002-01-09  3:39 ` Mike Kravetz
2002-01-09  5:05   ` Davide Libenzi
2002-01-09  3:32     ` Rusty Russell
2002-01-09 18:02       ` Davide Libenzi
2002-01-09 11:37     ` Ingo Molnar
2002-01-09 11:19       ` Rene Rebe
2002-01-09 15:34         ` Ryan Cumming
2002-01-09 18:24       ` Davide Libenzi
2002-01-09 21:24         ` Ingo Molnar
2002-01-09 19:38           ` Mike Kravetz
2002-01-10 18:21             ` Mike Kravetz
2002-01-10 19:08               ` Davide Libenzi
2002-01-10 19:09                 ` Linus Torvalds
2002-01-10 21:08                   ` Davide Libenzi
2002-01-10 19:15                 ` Mike Kravetz
2002-01-10 20:05                   ` Davide Libenzi
2002-01-09 22:34           ` Mark Hahn
2002-01-10 14:04             ` Ingo Molnar
2002-01-09 20:15       ` Linus Torvalds
2002-01-09 23:02         ` Ingo Molnar
2002-01-09  6:29   ` Brian
2002-01-09  6:40     ` Jeffrey W. Baker
2002-01-09  6:45     ` Ryan Cumming
2002-01-09  6:48     ` Ryan Cumming
2002-01-09 10:25   ` Ingo Molnar
2002-01-09 17:40     ` Mike Kravetz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020109170928.A4365@twiddle.net \
    --to=rth@twiddle.net \
    --cc=anton@samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.