On Tue, Apr 22, 2008 at 04:56:10PM +0200, Eric Dumazet wrote:
> Andrea Arcangeli a écrit :
>> +
>> +static int mm_lock_cmp(const void *a, const void *b)
>> +{
>> + cond_resched();
>> + if ((unsigned long)*(spinlock_t **)a <
>> + (unsigned long)*(spinlock_t **)b)
>> + return -1;
>> + else if (a == b)
>> + return 0;
>> + else
>> + return 1;
>> +}
>> +
> This compare function looks unusual...
> It should work, but sort() could be faster if the
> if (a == b) test had a chance to be true eventually...
Hmm, are you saying my mm_lock_cmp won't return 0 if a==b?
> static int mm_lock_cmp(const void *a, const void *b)
> {
> unsigned long la = (unsigned long)*(spinlock_t **)a;
> unsigned long lb = (unsigned long)*(spinlock_t **)b;
>
> cond_resched();
> if (la < lb)
> return -1;
> if (la > lb)
> return 1;
> return 0;
> }
If your intent is to use the assumption that there are going to be few
equal entries, you should have used likely(la > lb) to signal it's
rarely going to return zero or gcc is likely free to do whatever it
wants with the above. Overall that function is such a slow path that
this is going to be lost in the noise. My suggestion would be to defer
microoptimizations like this after 1/12 will be applied to mainline.
Thanks!
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel