RE: [PATCH] include/asm-ARCH/page.h:get_order() Reorganize and op

Perez-Gonzalez, Inaky (inaky.perez-gonzalez@intel.com)
Wed, 13 Nov 2002 16:43:37 -0800


> > > > s = --s >> PAGE_SHIFT;
> > >
> > > This code has undefined behaviour.
> >
> > Do you mean that this:
> >
> > s = (s-1) >> PAGE_SHIFT
> >
> > is more deterministic? If so, I agree -- if you mean something else,
> > I am kind of lost.
>
> I mean that this code violates the rule that you may modify a value
> only once between two sequence points. Newer gccs have a warning for
> this (-Wsequence-point), the info page tells more.

Agreed, and it was a poor choice from me. (s-1) should be correct,
and gcc-3.2 with -Wsequence-point is happy about it.

> Also, did I understand it right that you want to use fls even on
> architectures that don't have it as a builtin? I would guess that will
> actually be noticeably slower, since generic_fls is so complicated.

Well, it is not that bad, and it is still faster [did a quick test now]

0.144s, 0.241s and 0.358s

[get_order on all numbers from 0 to 90000000 with the optimized version,
the one that uses generic_fls and the old one].

Inaky Perez-Gonzalez -- Not speaking for Intel - opinions are my own [or my
fault]

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