[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 11 Nov 2021 18:17:56 +0000
From: Andrew Cooper <andrew.cooper3@...rix.com>
To: Eric Dumazet <edumazet@...gle.com>,
Peter Zijlstra <peterz@...radead.org>
CC: Eric Dumazet <eric.dumazet@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
netdev <netdev@...r.kernel.org>, <x86@...nel.org>,
Alexander Duyck <alexander.duyck@...il.com>,
Andrew Cooper <andrew.cooper3@...rix.com>, <amc96@...f.net>
Subject: Re: [RFC] x86/csum: rewrite csum_partial()
On 11/11/2021 16:52, Eric Dumazet wrote:
> On Thu, Nov 11, 2021 at 8:02 AM Eric Dumazet <edumazet@...gle.com> wrote:
>> Thanks Peter !
>>
>> This is more or less the first version I wrote. (I was doing tests for
>> (len & 32), (len & 16) .. to not have to update len in these blocks.
>>
>> Then, I tried to add an inline version, a la ip_fast_csum() but for IPv6.
>>
>> Then I came up with the version I sent, for some reason my .config had
>> temporarily disabled CONFIG_RETPOLINE,
>> thanks for reminding me this !
>>
>> I also missed this warning anyway :
>> arch/x86/lib/csum-partial_64.o: warning: objtool: csum_partial()+0x2f:
>> unannotated intra-function call
>>
>> I will spend a bit more time on this before sending a V2, thanks again !
> BTW, I could not understand why :
>
> result = add32_with_carry(result, *(u32 *)buff);
>
> generates this code :
>
> 123: 41 8b 09 mov (%r9),%ecx
> 126: 89 4d f8 mov %ecx,-0x8(%rbp)
> 129: 03 45 f8 add -0x8(%rbp),%eax
> 12c: 83 d0 00 adc $0x0,%eax
Are you using Clang? There is a long outstanding code generation bug
where an "rm" constraint is converted to "m" internally.
https://bugs.llvm.org/show_bug.cgi?id=47530
Even a stopgap of pretending "rm" means "r" would result in far better
code, 99% of the time.
> Apparently add32_with_carry() forces the use of use of a temporary in memory
>
> While
> asm(" addl 0*4(%[src]),%[res]\n"
> " adcl $0,%[res]\n"
> : [res] "=r" (result)
> : [src] "r" (buff), "[res]" (result)
> : "memory");
Just as a minor note about the asm constraints here and elsewhere
: [res] "=r" (result)
: "res" (result)
ought to be just [res] "+r" (result). The result variable really is
read and written by the asm fragments.
~Andrew
Powered by blists - more mailing lists