From: William Allen Simpson <william.allen.simpson@gmail.com>
To: Linux Kernel Developers <linux-kernel@vger.kernel.org>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
Andi Kleen <andi@firstfloor.org>
Subject: Re: [PATCH v2] tcp: input header length, prediction, and timestamp bugs
Date: Tue, 19 Jan 2010 12:35:02 -0500 [thread overview]
Message-ID: <4B55ED46.40909@gmail.com> (raw)
In-Reply-To: <4B50BFFC.8010108@gmail.com>
Over the weekend, I've been reviewing the .lst output that Andi
explained, and I've found a few interesting things.
1) The 4.4 compiler isn't very smart about shifts:
static inline unsigned int tcp_header_len_th(const struct tcphdr *th)
{
return th->doff * 4;
c04ea93e: 0f b6 47 0c movzbl 0xc(%edi),%eax
c04ea942: c0 e8 04 shr $0x4,%al
c04ea945: 0f b6 c0 movzbl %al,%eax
c04ea948: c1 e0 02 shl $0x2,%eax
That could easily be done as shr $0x2 instead.
2) This "fast path" code is under quite a bit of register pressure on
the 32-bit i386. There's a lot of saving and re-loading.
3) Particularly, the seldom used *th and len parameters are saved and
reloaded in the very beginning of the fast path, really wasting time.
4) Since both *th and len are actually indexed loads from *skb (which
the compiler keeps in a register most of the time), doing indexed loads
from the stack (%ebp) is the same, so they shouldn't be sent as
parameters at all!
5) There's already code, added back in 2006 for DMA, that directly
references skb->len instead of the len parameter. Probably lack of
header documentation, so the coder failed to notice:
if (copied_early)
tcp_cleanup_rbuf(sk, skb->len);
c04ead5d: 8b 56 50 mov 0x50(%esi),%edx
c04ead60: 89 d8 mov %ebx,%eax
c04ead62: e8 fc ff ff ff call c04ead63 <tcp_rcv_established+0x633>
Therefore, I'll resubmit this patch, removing the existing len parameter.
And maybe *th, too....
next prev parent reply other threads:[~2010-01-19 17:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-10 12:06 query: tcp_sock tcp_header_len calculations (re-sent) William Allen Simpson
2010-01-15 14:16 ` [PATCH] tcp: input header length, prediction, and timestamp bugs William Allen Simpson
2010-01-15 19:12 ` William Allen Simpson
2010-01-15 19:20 ` [PATCH v2] " William Allen Simpson
2010-01-19 17:35 ` William Allen Simpson [this message]
2010-01-19 19:35 ` William Allen Simpson
2010-01-19 19:58 ` William Allen Simpson
2010-01-19 20:17 ` [PATCH v3] " William Allen Simpson
2010-01-19 23:58 ` William Allen Simpson
2010-01-20 0:01 ` [PATCH v4] " William Allen Simpson
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=4B55ED46.40909@gmail.com \
--to=william.allen.simpson@gmail.com \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--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 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.