From: Eric Dumazet <dada1@cosmosbay.com>
To: Pierre Ossman <drzeus@drzeus.cx>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: net: alignment problem in icmp code
Date: Mon, 22 Oct 2007 11:52:12 +0200 [thread overview]
Message-ID: <471C72CC.3090100@cosmosbay.com> (raw)
In-Reply-To: <20071022112605.11f7893e@poseidon.drzeus.cx>
Pierre Ossman a écrit :
> On Mon, 22 Oct 2007 02:05:38 -0700 (PDT)
> David Miller <davem@davemloft.net> wrote:
>
>
>> From: Pierre Ossman <drzeus@drzeus.cx>
>> Date: Mon, 22 Oct 2007 10:42:08 +0200
>>
>>
>>> This seems like a rather evil layering violation.
>>>
>> This has a 10+ year precedence and it's why the Linux networking stack
>> is so fast. If you read any other driver you would have seen the
>> skb_reserve() call every one of them do to align the headers.
>>
>>
>
> The norm seems to be to not comment this call. It's hardly obvious.
>
>
This is not obvious you are right, but documented in
include/linux/skbuff.h (lines 1150 ...)
/*
* CPUs often take a performance hit when accessing unaligned memory
* locations. The actual performance hit varies, it can be small if the
* hardware handles it or large if we have to take an exception and fix it
* in software.
*
* Since an ethernet header is 14 bytes network drivers often end up with
* the IP header at an unaligned offset. The IP header can be aligned by
* shifting the start of the packet by 2 bytes. Drivers should do this
* with:
*
* skb_reserve(NET_IP_ALIGN);
*
* The downside to this alignment of the IP header is that the DMA is now
* unaligned. On some architectures the cost of an unaligned DMA is high
* and this cost outweighs the gains made by aligning the IP header.
*
* Since this trade off varies between architectures, we allow NET_IP_ALIGN
* to be overridden.
*/
#ifndef NET_IP_ALIGN
#define NET_IP_ALIGN 2
#endif
But then, many drivers dont use NET_IP_ALIGN but a hardcoded 2
drivers/net/pcnet32.c:608: skb_reserve(rx_skbuff, 2);
drivers/net/pcnet32.c:1214: skb_reserve(newskb, 2);
drivers/net/pcnet32.c:1245: skb_reserve(skb, 2); /* 16
byte align */
drivers/net/pcnet32.c:2396: skb_reserve(rx_skbuff, 2);
drivers/net/sundance.c:989: skb_reserve(skb, 2); /* 16
byte align the IP header. */
drivers/net/sundance.c:1312: skb_reserve(skb,
2); /* 16 byte align the IP header */
drivers/net/sundance.c:1375: skb_reserve(skb, 2); /*
Align IP on 16 byte boundaries */
prev parent reply other threads:[~2007-10-22 9:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-20 21:35 net: alignment problem in icmp code Pierre Ossman
2007-10-21 5:12 ` David Miller
2007-10-21 9:34 ` Pierre Ossman
2007-10-21 19:48 ` David Miller
2007-10-21 21:21 ` Pierre Ossman
2007-10-21 23:02 ` David Miller
2007-10-22 4:54 ` Pierre Ossman
2007-10-22 5:15 ` David Miller
2007-10-22 7:23 ` Pierre Ossman
2007-10-22 8:31 ` David Miller
2007-10-22 8:42 ` Pierre Ossman
2007-10-22 9:05 ` David Miller
2007-10-22 9:26 ` Pierre Ossman
2007-10-22 9:52 ` Eric Dumazet [this message]
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=471C72CC.3090100@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=drzeus@drzeus.cx \
--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;
as well as URLs for NNTP newsgroup(s).