lkml.org 
[lkml]   [2016]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64
    From
    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

    \
     
     \ /
      Last update: 2016-02-04 23:41    [W:9.159 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site