[RFCv2][PATCH] flexible array implementation

Dave Hansen dave at linux.vnet.ibm.com
Wed Jul 22 15:03:26 PDT 2009


On Wed, 2009-07-22 at 11:30 -0700, Matt Helsley wrote:
> > +static int __check_part_and_nr(struct flex_array *fa,
> > +                            int part_nr, int element_nr)
> > +{
> > +     if (part_nr >= __nr_part_ptrs() ||
> > +         element_nr > fa->nr_elements) {
> > +             WARN(1, "bad flexible array element number: %d > %d\n",
> > +                     element_nr, fa->nr_elements);
> > +             return -EINVAL;
> > +     }
> > +     return 0;
> > +}
> 
> Should the above be inline? Does it make sense to optimize the "common"
> case and penalize inappropriate access by putting an unlikely() in
> there? Or is it too early for this stuff?

I think I'll leave it to the compiler for now.  Since we also don't have
a single user, I don't think we have an idea how hot of a path this
might get used in.

> I wonder how the *, /, and % ops will affect things that otherwise
> would have been reduced to shifts and masks -- especially on the
> "smaller" embedded archs.

I'm generally fine with rounding all these sizes to powers-of-two.  But,
I do think it's a wee bit premature at this point.

-- Dave



More information about the Containers mailing list