All of lore.kernel.org
 help / color / mirror / Atom feed
From: Noah Goldstein <goldstein.w.n@gmail.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Johannes Berg <johannes@sipsolutions.net>,
	alexanderduyck@fb.com, kbuild-all@lists.01.org,
	open list <linux-kernel@vger.kernel.org>,
	linux-um@lists.infradead.org, lkp@intel.com,
	peterz@infradead.org, X86 ML <x86@kernel.org>
Subject: Re: [tip:x86/core 1/1] arch/x86/um/../lib/csum-partial_64.c:98:12: error: implicit declaration of function 'load_unaligned_zeropad'
Date: Thu, 25 Nov 2021 00:47:46 -0600	[thread overview]
Message-ID: <CAFUsyfKx=444zNM40rVznS+=0YKxz2+O+qNA2NbiAv2Qs+Xhrg@mail.gmail.com> (raw)
In-Reply-To: <CANn89iLYHkyaLawrZJYuRETx63c0QWQ0kLGysPbGpWj2+C5Jfw@mail.gmail.com>

On Thu, Nov 25, 2021 at 12:32 AM Eric Dumazet <edumazet@google.com> wrote:
>
> On Wed, Nov 24, 2021 at 9:09 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> >
> >
> > Although I see slightly worse performance with aligned `buff`  in
> > the branch-free approach. Imagine if non-aligned `buff` is that
> > uncommon might be better to speculate past the work of `ror`.
>
> Yes, no clear win here removing the conditional (same cost really),
> although using a ror32() is removing the from32to16() helper and get
> rid of one folding.
>
> I will formally submit this change, thanks !

Great :)

Can you put me on the cc list? I have a patch for the function that I'll post
once yours gets through.

