From: Alexander Duyck <alexander.duyck@gmail.com>
To: David Laight <David.Laight@aculab.com>
Cc: Tom Herbert <tom@herbertland.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"hpa@zytor.com" <hpa@zytor.com>,
"x86@kernel.org" <x86@kernel.org>,
"kernel-team@fb.com" <kernel-team@fb.com>
Subject: Re: [PATCH v3 net-next] net: Implement fast csum_partial for x86_64
Date: Thu, 4 Feb 2016 08:51:59 -0800 [thread overview]
Message-ID: <CAKgT0UcuJWmpwO4hu34qBWhrhqQ5GQMU_dWHF-Dd10+Y9aCH=g@mail.gmail.com> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1CCD63C9@AcuExch.aculab.com>
On Thu, Feb 4, 2016 at 3:08 AM, David Laight <David.Laight@aculab.com> wrote:
> From: Tom Herbert
>> Sent: 03 February 2016 19:19
> ...
>> + /* Main loop */
>> +50: adcq 0*8(%rdi),%rax
>> + adcq 1*8(%rdi),%rax
>> + adcq 2*8(%rdi),%rax
>> + adcq 3*8(%rdi),%rax
>> + adcq 4*8(%rdi),%rax
>> + adcq 5*8(%rdi),%rax
>> + adcq 6*8(%rdi),%rax
>> + adcq 7*8(%rdi),%rax
>> + adcq 8*8(%rdi),%rax
>> + adcq 9*8(%rdi),%rax
>> + adcq 10*8(%rdi),%rax
>> + adcq 11*8(%rdi),%rax
>> + adcq 12*8(%rdi),%rax
>> + adcq 13*8(%rdi),%rax
>> + adcq 14*8(%rdi),%rax
>> + adcq 15*8(%rdi),%rax
>> + lea 128(%rdi), %rdi
>> + loop 50b
>
> I'd need convincing that unrolling the loop like that gives any significant gain.
> You have a dependency chain on the carry flag so have delays between the 'adcq'
> instructions (these may be more significant than the memory reads from l1 cache).
>
> I also don't remember (might be wrong) the 'loop' instruction being executed quickly.
> If 'loop' is fast then you will probably find that:
>
> 10: adcq 0(%rdi),%rax
> lea 8(%rdi),%rdi
> loop 10b
>
> is just as fast since the three instructions could all be executed in parallel.
> But I suspect that 'dec %cx; jnz 10b' is actually better (and might execute as
> a single micro-op).
> IIRC 'adc' and 'dec' will both have dependencies on the flags register
> so cannot execute together (which is a shame here).
>
> It is also possible that breaking the carry-chain dependency by doing 32bit
> adds (possibly after 64bit reads) can be made to be faster.
If nothing else reducing the size of this main loop may be desirable.
I know the newer x86 is supposed to have a loop buffer so that it can
basically loop on already decoded instructions. Normally it is only
something like 64 or 128 bytes in size though. You might find that
reducing this loop to that smaller size may improve the performance
for larger payloads.
- Alex
next prev parent reply other threads:[~2016-02-04 16:52 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-03 19:18 [PATCH v3 net-next] net: Implement fast csum_partial for x86_64 Tom Herbert
2016-02-04 9:30 ` Ingo Molnar
2016-02-04 10:56 ` Ingo Molnar
2016-02-04 19:24 ` Tom Herbert
2016-02-05 9:24 ` Ingo Molnar
2016-02-04 21:46 ` Linus Torvalds
2016-02-04 22:09 ` Linus Torvalds
2016-02-05 1:27 ` Linus Torvalds
2016-02-05 1:39 ` Linus Torvalds
2016-02-04 22:43 ` Tom Herbert
2016-02-04 22:57 ` Linus Torvalds
2016-02-05 8:01 ` Ingo Molnar
2016-02-05 10:07 ` David Laight
2016-02-04 11:08 ` David Laight
2016-02-04 16:51 ` Alexander Duyck [this message]
2016-02-04 16:58 ` Tom Herbert
2016-02-04 17:09 ` David Laight
2016-02-04 20:59 ` Tom Herbert
2016-02-04 21:09 ` Alexander Duyck
2016-02-04 19:22 ` Alexander Duyck
2016-02-04 19:31 ` Tom Herbert
2016-02-04 19:44 ` Tom Herbert
2016-02-04 20:03 ` Alexander Duyck
2016-02-08 20:12 George Spelvin
2016-02-09 10:48 ` David Laight
2016-02-10 0:53 ` George Spelvin
2016-02-10 11:39 ` David Laight
2016-02-10 14:43 ` George Spelvin
2016-02-10 15:18 ` David Laight
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='CAKgT0UcuJWmpwO4hu34qBWhrhqQ5GQMU_dWHF-Dd10+Y9aCH=g@mail.gmail.com' \
--to=alexander.duyck@gmail.com \
--cc=David.Laight@aculab.com \
--cc=davem@davemloft.net \
--cc=hpa@zytor.com \
--cc=kernel-team@fb.com \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tom@herbertland.com \
--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.