Re: [RFC][PATCH] flex_array: conditionally optimize out divides

From: Dave Hansen
Date: Tue Aug 18 2009 - 17:30:37 EST


On Tue, 2009-08-18 at 11:02 -0700, Dan Williams wrote:
> > + return flex_array_get_precalc(fa, part_nr, index_inside);
> > +}
> > +
> > +static inline int flex_array_put_es(struct flex_array *fa, int element_nr,
> > + int element_size, void *src, gfp_t flags)
> > +{
> > + int part_nr = __fa_element_to_part_nr(element_size, element_nr);
> > + int index_inside = __fa_index_inside_part(element_size, element_nr);
> > +
> > + if (element_nr >= fa->total_nr_elements)
> > + return -ENOSPC;
>
> ...and this one look like good candidates for unlikely() as these
> additional branches may be a concern for the fast path.

Personally, I think those macros are grossly overused. I'm loathe to
use them unless there's actual profiling data showing that they make an
appreciable performance improvement or that the generated code is
unquestionably better.

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/