linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: alignment faults in 3.6
Date: Thu, 11 Oct 2012 08:20:14 -0500	[thread overview]
Message-ID: <5076C78E.1020408@gmail.com> (raw)
In-Reply-To: <1349959248.21172.8970.camel@edumazet-glaptop>

On 10/11/2012 07:40 AM, Eric Dumazet wrote:
> On Thu, 2012-10-11 at 12:28 +0000, Arnd Bergmann wrote:
> 
>>
>> Rob Herring as the original reporter has dropped off the Cc list, adding
>> him back.
>>
>> I assume that the calxeda xgmac driver is the culprit then. It uses
>> netdev_alloc_skb() rather than netdev_alloc_skb_ip_align() in
>> xgmac_rx_refill but it is not clear whether it does so intentionally
>> or by accident.

This in fact does work and eliminates the unaligned traps. However, not
all h/w can do IP aligned DMA (i.MX FEC for example), so I still think
this is a questionable optimization by the compiler. We're saving 1 load
instruction here for data that is likely already in the cache. It may be
legal per the ABI, but the downside of this optimization is much greater
than the upside.

> 
> Thanks Arnd
> 
> It seems an accident, since driver doesnt check skb->data alignment at
> all (this can change with SLAB debug on/off)
> 
> It also incorrectly adds 64 bytes to bfsize, there is no need for this.

I'm pretty sure this was needed as the h/w writes out full bursts of
data, but I'll go back and check.

Rob

