From patchwork Thu Oct 11 12:40:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 1581921 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id E14993FD9C for ; Thu, 11 Oct 2012 12:44:44 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TMI4Q-0000UH-My; Thu, 11 Oct 2012 12:40:58 +0000 Received: from mail-bk0-f49.google.com ([209.85.214.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TMI4M-0000TD-Lo for linux-arm-kernel@lists.infradead.org; Thu, 11 Oct 2012 12:40:55 +0000 Received: by mail-bk0-f49.google.com with SMTP id j4so889282bkw.36 for ; Thu, 11 Oct 2012 05:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; bh=1i7ohxxeuhNFWlvDpxWQihFSG2TZBEYhQ0xNkiywMoI=; b=jnR4ZsKudt/vSEc7qjJ0RQEyzrAnpjtDJ4LIA9NSC3z7gSxp3zOimaz4Gxm9z9ZmtQ cNHJMRTYY5HU43/2/fjuUS7DH0k0me2LUZAQTYJLxmpw9va3HAawrA2P2Z9v6haCneTJ poZMM/tAqieB3m0iXFsXZ5EZPclXNbYDHB7FV/5ZZo2TI3TGw9YQ5qw3ROdyTqXsd17t l6xZS9aZELBKuLooBuQXcdS4AuA/3GwgZj7exZ/7UBDE6J8PXiVnMw6bLMpMn6IG9zov qpanNixLTcJNe/mNxK8ktAvT20FANKR9Z+blGxvvw4sWqK5MVo2hNhIidBFqMFlU5DiH PCfQ== Received: by 10.204.151.9 with SMTP id a9mr280896bkw.2.1349959252570; Thu, 11 Oct 2012 05:40:52 -0700 (PDT) Received: from [172.28.90.114] ([172.28.90.114]) by mx.google.com with ESMTPS id m19sm3543042bkm.8.2012.10.11.05.40.50 (version=SSLv3 cipher=OTHER); Thu, 11 Oct 2012 05:40:51 -0700 (PDT) Subject: Re: alignment faults in 3.6 From: Eric Dumazet To: Arnd Bergmann In-Reply-To: <201210111228.25995.arnd@arndb.de> References: <20121005082439.GF4625@n2100.arm.linux.org.uk> <20121011103257.GO4625@n2100.arm.linux.org.uk> <1349952574.21172.8604.camel@edumazet-glaptop> <201210111228.25995.arnd@arndb.de> Date: Thu, 11 Oct 2012 14:40:48 +0200 Message-ID: <1349959248.21172.8970.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (eric.dumazet[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: =?ISO-8859-1?Q?M=E5ns_Rullg=E5rd?= , Russell King - ARM Linux , netdev@vger.kernel.org, David Laight , Jon Masters , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. 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. (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);