Re: [RFCv2][PATCH] flexible array implementation

From: Dave Hansen
Date: Wed Jul 22 2009 - 18:03:52 EST


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

--
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/