From patchwork Sun Sep 19 10:38:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Salvaterra X-Patchwork-Id: 1529823 X-Patchwork-Delegate: rsalvaterra@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=QfSgiFQ2; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=QVm9t9eN; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4HC44K11MKz9sSn for ; Sun, 19 Sep 2021 20:41:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=am0ugl41tbaKcE7mgLU3wPqvWowSTziVTUvGKlLwwd0=; b=QfSgiFQ2TT1Ji8 WidavOsb4lpI/7r8dLT/Wz4Hen1xNyFa94jk6J84SVU8HYsFGW8NhEDGg19QQNurHV6yw7ZU6mRKH 0prY9MOWccjwVkEe80z/X7FqfL02sDOF74v2rMEKzarzCOG+aW5csyVLIlY5W2/53g1CtgUA41AZA 5oR1sLRiLDe3cK0K3oNsPgxEXFdt5pIxo0H7OkaKcRKmySLFRoRLRiuIF9KeGjr3cFMI7yIyyW+Rz EoMg6/lPJC/MLTyzMcvULuUocAjWCHsFjF5yHClpwj19sW931+X8bOvv1nkNKjgBOL4SUSzHf4p+3 SN3ASHmqVLfzIdRT04Zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mRuDo-00H7vv-A9; Sun, 19 Sep 2021 10:38:56 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mRuDl-00H7vR-3P for openwrt-devel@lists.openwrt.org; Sun, 19 Sep 2021 10:38:54 +0000 Received: by mail-ed1-x52d.google.com with SMTP id v22so44429112edd.11 for ; Sun, 19 Sep 2021 03:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=O8kkbd1lVtOvJPMJbalrf+1+hi1C5zv7wa1uyZlOD+c=; b=QVm9t9eNFZ64IW/xK3VDISA9EuMqFiPXzcmAj41Gzv32x3iPtJRxBLlh4oeJ1BGRha GDXLH6qjBOiRd4v+D7JNFT3ia4y17R+UtJoG3nZoZmykvr7D1gvwJ62Qwsip392Uh//h CTYj95oUD2llUr+3O7gPNAtlADMyHi2ZYCWsuI2Y5WcXLgCSJloJBqBmejo2IX3HPBXd PeaYOFmK0L3XBqc0deMdbL/6kLPAQqOLorKRpb0+dVExZEEtaMXSWDtMpXWrkuJHO9IR 7ynIX/yZEkQavEkgvgDR03zRhsqJb8iBATM1R9sGv5fgDUy2pBSmc3/8pgXDDoWRKdhA ZTcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=O8kkbd1lVtOvJPMJbalrf+1+hi1C5zv7wa1uyZlOD+c=; b=rXJ8S6h0haJlIVE2+/YspyIXCWGPfp0iR5akt14LQMDDD7SyjDFoTHTHyPbw4J7Map 6/uQxygSrrYEoRgto0AwgYgoLOIvm0zrZcHqL57zJqBz6u4Q/ltJ+Wo0hAybDjcAw1uB EhogSroqksjClsZu5Uriq9tO2wx0Rr4wwmnjaiP3vvUKO5pM0YgK4SArdJj1lE/8c1aF wx49pXGEvPHoWn2kQkB5J9+aVQsoQvCleHUbgAs9hujdPVkVQYFfrALBAZuNj0QO7s+i WZ0dGkzSauoL4RqUdYxvlFVChMpzq9t8rIimwNP8L3Ylh1vEcO2u/GrYpn8Hmiqws5+E QfLw== X-Gm-Message-State: AOAM530jZWOVyULHxHoZqRmtNpSD/guN9zCKFGb7We27NXeIthjaz3cP r+NN5a7wOOt7KjZjTKedk9l37x5/UA== X-Google-Smtp-Source: ABdhPJy7WRX80xLr9FNyggTNL/MpXsJ5M9oDuFqmagtDwgO/2jEdoeam+7KV3JhkTHaXV02Nw+e6ug== X-Received: by 2002:a17:906:2b84:: with SMTP id m4mr22318959ejg.179.1632047927704; Sun, 19 Sep 2021 03:38:47 -0700 (PDT) Received: from crystalwell.adg.lan (a95-94-64-141.cpe.netcabo.pt. [95.94.64.141]) by smtp.gmail.com with ESMTPSA id a5sm5670186edm.37.2021.09.19.03.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Sep 2021 03:38:47 -0700 (PDT) From: Rui Salvaterra To: openwrt-devel@lists.openwrt.org Cc: rosenp@gmail.com, Rui Salvaterra Subject: [PATCH] ath79/ag71xx: rearrange ag71xx structs to remove holes Date: Sun, 19 Sep 2021 11:38:39 +0100 Message-Id: <20210919103839.2503-1-rsalvaterra@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210919_033853_210946_647D399F X-CRM114-Status: GOOD ( 14.48 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Rosen Penev Remove ____cacheline_aligned attribute to ring structs. This actually causes holes in the ag71xx struct as well as lower performance. Rearrange struct members to fall within respective cachelines. The RX ring struct now does not share a cacheline with the TX ring. The NAPI struct now takes up its own cachelines and does not share. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:52d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [rsalvaterra[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rosen Penev Remove ____cacheline_aligned attribute to ring structs. This actually causes holes in the ag71xx struct as well as lower performance. Rearrange struct members to fall within respective cachelines. The RX ring struct now does not share a cacheline with the TX ring. The NAPI struct now takes up its own cachelines and does not share. According to pahole -C ag71xx -c 32 Before: struct ag71xx { /* size: 384, cachelines: 12, members: 22 */ /* sum members: 375, holes: 2, sum holes: 9 */ After: struct ag71xx { /* size: 376, cachelines: 12, members: 22 */ /* last cacheline: 24 bytes */ Signed-off-by: Rosen Penev [Fix typos in the patch description] Signed-off-by: Rui Salvaterra --- The ag71xx_ring changes are already part of the upstream driver. However, since we're not using it at all yet, let's apply this to our driver for the time being, as David explicitly requests performance numbers before applying it upstream [1] (and rightly so, in my opinion). [1] https://lore.kernel.org/netdev/20190725.112108.2287417619951369896.davem@davemloft.net/ .../net/ethernet/atheros/ag71xx/ag71xx.h | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h index 5ff9439f0d..6ed1f78459 100644 --- a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h +++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h @@ -107,13 +107,16 @@ struct ag71xx_buf { }; struct ag71xx_ring { - struct ag71xx_buf *buf; - u8 *descs_cpu; - dma_addr_t descs_dma; - u16 desc_split; - u16 order; + /* "Hot" fields in the data path. */ unsigned int curr; unsigned int dirty; + + /* "Cold" fields - not used in the data path. */ + struct ag71xx_buf *buf; + u16 order; + u16 desc_split; + dma_addr_t descs_dma; + u8 *descs_cpu; }; struct ag71xx_int_stats { @@ -151,21 +154,20 @@ struct ag71xx { * Critical data related to the per-packet data path are clustered * early in this structure to help improve the D-cache footprint. */ - struct ag71xx_ring rx_ring ____cacheline_aligned; - struct ag71xx_ring tx_ring ____cacheline_aligned; + struct ag71xx_ring rx_ring; + u16 rx_buf_size; + u16 rx_buf_offset; + u32 msg_enable; + struct ag71xx_ring tx_ring; int mac_idx; - u16 desc_pktlen_mask; - u16 rx_buf_size; - u8 rx_buf_offset; u8 tx_hang_workaround:1; + struct napi_struct napi; struct net_device *dev; struct platform_device *pdev; spinlock_t lock; - struct napi_struct napi; - u32 msg_enable; /* * From this point onwards we're not looking at per-packet fields. @@ -188,12 +190,12 @@ struct ag71xx { unsigned int speed; int duplex; - struct delayed_work restart_work; - struct timer_list oom_timer; - struct reset_control *mac_reset; struct reset_control *mdio_reset; + struct delayed_work restart_work; + struct timer_list oom_timer; + u32 fifodata[3]; u32 plldata[3]; u32 pllreg[3];