Re: Big git diff speedup by avoiding x86 "fast string" memcmp

From: Nick Piggin
Date: Thu Dec 09 2010 - 21:38:14 EST


On Thu, Dec 09, 2010 at 02:37:09PM +0100, Borislav Petkov wrote:
> On Thu, Dec 09, 2010 at 06:09:38PM +1100, Nick Piggin wrote:
> > +static inline int dentry_memcmp(const unsigned char *cs,
> > + const unsigned char *ct, size_t count)
> > +{
> > + while (count) {
> > + int ret = (*cs != *ct);
> > + if (ret)
> > + return ret;
> > + cs++;
> > + ct++;
> > + count--;
> > + }
> > + return 0;
> > +}
>
> we have a memcmp() in lib/string.c. Maybe reuse it from there?

Well I think I prefer it to be inline so it doesn't clobber registers,
and also so that it isn't required to carry an integer value to return
(only boolean) if that might help.

I might also change it a bit and take advantage of the fact we won't
have a zero sized count -- this could move the loop branch to after the
values are loaded, and would mean that the load will get underway
even if the branch is mispredicted...

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