Subject: Re: Route cache performance under stress

From: Andi Kleen <[email-masked]>
Date: Fri, 23 May 2003 10:21:13 +0200

On Thu, 22 May 2003 18:01:52 -0700 (PDT)
"David S. Miller" <[email-masked]> wrote:

>    From: Martin Josefsson <[email-masked]>
>    Date: 22 May 2003 13:15:39 +0200
> 
>    On Thu, 2003-05-22 at 12:40, David S. Miller wrote:
>    
>    > +static unsigned long size_to_order(unsigned long size)
>    
>    Any reason you're not using get_order() ?
> 
> Actually, get_order() aparently only works on powers of
> two, which 'size' is definitely not.

Are you sure? I always used it on all kinds of sizes.

The algorithm looks for me like it works on any size. A quick test
confirms that too.

(i386 version)
static __inline__ int get_order(unsigned long size)
{
        int order;

        size = (size-1) >> (PAGE_SHIFT-1);
        order = -1;
        do {
                size >>= 1;
                order++;
        } while (size);
        return order;
}

-Andi