Thread (22 messages) 22 messages, 8 authors, 2012-10-11

alignment faults in 3.6

flat view

From: Eric Dumazet <hidden>
Date: 2012-10-11 11:28:19
Also in: netdev

Possibly related (same subject, not in this thread)

On Thu, 2012-10-11 at 12:56 +0200, Maxime Bizon wrote:
On Thu, 2012-10-11 at 12:49 +0200, Eric Dumazet wrote:

quoted
So if you have an alignment fault, thats because IP header is not
aligned on 4 bytes ?

If so a driver is buggy and must be fixed.
So a driver that does not align the ip header is buggy ?
exactly.
I always thought it was ok not to do so (with a potential performance
penalty).
Apparently not for some arches.
I have some MIPS hardware that is not able to DMA on anything but 32bits
aligned addresses (bcm63xx). I tried once to add a memcpy instead of
taking unaligned faults and the result was *much slower* on a ipv4
forwarding test (which is what the hardware is used for).
You probably are aware that a driver can use : 

- a fragment to hold the frame given by the hardware, with whatever
alignment is needed by the hardware.

Then allocate an skb with enough room (128 bytes) to pull the headers as
needed later.

skb = netdev_alloc_skb_ip_align(dev, 128);

Attach the fragment to the skb, and feed stack with this skb.
(pull the ethernet header before calling eth_type_trans()

Most modern drivers exactly use this strategy and get nice performance.

Of course, if hardware doesnt need a strange alignment, we can avoid the
fragment and directly use 

skb = netdev_alloc_skb_ip_align(dev, 1536);

So all drivers can be fixed if needed.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help