lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTiksAkqrMtVDgxhm5s+jqMaKoUhbTaWsXfKJ9QOy@mail.gmail.com>
Date:	Fri, 17 Dec 2010 01:15:44 +1100
From:	Nick Piggin <npiggin@...il.com>
To:	Boaz Harrosh <bharrosh@...asas.com>
Cc:	David Miller <davem@...emloft.net>, hooanon05@...oo.co.jp,
	npiggin@...nel.dk, torvalds@...ux-foundation.org,
	linux-arch@...r.kernel.org, x86@...nel.org,
	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: Big git diff speedup by avoiding x86 "fast string" memcmp

On Fri, Dec 17, 2010 at 1:03 AM, Boaz Harrosh <bharrosh@...asas.com> wrote:
> On 12/16/2010 03:13 PM, Nick Piggin wrote:
> static inline int dentry_memcmp_long(const unsigned char *cs,
>                                const unsigned char *ct, ssize_t count)
> {
>        int ret;
>        const unsigned long *ls = (const unsigned long *)cs;
>        const unsigned long *lt = (const unsigned long *)ct;
>
>        while (count > 8) {
>                ret = (*cs != *ct);
>                if (ret)
>                        break;
>                cs++;
>                ct++;
>                count-=8;
>        }
>        if (count) {
>                unsigned long t = *ct & ((0xffffffffffffffff >> ((8 - count) * 8))
>                ret = (*cs != t)
>        }
>
>        return ret;
> }
>
> Same as yours but just to avoid the branch inside the loop
> and slightly smaller code.

That's true, it should make the branch more predictable too. Well,
maybe. I'm going to leave it as-is for now, but I would welcome any
test results or ideas for improvements.


> BTW: On some ARCHs ++foo is faster than foo++
>     and Also, is there a reason not to write the above loop as:
>
>     while(c-- && (ret = (*cs++ != *ct++)))
>                ;

gcc should turn it into the same thing these days. I prefer avoiding
expressions with side effects in control statements (other than a
simple counter).

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