Re: [PATCH 01/18] flag parameters: helper function

From: Davide Libenzi
Date: Mon May 05 2008 - 22:09:50 EST


On Mon, 5 May 2008, Andrew Morton wrote:

> > +int flags_remap(const struct flags_rmap *m, int n,
> > + int f, int *rf)
> > +{
> > + int i;
> > + for (i = 0, *rf = 0; f && i < n; i++, m++)
> > + if (f & m->f) {
> > + *rf |= m->of;
> > + f &= ~m->f;
> > + }
> > + return f;
> > +}
>
> hm, that looks expensive. The compiler will need to generate a deref of m
> and rf multiple times around the loop. Copying them into locals does
> improve that a lot.

That's not a fast path. The extra cycles in the ldr/str get lost in the
overall syscall cost. But I guess Uli (or myself afterward) can change it
if you fill picky about it ;)



> I'm only on [1/18] so I don't know how often this code gets executed. If
> it's "on each open" then ouch, perhaps it might even be worth investigating a
> table-based implementation.
>
> Also: sorry, but ugh-at-the-naming. We don't *gain* anything from having
> idenitifers called f, of, m, n and rf. And we lose quite a lot in
> readability and understandability. It would be much nicer to invest a
> little bit more typing-time here, IMO.

Why? Don't you like nibble-sized variable names? :)
Uli took my email-code as is, so either he changes it, or I'll post
patches over it later.




- Davide


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