From: David Laight <David.Laight@ACULAB.COM>
To: 'Christophe Leroy' <christophe.leroy@csgroup.eu>,
'Segher Boessenkool' <segher@kernel.crashing.org>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Russell King <linux@armlinux.org.uk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"David S. Miller" <davem@davemloft.net>
Subject: RE: [PATCH] net: Remove branch in csum_shift()
Date: Tue, 1 Mar 2022 11:41:06 +0000 [thread overview]
Message-ID: <10309fa64833418a980a8d950d037357@AcuMS.aculab.com> (raw)
In-Reply-To: <c616f9a6-c9db-d3a7-1b23-f827732566bb@csgroup.eu>
From: Christophe Leroy
> Sent: 01 March 2022 11:15
...
> Looks like ARM also does better code with the generic implementation as
> it seems to have some looking like conditional instructions 'rorne' and
> 'strne'.
In arm32 (and I think arm64) every instruction is conditional.
> static __always_inline __wsum csum_shift(__wsum sum, int offset)
> {
> /* rotate sum to align it with a 16b boundary */
> if (offset & 1)
> 1d28: e2102001 ands r2, r0, #1
> 1d2c: e58d3004 str r3, [sp, #4]
> * @word: value to rotate
> * @shift: bits to roll
> */
> static inline __u32 ror32(__u32 word, unsigned int shift)
> {
> return (word >> (shift & 31)) | (word << ((-shift) & 31));
> 1d30: 11a03463 rorne r3, r3, #8
> 1d34: 158d3004 strne r3, [sp, #4]
> if (unlikely(iov_iter_is_pipe(i)))
There is a spare 'str' that a minor code change would
probably remove.
Likely not helped by registers being spilled to stack.
ISTR arm32 having a reasonable number of registers and then
a whole load of them being stolen by the implementation.
(I'm sure I remember stack limit and thread base...)
So the compiler doesn't get that many to play with.
Not quite as bad as nios2 - where r2 and r3 are 'reserved for
the assembler' (as they probably are on MIPS) but the nios2
assembler doesn't ever need to use them!
> ...
> Ok, so the solution would be to have an arch specific version of
> csum_shift() in the same principle as csum_add().
Probably.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2022-03-01 11:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-11 8:48 [PATCH] net: Remove branch in csum_shift() Christophe Leroy
2022-02-13 2:39 ` David Laight
2022-02-13 9:16 ` Segher Boessenkool
2022-02-13 17:47 ` David Laight
2022-02-14 9:29 ` Segher Boessenkool
2022-03-01 10:20 ` Christophe Leroy
2022-03-01 10:47 ` David Laight
2022-03-01 11:14 ` Christophe Leroy
2022-03-01 11:41 ` David Laight [this message]
2022-03-01 12:37 ` Russell King (Oracle)
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=10309fa64833418a980a8d950d037357@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=christophe.leroy@csgroup.eu \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=segher@kernel.crashing.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).