lkml.org 
[lkml]   [2015]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 07/10] module: Optimize __module_address() using a latched RB-tree
On Mon, Apr 13, 2015 at 06:49:49PM +0200, Ingo Molnar wrote:
> * Peter Zijlstra <peterz@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.


\
 
 \ /
  Last update: 2015-04-14 15:01    [W:0.082 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site