Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-02-01 Thread Eric Dumazet
On Mon, 2016-02-01 at 16:55 +, David Laight wrote: > From: Eric Dumazet > > Sent: 29 January 2016 22:29 > ... > > On modern intel cpus, this does not matter at all, sure. It took a while > > before "rep movsb" finally did the right thing. > > Unfortunately memcpy_to_io() etc now map to 'rep mo

RE: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-02-01 Thread David Laight
From: Eric Dumazet > Sent: 29 January 2016 22:29 ... > On modern intel cpus, this does not matter at all, sure. It took a while > before "rep movsb" finally did the right thing. Unfortunately memcpy_to_io() etc now map to 'rep movsb', and that can only be optimisied for cached addresses. So copie

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-31 Thread Eric Dumazet
On Sun, 2016-01-31 at 14:13 -0800, Tom Herbert wrote: > Neither is GRE enabled by default in Linux and it is not a typical > case. So that patch is an optimization for a very narrow use case that > impacts the core data path for everyone. Please at least consider > making it configurable. No idea

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-31 Thread Tom Herbert
On Fri, Jan 29, 2016 at 6:15 PM, Eric Dumazet wrote: > On Fri, 2016-01-29 at 16:47 -0800, Tom Herbert wrote: > >> Hmm, thanks for pointing that out. It looks like this is called by a >> couple drivers as part of pulling up the data to get alignment. I am >> actually surprised they are doing this.

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Eric Dumazet
On Fri, 2016-01-29 at 16:47 -0800, Tom Herbert wrote: > Hmm, thanks for pointing that out. It looks like this is called by a > couple drivers as part of pulling up the data to get alignment. I am > actually surprised they are doing this. Flow dissector is not the > cheapest function in the world a

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread David Miller
From: Tom Herbert Date: Fri, 29 Jan 2016 16:47:46 -0800 > Seems like it might be just as well to pull up a fixed number of > bytes (ixgbe want min of 60 bytes), This is precisely what we were trying to move away from, please don't regress back to that.

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Tom Herbert
On Fri, Jan 29, 2016 at 3:58 PM, Sowmini Varadhan wrote: > On (01/29/16 15:31), Tom Herbert wrote: >> But even within flow dissector, to be completely correct, we need to >> replace all 32-bit accesses with the mempy (flow_label, mpls label, >> keyid) and be vigilant about new ones coming in. For

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Sowmini Varadhan
On (01/29/16 15:31), Tom Herbert wrote: > But even within flow dissector, to be completely correct, we need to > replace all 32-bit accesses with the mempy (flow_label, mpls label, > keyid) and be vigilant about new ones coming in. For that matter, .. well, one question that came to my mind when I

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Tom Herbert
On Fri, Jan 29, 2016 at 3:04 PM, Sowmini Varadhan wrote: > On (01/29/16 15:00), Tom Herbert wrote: > >> The sparc documentation is pretty clear >> http://docs.oracle.com/cd/E19253-01/816-4854/hwovr-2/index.html, seems >> like unaligned accesses are not allowed in the architecture. > > yes, but loo

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Sowmini Varadhan
On (01/29/16 15:00), Tom Herbert wrote: > The sparc documentation is pretty clear > http://docs.oracle.com/cd/E19253-01/816-4854/hwovr-2/index.html, seems > like unaligned accesses are not allowed in the architecture. yes, but looks like you can paper over some of this with memcpy (as was happen

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Tom Herbert
On Fri, Jan 29, 2016 at 1:09 PM, Sowmini Varadhan wrote: > On (01/29/16 13:00), Tom Herbert wrote: >> Doesn't every IP/VXLAN packet contains unaligned headers? Why don't >> those create alignment issues (like when stack looks at addresses)? > > They do. > > http://comments.gmane.org/gmane.linux.ne

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Alexander Duyck
On Fri, Jan 29, 2016 at 2:28 PM, Eric Dumazet wrote: > On Fri, 2016-01-29 at 14:08 -0800, Alexander Duyck wrote: > >> It also means DMA becomes dramatically slower as it introduces a >> partial write access for the start of every frame. It is why we had >> set NET_IP_ALIGN to 0 on x86 since DMA w

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Eric Dumazet
On Fri, 2016-01-29 at 14:08 -0800, Alexander Duyck wrote: > It also means DMA becomes dramatically slower as it introduces a > partial write access for the start of every frame. It is why we had > set NET_IP_ALIGN to 0 on x86 since DMA was becoming more expensive > when unaligned then reading IP

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Alexander Duyck
On Fri, Jan 29, 2016 at 1:33 PM, Eric Dumazet wrote: > On Fri, 2016-01-29 at 13:16 -0800, Alexander Duyck wrote: > >> It has to be something recent. I know back when I wrote the code I >> tested it on a few different architectures and had to add a few bits >> in __skb_get_poff so that it would re

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Eric Dumazet
On Fri, 2016-01-29 at 13:16 -0800, Alexander Duyck wrote: > It has to be something recent. I know back when I wrote the code I > tested it on a few different architectures and had to add a few bits > in __skb_get_poff so that it would read doff as a u8 instead of > bitfield in a u32. > > Looking

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Tom Herbert
On Fri, Jan 29, 2016 at 1:09 PM, Sowmini Varadhan wrote: > On (01/29/16 13:00), Tom Herbert wrote: >> Doesn't every IP/VXLAN packet contains unaligned headers? Why don't >> those create alignment issues (like when stack looks at addresses)? > > They do. > > http://comments.gmane.org/gmane.linux.ne

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Alexander Duyck
On Fri, Jan 29, 2016 at 12:01 PM, Eric Dumazet wrote: > On Fri, 2016-01-29 at 14:44 -0500, Sowmini Varadhan wrote: >> On (01/29/16 11:37), Eric Dumazet wrote: >> > >> > I have no idea why reading iph->saddr or iph->daddr would not hit the >> > problem, but accessing the 32bit ipv6 flow label would

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Sowmini Varadhan
On (01/29/16 13:00), Tom Herbert wrote: > Doesn't every IP/VXLAN packet contains unaligned headers? Why don't > those create alignment issues (like when stack looks at addresses)? They do. http://comments.gmane.org/gmane.linux.network/370672 some of it was fixed in https://lkml.org/lkml/2015/7/2

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Tom Herbert
On Fri, Jan 29, 2016 at 10:54 AM, Eric Dumazet wrote: > On Fri, 2016-01-29 at 10:33 -0800, Eric Dumazet wrote: >> On Fri, 2016-01-29 at 13:06 -0500, Sowmini Varadhan wrote: >> > There is an unaligned access at __skb_flow_dissect when it calls >> > ip6_flowlabel() with the call stack >> > >> > __

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Eric Dumazet
On Fri, 2016-01-29 at 12:01 -0800, Eric Dumazet wrote: > On Fri, 2016-01-29 at 14:44 -0500, Sowmini Varadhan wrote: > > On (01/29/16 11:37), Eric Dumazet wrote: > > > > > > I have no idea why reading iph->saddr or iph->daddr would not hit the > > > problem, but accessing the 32bit ipv6 flow label

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Eric Dumazet
On Fri, 2016-01-29 at 14:44 -0500, Sowmini Varadhan wrote: > On (01/29/16 11:37), Eric Dumazet wrote: > > > > I have no idea why reading iph->saddr or iph->daddr would not hit the > > problem, but accessing the 32bit ipv6 flow label would be an issue. > > > > Something is fishy. > > I was wonder

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Sowmini Varadhan
On (01/29/16 11:37), Eric Dumazet wrote: > > I have no idea why reading iph->saddr or iph->daddr would not hit the > problem, but accessing the 32bit ipv6 flow label would be an issue. > > Something is fishy. I was wondering about this myself. Even on sparc, I only first ran into the errors for

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread David Miller
From: Eric Dumazet Date: Fri, 29 Jan 2016 11:37:30 -0800 > But really adding unaligned() accesses in flow dissector would slow it > quite a lot on MIPS and others. Agreed, the fix definitely belongs in the callers of these interfaces, which in this case is the driver.

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Eric Dumazet
On Fri, 2016-01-29 at 11:08 -0800, David Miller wrote: > From: Eric Dumazet > Date: Fri, 29 Jan 2016 10:40:10 -0800 > > > I would try following ixgbe fix (sorry, totally untested, but you get > > the idea...) > > > > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > > b/drivers/net/e

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Eric Dumazet
On Fri, 2016-01-29 at 11:06 -0800, David Miller wrote: > From: Eric Dumazet > Date: Fri, 29 Jan 2016 10:33:48 -0800 > > > Why ipv6 stack itself does not trigger the issue ? > > > > Maybe the driver itself does not properly align IP headers on sparc ? > > > > Make sure NET_IP_ALIGN is 2 on your

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Sowmini Varadhan
On (01/29/16 10:54), Eric Dumazet wrote: > > Why ipv6 stack itself does not trigger the issue ? > > Maybe the driver itself does not properly align IP headers on sparc ? > > Make sure NET_IP_ALIGN is 2 on your build. > > Note that x86 does not care, but a driver should always align Ethernet > > hea

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread David Miller
From: Eric Dumazet Date: Fri, 29 Jan 2016 10:40:10 -0800 > I would try following ixgbe fix (sorry, totally untested, but you get > the idea...) > > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > index c4003a88bbf6..7ba64ed463a6 100

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread David Miller
From: Eric Dumazet Date: Fri, 29 Jan 2016 10:33:48 -0800 > Why ipv6 stack itself does not trigger the issue ? > > Maybe the driver itself does not properly align IP headers on sparc ? > > Make sure NET_IP_ALIGN is 2 on your build. > > Note that x86 does not care, but a driver should always ali

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread David Miller
From: Sowmini Varadhan Date: Fri, 29 Jan 2016 13:06:51 -0500 > @@ -102,6 +102,17 @@ __be32 __skb_flow_get_ports(const struct sk_buff *skb, > int > } > EXPORT_SYMBOL(__skb_flow_get_ports); > > +static inline __be32 ip6_flowlabel_align(const u8 *hdr) > +{ > + union { > + _

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Eric Dumazet
On Fri, 2016-01-29 at 10:33 -0800, Eric Dumazet wrote: > On Fri, 2016-01-29 at 13:06 -0500, Sowmini Varadhan wrote: > > There is an unaligned access at __skb_flow_dissect when it calls > > ip6_flowlabel() with the call stack > > > > __skb_flow_dissect+0x2a8/0x87c > > eth_get_headlen+0x5c/0xaxa

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Eric Dumazet
On Fri, 2016-01-29 at 10:33 -0800, Eric Dumazet wrote: > > Why ipv6 stack itself does not trigger the issue ? > > Maybe the driver itself does not properly align IP headers on sparc ? > > Make sure NET_IP_ALIGN is 2 on your build. > > Note that x86 does not care, but a driver should always ali

Re: [RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Eric Dumazet
On Fri, 2016-01-29 at 13:06 -0500, Sowmini Varadhan wrote: > There is an unaligned access at __skb_flow_dissect when it calls > ip6_flowlabel() with the call stack > > __skb_flow_dissect+0x2a8/0x87c > eth_get_headlen+0x5c/0xaxa4 > ixgbe_clean_rx_irq+0x5cc/0xb20 [ixgbe] > ixgbe_poll+0x5a4/0

[RFC] Kernel unaligned access at __skb_flow_dissect

2016-01-29 Thread Sowmini Varadhan
There is an unaligned access at __skb_flow_dissect when it calls ip6_flowlabel() with the call stack __skb_flow_dissect+0x2a8/0x87c eth_get_headlen+0x5c/0xaxa4 ixgbe_clean_rx_irq+0x5cc/0xb20 [ixgbe] ixgbe_poll+0x5a4/0x760 [ixgbe] net_rx_action+0x13c/0x354 : Essentially, ixgbe_pull_