On Mon, Apr 13, 2015 at 06:49:49PM +0200, Ingo Molnar wrote:
> * Peter Zijlstra <pet...@infradead.org> wrote:

> > +static __always_inline int
> > +mod_tree_comp(void *key, struct latch_tree_node *n)
> > +{
> > +   unsigned long val = (unsigned long)key;
> > +   unsigned long start, end;
> > +
> > +   end = start = __mod_tree_val(n);
> > +   end += __mod_tree_size(n);
> > +
> > +   if (val < start)
> > +           return -1;
> > +
> > +   if (val >= end)
> > +           return 1;
> > +
> > +   return 0;
> 
> So since we are counting nanoseconds, I suspect this could be written 
> more optimally as:
> 
> {
>       unsigned long val = (unsigned long)key;
>       unsigned long start, end;
> 
>       start = __mod_tree_val(n);
>       if (val < start)
>               return -1;
> 
>       end = start + __mod_tree_size(n);
>       if (val >= end)
>               return 1;
> 
>       return 0;
> }
> 
> right?

I was afraid it would rip apart the common bits of
__mod_tree_{val,size}(), iow. it would end up doing the whole
latch_tree_node -> mod_tree_node -> mod and mtn_init comparison dance
twice.

But GCC does the right thing, so yes.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to