All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Demian Shulhan <demyansh@gmail.com>
Cc: saeed bishara <saeed.bishara.os@gmail.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Eric Biggers <ebiggers@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Marco Elver <elver@google.com>, Ard Biesheuvel <ardb@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	David Gow <davidgow@google.com>,
	Brendan Higgins <brendan.higgins@linux.dev>,
	Nathan Chancellor <nathan@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com,
	netdev@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH 0/2] arm64: csum: Add fused copy and Internet checksum
Date: Mon, 2 Nov 2026 16:14:26 +0000	[thread overview]
Message-ID: <20261102161426.2403d308@pumpkin> (raw)
In-Reply-To: <CAOLeWCu4NiedyXmoLwwnTvJitRwgg6PQq9LApO=k36ktN3-XWA@mail.gmail.com>

On Mon, 2 Nov 2026 16:14:06 +0100
Demian Shulhan <demyansh@gmail.com> wrote:

> > The scalar path seems like generic C code and not restricted to arm64,
> > curious how that performs against existing (e.g. x86) assembly
> > optimized implementation.  
> Depends. I think __builtin_addcll() is needed to get roughly the same
> performance as the asm version. In my tests GCC on arm64 turns it
> into adds + cset instead of adcs like on x86.
> But I will look at it, thanks!

The C version I posted earlier has the loop:
    buf += count;
    count = -count;
    sum = carry = 0;
    do {
        val = *(u64 *)(buf + count);
        sum += val;
        carry += sum < val;
    } while ((count += 8));

for aarch64 you get:
.L4:
        ldr     x1, [x0, x4]
        adds    x2, x2, x1
        cinc    x3, x3, cs	# adc $0,%rxx on x86
        adds    x4, x4, 8
        bne     .L4

I suspect that is close to optimal - especially for fast cpu with
out of order execution.

https://godbolt.org/z/eso79K7Wq

David

> 
> пн, 2 лист. 2026 р. о 12:44 saeed bishara <saeed.bishara.os@gmail.com> пише:
> >
> > On Sun, Nov 1, 2026 at 3:34 PM Demian Shulhan <demyansh@gmail.com> wrote:  
> > >
> > > I would prefer to keep only the scalar version of the fused copy+csum.
> > > It reads the data once instead of twice, and on real Armv9 hardware it
> > > cuts end-to-end cycles/byte for bulk TCP over WireGuard by 3-12%
> > > depending on the core (+6-8% throughput). It uses only general-purpose
> > > registers, so there is no FPSIMD state to save and it is safe in any
> > > context.
> > >
> > > If you are OK with the scalar path, I can send v2 with NEON dropped,
> > > the scalar path only, and the KUnit fix for the x86 zero-length case
> > > Jakub reported.
> > >  
> > The scalar path seems like generic C code and not restricted to arm64,
> > curious how that performs against existing (e.g. x86) assembly
> > optimized implementation.
> > saeed  



  reply	other threads:[~2026-11-02 16:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 13:17 [PATCH 0/2] arm64: csum: Add fused copy and Internet checksum Demian Shulhan
2026-09-27 13:17 ` [PATCH 1/2] " Demian Shulhan
2026-11-01 22:44   ` Nathan Chancellor
2026-09-27 13:17 ` [PATCH 2/2] lib/tests: checksum: Add KUnit tests for csum_partial_copy_nocheck() Demian Shulhan
2026-09-27 17:44 ` [PATCH 0/2] arm64: csum: Add fused copy and Internet checksum David Laight
2026-11-01 13:33   ` Demian Shulhan
2026-11-01 18:21     ` David Laight
2026-11-02 11:44     ` saeed bishara
2026-11-02 14:58       ` David Laight
2026-11-02 15:14       ` Demian Shulhan
2026-11-02 16:14         ` David Laight [this message]
2026-11-03 15:47           ` Demian Shulhan
2026-11-03 22:38             ` David Laight
2026-11-05 11:41               ` Demian Shulhan
2026-09-30  1:33 ` Jakub Kicinski

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=20261102161426.2403d308@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ardb@kernel.org \
    --cc=brendan.higgins@linux.dev \
    --cc=catalin.marinas@arm.com \
    --cc=davidgow@google.com \
    --cc=demyansh@gmail.com \
    --cc=ebiggers@kernel.org \
    --cc=elver@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=nathan@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=saeed.bishara.os@gmail.com \
    --cc=will@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.