> (or if its needed, a comment would be nice, because on prior kernels,
> this makes skb->head allocations uses kmalloc-4096 instead of
> kmalloc-2048 slab cache... With 3.7 its less an issue now we use order-3
> pages to deliver fragments for rx skbs
>
> So the following patch should fix the alignment, and makes driver uses
> half memory than before for stable kernels
> 
> diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
> index 16814b3..a895e18 100644
> --- a/drivers/net/ethernet/calxeda/xgmac.c
> +++ b/drivers/net/ethernet/calxeda/xgmac.c
> @@ -671,7 +671,8 @@ static void xgmac_rx_refill(struct xgmac_priv *priv)
>  		p = priv->dma_rx + entry;
>  
>  		if (priv->rx_skbuff[entry] == NULL) {
> -			skb = netdev_alloc_skb(priv->dev, priv->dma_buf_sz);
> +			skb = netdev_alloc_skb_ip_align(priv->dev,
> +							priv->dma_buf_sz);
>  			if (unlikely(skb == NULL))
>  				break;
>  
> @@ -703,7 +704,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev)
>  	/* Set the Buffer size according to the MTU;
>  	 * indeed, in case of jumbo we need to bump-up the buffer sizes.
>  	 */
> -	bfsize = ALIGN(dev->mtu + ETH_HLEN + ETH_FCS_LEN + NET_IP_ALIGN + 64,
> +	bfsize = ALIGN(dev->mtu + ETH_HLEN + ETH_FCS_LEN,
>  		       64);
>  
>  	netdev_dbg(priv->dev, "mtu [%d] bfsize [%d]\n", dev->mtu, bfsize);
> 
> 

  reply	other threads:[~2012-10-11 13:20 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-04 23:10 alignment faults in 3.6 Rob Herring
2012-10-05  0:58 ` Michael Hope
2012-10-05  1:26   ` Mans Rullgard
2012-10-05  1:56     ` Rob Herring
2012-10-05  2:25       ` Mans Rullgard
2012-10-05  3:04         ` Rob Herring
2012-10-05  5:37           ` Khem Raj
2012-10-05  7:12         ` Russell King - ARM Linux
2012-10-05  8:20           ` Mans Rullgard
2012-10-05  8:24             ` Russell King - ARM Linux
2012-10-05  8:33               ` Mans Rullgard
2012-10-05  8:33                 ` Russell King - ARM Linux
2012-10-05  8:37                   ` Mans Rullgard
2012-10-05  8:50                     ` Russell King - ARM Linux
2012-10-05 13:49                     ` Mikael Pettersson
2012-10-05 12:24               ` Rob Herring
2012-10-05 13:51                 ` Mikael Pettersson
2012-10-05 16:01                   ` Rob Herring
2012-10-05 22:37                     ` Mans Rullgard
2012-10-05 22:42                       ` Russell King - ARM Linux
2012-10-06  1:41                         ` Nicolas Pitre
2012-10-06 16:04                         ` Mans Rullgard
2012-10-06 16:19                           ` Nicolas Pitre
2012-10-06 16:31                           ` Russell King - ARM Linux
2012-10-06 10:58                     ` Mikael Pettersson
2012-10-09 14:05                     ` Scott Bambrough
2012-10-09 14:18                       ` Mans Rullgard
2012-10-05 14:05                 ` Russell King - ARM Linux
2012-10-05 14:33                   ` Rob Herring
2012-10-11  0:59                     ` Jon Masters
2012-10-11  2:27                       ` Måns Rullgård
2012-10-11  2:34                         ` Jon Masters
2012-10-11  8:21                         ` David Laight
2012-10-11  8:53                           ` Russell King - ARM Linux
2012-10-11  9:45                           ` Måns Rullgård
2012-10-11 10:00                             ` Eric Dumazet
2012-10-11 10:20                               ` Måns Rullgård
2012-10-11 10:22                               ` Eric Dumazet
2012-10-11 10:32                                 ` Russell King - ARM Linux
2012-10-11 10:49                                   ` Eric Dumazet
2012-10-11 10:56                                     ` Maxime Bizon
2012-10-11 11:28                                       ` Eric Dumazet
2012-10-11 11:47                                         ` Maxime Bizon
2012-10-11 11:54                                           ` Eric Dumazet
2012-10-11 12:00                                             ` Eric Dumazet
2012-10-11 12:51                                             ` Maxime Bizon
2012-10-11 12:59                                               ` Eric Dumazet
2012-10-11 12:28                                     ` Arnd Bergmann
2012-10-11 12:40                                       ` Eric Dumazet
2012-10-11 13:20                                         ` Rob Herring [this message]
2012-10-11 13:32                                           ` Måns Rullgård
2012-10-11 13:35                                           ` Arnd Bergmann
2012-10-11 13:47                                           ` Eric Dumazet
2012-10-11 15:23                                             ` Rob Herring
2012-10-11 15:39                                               ` David Laight
2012-10-11 16:18                                                 ` Måns Rullgård
2012-10-12  8:11                                                   ` Arnd Bergmann
2012-10-12  9:03                                                     ` Russell King - ARM Linux
2012-10-12 10:04                                                       ` Eric Dumazet
2012-10-12 12:24                                                         ` Russell King - ARM Linux
2012-10-12 11:00                                                       ` Måns Rullgård
2012-10-12 11:07                                                         ` Russell King - ARM Linux
2012-10-12 11:18                                                           ` Måns Rullgård
2012-10-12 11:44                                                             ` Russell King - ARM Linux
2012-10-12 12:08                                                               ` Eric Dumazet
2012-10-12 14:22                                                                 ` Benjamin LaHaise
2012-10-12 14:36                                                                   ` David Laight
2012-10-12 14:48                                                                   ` Eric Dumazet
2012-10-12 15:00                                                                     ` Benjamin LaHaise
2012-10-12 15:04                                                                     ` Ben Hutchings
2012-10-12 15:47                                                                       ` David Laight
2012-10-12 16:13                                                                         ` Ben Hutchings
2012-10-12 12:16                                                               ` Måns Rullgård
2012-10-12 11:19                                                           ` Russell King - ARM Linux
2012-10-11 16:15                                               ` Eric Dumazet
2012-10-11 16:59                                   ` Catalin Marinas
2012-10-11 10:16                             ` David Laight
2012-10-11 10:46                               ` Måns Rullgård
2012-10-05 16:08   ` Rob Herring
2012-10-05  7:29 ` Russell King - ARM Linux
2012-10-05 10:51   ` Russell King - ARM Linux
2012-10-23 16:30     ` Jon Masters
2012-10-23 16:58       ` Russell King - ARM Linux
2012-10-23 17:15         ` Jon Masters
2012-10-23 19:14         ` Rob Herring

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=5076C78E.1020408@gmail.com \
    --to=robherring2@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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).