Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1327224

Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64

From Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64
Date 2016-02-04 23:10 +0100
Message-ID <qYAga-84a-17@gated-at.bofh.it> (permalink)
References <qYoyn-6KS-25@gated-at.bofh.it> <qYoyn-6KS-23@gated-at.bofh.it> <qYzWN-7GJ-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Feb 4, 2016 at 1:46 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
>         static const unsigned long mask[9] = {
>                 0x0000000000000000,
>                 0x000000000000ff00,
>                 0x000000000000ffff,
>                 0x00000000ff00ffff,
>                 0x00000000ffffffff,
>                 0x0000ff00ffffffff,
>                 0x0000ffffffffffff,
>                 0xff00ffffffffffff,
>                 0xffffffffffffffff };
>         unsigned long val = load_unaligned_zeropad(buf + (len & 1));
>         val &= mask[len];

Yeah, that was buggy. I knew it was likely buggy,  but that "buf +
(len & 1)" was just stupid.

The "+" should be "-", of course - the point is to shift up the value
by 8 bits for odd cases, and we need to load starting one byte early
for that. The idea is that we use the byte shifter in the load unit to
do some work for us.

And the bitmasks are the wrong way around for the odd cases - it's the
low byte that ends up being bogus for those cases.

So it should probably look something like

        static const unsigned long mask[9] = {
                0x0000000000000000,
                0x000000000000ff00,
                0x000000000000ffff,
                0x00000000ffffff00,
                0x00000000ffffffff,
                0x0000ffffffffff00,
                0x0000ffffffffffff,
                0xffffffffffffff00,
                0xffffffffffffffff };
        unsigned long val = load_unaligned_zeropad(buf - (len & 1));
        val &= mask[len];

and then it *might* work.

Still entirely and utterly untested, I just decided to look at it a
bit more and noticed my thinko.

                Linus

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Ingo Molnar <mingo@kernel.org> - 2016-02-04 10:40 +0100
  Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Ingo Molnar <mingo@kernel.org> - 2016-02-04 12:00 +0100
    Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Tom Herbert <tom@herbertland.com> - 2016-02-04 20:30 +0100
      Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Ingo Molnar <mingo@kernel.org> - 2016-02-05 10:30 +0100
  Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Linus Torvalds <torvalds@linux-foundation.org> - 2016-02-04 22:50 +0100
    Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Linus Torvalds <torvalds@linux-foundation.org> - 2016-02-04 23:10 +0100
      Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Linus Torvalds <torvalds@linux-foundation.org> - 2016-02-05 02:30 +0100
        Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Linus Torvalds <torvalds@linux-foundation.org> - 2016-02-05 02:40 +0100
    Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Tom Herbert <tom@herbertland.com> - 2016-02-04 23:50 +0100
      Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Linus Torvalds <torvalds@linux-foundation.org> - 2016-02-05 00:00 +0100
      Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Ingo Molnar <mingo@kernel.org> - 2016-02-05 09:10 +0100
        RE: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 David Laight <David.Laight@ACULAB.COM> - 2016-02-05 11:20 +0100

csiph-web