From: Eric Dumazet <eric.dumazet@gmail.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
Patrick McHardy <kaber@trash.net>,
Herbert Xu <herbert@gondor.apana.org.au>,
"H.K. Jerry Chu" <hkchu@google.com>,
Michael Dalton <mwdalton@google.com>,
netdev <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] csum experts, csum_replace2() is too expensive
Date: Fri, 21 Mar 2014 06:47:05 -0700 [thread overview]
Message-ID: <1395409625.6441.4.camel@edumazet-glaptop2.roam.corp.google.com> (raw)
In-Reply-To: <1395408778.6441.2.camel@edumazet-glaptop2.roam.corp.google.com>
On Fri, 2014-03-21 at 06:32 -0700, Eric Dumazet wrote:
> On Fri, 2014-03-21 at 05:50 -0700, Eric Dumazet wrote:
>
> > Or the fact that we mix 16 bit stores and 32bit loads ?
> >
> > iph->tot_len = newlen;
> > iph->check = 0;
> > iph->check = ip_fast_csum(iph, 5);
>
> Yep definitely. Using 16 bit loads in ip_fast_csum() totally removes the
> stall. I no longer see inet_gro_complete() in perf top...
>
> + if (__builtin_constant_p(ihl) && ihl == 5) {
> + asm(" movw (%[iph]), %w[sum]\n" /* ihl/version/tos */
> + " addw 2(%[iph]), %w[sum]\n" /* tot_len */
> + " adcw 8(%[iph]), %w[sum]\n" /* ttl/protocol */
> + " adcw 10(%[iph]), %w[sum]\n" /* check */
> + " adcl 4(%[iph]), %[sum]\n" /* id/frag_off */
> + " adcl 12(%[iph]), %[sum]\n" /* saddr */
> + " adcl 16(%[iph]), %[sum]\n" /* daddr */
> + " adcl $0, %[sum]\n"
> + : [sum] "=r" (sum)
> + : [iph] "r" (iph)
> + );
> + return csum_fold(sum);
>
Another idea would be to move the ip_fast_csum() call at the end of
inet_gro_complete()
I'll try this :
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 8c54870db792..0ca8f350a532 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1434,8 +1434,8 @@ static int inet_gro_complete(struct sk_buff *skb, int nhoff)
int proto = iph->protocol;
int err = -ENOSYS;
- csum_replace2(&iph->check, iph->tot_len, newlen);
iph->tot_len = newlen;
+ iph->check = 0;
rcu_read_lock();
ops = rcu_dereference(inet_offloads[proto]);
@@ -1447,6 +1447,7 @@ static int inet_gro_complete(struct sk_buff *skb, int nhoff)
* inet_gro_receive().
*/
err = ops->callbacks.gro_complete(skb, nhoff + sizeof(*iph));
+ iph->check = ip_fast_csum((u8 *)iph, 5);
out_unlock:
rcu_read_unlock();
next prev parent reply other threads:[~2014-03-21 13:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1395341341.9114.93.camel@edumazet-glaptop2.roam.corp.google.com>
[not found] ` <87a9cknwk4.fsf@tassilo.jf.intel.com>
2014-03-21 12:50 ` Eric Dumazet
2014-03-21 13:28 ` Andi Kleen
2014-03-21 13:32 ` Eric Dumazet
2014-03-21 13:47 ` Eric Dumazet [this message]
2014-03-21 13:56 ` Eric Dumazet
2014-03-21 14:14 ` David Laight
2014-03-21 18:52 ` David Miller
2014-03-24 2:50 ` Eric Dumazet
2014-03-24 10:30 ` David Laight
2014-03-24 13:17 ` Eric Dumazet
2014-03-24 14:13 ` Eric Dumazet
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=1395409625.6441.4.camel@edumazet-glaptop2.roam.corp.google.com \
--to=eric.dumazet@gmail.com \
--cc=andi@firstfloor.org \
--cc=herbert@gondor.apana.org.au \
--cc=hkchu@google.com \
--cc=hpa@zytor.com \
--cc=kaber@trash.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mwdalton@google.com \
--cc=netdev@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®