>
> diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c
> index 1eb8f2d11f7c785be624eba315fe9ca7989fd56d..cf4bd3ef66e56c681b3435d43011ece78438376d
> 100644
> --- a/arch/x86/lib/csum-partial_64.c
> +++ b/arch/x86/lib/csum-partial_64.c
> @@ -11,16 +11,6 @@
>  #include <asm/checksum.h>
>  #include <asm/word-at-a-time.h>
>
> -static inline unsigned short from32to16(unsigned a)
> -{
> -       unsigned short b = a >> 16;
> -       asm("addw %w2,%w0\n\t"
> -           "adcw $0,%w0\n"
> -           : "=r" (b)
> -           : "0" (b), "r" (a));
> -       return b;
> -}
> -
>  /*
>   * Do a checksum on an arbitrary memory area.
>   * Returns a 32bit checksum.
> @@ -41,6 +31,7 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
>         if (unlikely(odd)) {
>                 if (unlikely(len == 0))
>                         return sum;
> +               temp64 = ror32((__force u32)sum, 8);
>                 temp64 += (*(unsigned char *)buff << 8);
>                 len--;
>                 buff++;
> @@ -129,10 +120,8 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
>  #endif
>         }
>         result = add32_with_carry(temp64 >> 32, temp64 & 0xffffffff);
> -       if (unlikely(odd)) {
> -               result = from32to16(result);
> -               result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
> -       }
> +       if (unlikely(odd))
> +               result = ror32(result, 8);
>         return (__force __wsum)result;
>  }
>  EXPORT_SYMBOL(csum_partial);

WARNING: multiple messages have this Message-ID (diff)
From: Noah Goldstein <goldstein.w.n@gmail.com>
To: kbuild-all@lists.01.org
Subject: Re: [tip:x86/core 1/1] arch/x86/um/../lib/csum-partial_64.c:98:12: error: implicit declaration of function 'load_unaligned_zeropad'
Date: Thu, 25 Nov 2021 00:47:46 -0600	[thread overview]
Message-ID: <CAFUsyfKx=444zNM40rVznS+=0YKxz2+O+qNA2NbiAv2Qs+Xhrg@mail.gmail.com> (raw)
In-Reply-To: <CANn89iLYHkyaLawrZJYuRETx63c0QWQ0kLGysPbGpWj2+C5Jfw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2299 bytes --]

On Thu, Nov 25, 2021 at 12:32 AM Eric Dumazet <edumazet@google.com> wrote:
>
> On Wed, Nov 24, 2021 at 9:09 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> >
> >
> > Although I see slightly worse performance with aligned `buff`  in
> > the branch-free approach. Imagine if non-aligned `buff` is that
> > uncommon might be better to speculate past the work of `ror`.
>
> Yes, no clear win here removing the conditional (same cost really),
> although using a ror32() is removing the from32to16() helper and get
> rid of one folding.
>
> I will formally submit this change, thanks !

Great :)

Can you put me on the cc list? I have a patch for the function that I'll post
once yours gets through.

>
> diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c
> index 1eb8f2d11f7c785be624eba315fe9ca7989fd56d..cf4bd3ef66e56c681b3435d43011ece78438376d
> 100644
> --- a/arch/x86/lib/csum-partial_64.c
> +++ b/arch/x86/lib/csum-partial_64.c
> @@ -11,16 +11,6 @@
>  #include <asm/checksum.h>
>  #include <asm/word-at-a-time.h>
>
> -static inline unsigned short from32to16(unsigned a)
> -{
> -       unsigned short b = a >> 16;
> -       asm("addw %w2,%w0\n\t"
> -           "adcw $0,%w0\n"
> -           : "=r" (b)
> -           : "0" (b), "r" (a));
> -       return b;
> -}
> -
>  /*
>   * Do a checksum on an arbitrary memory area.
>   * Returns a 32bit checksum.
> @@ -41,6 +31,7 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
>         if (unlikely(odd)) {
>                 if (unlikely(len == 0))
>                         return sum;
> +               temp64 = ror32((__force u32)sum, 8);
>                 temp64 += (*(unsigned char *)buff << 8);
>                 len--;
>                 buff++;
> @@ -129,10 +120,8 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
>  #endif
>         }
>         result = add32_with_carry(temp64 >> 32, temp64 & 0xffffffff);
> -       if (unlikely(odd)) {
> -               result = from32to16(result);
> -               result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
> -       }
> +       if (unlikely(odd))
> +               result = ror32(result, 8);
>         return (__force __wsum)result;
>  }
>  EXPORT_SYMBOL(csum_partial);

WARNING: multiple messages have this Message-ID (diff)
From: Noah Goldstein <goldstein.w.n@gmail.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Johannes Berg <johannes@sipsolutions.net>,
	alexanderduyck@fb.com, kbuild-all@lists.01.org,
	open list <linux-kernel@vger.kernel.org>,
	linux-um@lists.infradead.org, lkp@intel.com,
	peterz@infradead.org, X86 ML <x86@kernel.org>
Subject: Re: [tip:x86/core 1/1] arch/x86/um/../lib/csum-partial_64.c:98:12: error: implicit declaration of function 'load_unaligned_zeropad'
Date: Thu, 25 Nov 2021 00:47:46 -0600	[thread overview]
Message-ID: <CAFUsyfKx=444zNM40rVznS+=0YKxz2+O+qNA2NbiAv2Qs+Xhrg@mail.gmail.com> (raw)
In-Reply-To: <CANn89iLYHkyaLawrZJYuRETx63c0QWQ0kLGysPbGpWj2+C5Jfw@mail.gmail.com>

On Thu, Nov 25, 2021 at 12:32 AM Eric Dumazet <edumazet@google.com> wrote:
>
> On Wed, Nov 24, 2021 at 9:09 PM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
> >
> >
> >
> > Although I see slightly worse performance with aligned `buff`  in
> > the branch-free approach. Imagine if non-aligned `buff` is that
> > uncommon might be better to speculate past the work of `ror`.
>
> Yes, no clear win here removing the conditional (same cost really),
> although using a ror32() is removing the from32to16() helper and get
> rid of one folding.
>
> I will formally submit this change, thanks !

Great :)

Can you put me on the cc list? I have a patch for the function that I'll post
once yours gets through.

>
> diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c
> index 1eb8f2d11f7c785be624eba315fe9ca7989fd56d..cf4bd3ef66e56c681b3435d43011ece78438376d
> 100644
> --- a/arch/x86/lib/csum-partial_64.c
> +++ b/arch/x86/lib/csum-partial_64.c
> @@ -11,16 +11,6 @@
>  #include <asm/checksum.h>
>  #include <asm/word-at-a-time.h>
>
> -static inline unsigned short from32to16(unsigned a)
> -{
> -       unsigned short b = a >> 16;
> -       asm("addw %w2,%w0\n\t"
> -           "adcw $0,%w0\n"
> -           : "=r" (b)
> -           : "0" (b), "r" (a));
> -       return b;
> -}
> -
>  /*
>   * Do a checksum on an arbitrary memory area.
>   * Returns a 32bit checksum.
> @@ -41,6 +31,7 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
>         if (unlikely(odd)) {
>                 if (unlikely(len == 0))
>                         return sum;
> +               temp64 = ror32((__force u32)sum, 8);
>                 temp64 += (*(unsigned char *)buff << 8);
>                 len--;
>                 buff++;
> @@ -129,10 +120,8 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
>  #endif
>         }
>         result = add32_with_carry(temp64 >> 32, temp64 & 0xffffffff);
> -       if (unlikely(odd)) {
> -               result = from32to16(result);
> -               result = ((result >> 8) & 0xff) | ((result & 0xff) << 8);
> -       }
> +       if (unlikely(odd))
> +               result = ror32(result, 8);
>         return (__force __wsum)result;
>  }
>  EXPORT_SYMBOL(csum_partial);

_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


  parent reply	other threads:[~2021-11-25  6:50 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17 18:45 [tip:x86/core 1/1] arch/x86/um/../lib/csum-partial_64.c:98:12: error: implicit declaration of function 'load_unaligned_zeropad' kernel test robot
2021-11-17 18:45 ` kernel test robot
2021-11-17 18:55 ` Eric Dumazet
2021-11-17 18:55   ` Eric Dumazet
2021-11-17 19:40   ` Eric Dumazet
2021-11-17 19:40     ` Eric Dumazet
2021-11-18 16:00     ` Peter Zijlstra
2021-11-18 16:00       ` Peter Zijlstra
2021-11-18 16:00       ` Peter Zijlstra
2021-11-18 16:26       ` Johannes Berg
2021-11-18 16:26         ` Johannes Berg
2021-11-18 16:26         ` Johannes Berg
2021-11-18 16:57         ` Eric Dumazet
2021-11-18 16:57           ` Eric Dumazet
2021-11-18 16:57           ` Eric Dumazet
2021-11-18 17:02           ` Eric Dumazet
2021-11-18 17:02             ` Eric Dumazet
2021-11-18 17:02             ` Eric Dumazet
2021-11-25  1:58           ` Noah Goldstein
2021-11-25  1:58             ` Noah Goldstein
2021-11-25  1:58             ` Noah Goldstein
2021-11-25  2:56             ` Eric Dumazet
2021-11-25  2:56               ` Eric Dumazet
2021-11-25  2:56               ` Eric Dumazet
2021-11-25  3:41               ` Noah Goldstein
2021-11-25  3:41                 ` Noah Goldstein
2021-11-25  3:41                 ` Noah Goldstein
2021-11-25  4:00                 ` Eric Dumazet
2021-11-25  4:00                   ` Eric Dumazet
2021-11-25  4:00                   ` Eric Dumazet
2021-11-25  4:08                   ` Eric Dumazet
2021-11-25  4:08                     ` Eric Dumazet
2021-11-25  4:08                     ` Eric Dumazet
2021-11-25  4:20                     ` Eric Dumazet
2021-11-25  4:20                       ` Eric Dumazet
2021-11-25  4:20                       ` Eric Dumazet
2021-11-25  4:56                       ` Noah Goldstein
2021-11-25  4:56                         ` Noah Goldstein
2021-11-25  4:56                         ` Noah Goldstein
2021-11-25  5:09                         ` Noah Goldstein
2021-11-25  5:09                           ` Noah Goldstein
2021-11-25  5:09                           ` Noah Goldstein
2021-11-25  6:32                           ` Eric Dumazet
2021-11-25  6:32                             ` Eric Dumazet
2021-11-25  6:32                             ` Eric Dumazet
2021-11-25  6:45                             ` Eric Dumazet
2021-11-25  6:45                               ` Eric Dumazet
2021-11-25  6:45                               ` Eric Dumazet
2021-11-25  6:49                               ` Noah Goldstein
2021-11-25  6:49                                 ` Noah Goldstein
2021-11-25  6:49                                 ` Noah Goldstein
2021-11-25  6:47                             ` Noah Goldstein [this message]
2021-11-25  6:47                               ` Noah Goldstein
2021-11-25  6:47                               ` Noah Goldstein
2021-11-26 17:18                   ` David Laight
2021-11-26 17:18                     ` David Laight
2021-11-26 17:18                     ` David Laight
2021-11-26 18:09                     ` Eric Dumazet
2021-11-26 18:09                       ` Eric Dumazet
2021-11-26 18:09                       ` Eric Dumazet
2021-11-26 22:41                       ` David Laight
2021-11-26 22:41                         ` David Laight
2021-11-26 22:41                         ` David Laight
2021-11-26 23:04                         ` Noah Goldstein
2021-11-26 23:04                           ` Noah Goldstein
2021-11-26 23:04                           ` Noah Goldstein
2021-11-28 18:30                           ` David Laight
2021-11-28 18:30                             ` David Laight
2021-11-28 18:30                             ` David Laight
2021-12-29  6:00       ` Al Viro
2021-12-29  6:00         ` Al Viro
2021-12-29  6:00         ` Al Viro
2022-01-31  2:29         ` Al Viro
2022-01-31  2:29           ` Al Viro
2022-01-31  2:29           ` Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFUsyfKx=444zNM40rVznS+=0YKxz2+O+qNA2NbiAv2Qs+Xhrg@mail.gmail.com' \
    --to=goldstein.w.n@gmail.com \
    --cc=alexanderduyck@fb.com \
    --cc=edumazet@google.com \
    --cc=johannes@sipsolutions.net \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=lkp@intel.com \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.