From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4759C7EE43 for ; Mon, 12 Jun 2023 22:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wkuONiPibEeUUZAKrnguMaB3CRFUE+CWzdmb+c8v1eM=; b=UpIhgi2qvEK2qJGbLN8ksHf1se Rv7oVKJi13gZF9VbBdBKahQwPKuNB+rn4CgjCFATY4QyK/ZupaEX/nJHnAvgL3qdwqTeMkHjm2Jxk m1zj0xoj7XhmmeTkeWj8uUt9YnVpgPtX8OCPDlIch5mejr/BmYusA+IO9PmaOBiDGkFtNi4ppls6F DQj0oTW5OtAmg09+m3ulHwwWB+kVLU+J7aN7lFDl2TADNAmnOgVejeZMIsfB0g9yWQYnXi/KCaYga mUNUNcPhk1hZmuz79xSzXlj7CkTKs61zevYczpqgzkKQkt57Y4hwh3M383rP6cC8ZtR+yZkeFRA9a cq9GAyhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q8q7U-005pyE-2T; Mon, 12 Jun 2023 22:34:40 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q8q7S-005pwB-0b for linux-arm-kernel@bombadil.infradead.org; Mon, 12 Jun 2023 22:34:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Lig8bfKofULub0rdesjmJTGhCjl+c+cZITPDTaTBD/c=; b=LCbp6tGVMgOxFvhGkOBMa1ofFy UopRJSmGOORfeVTC748MT9GRSMYiGE+y3IdMlIGO0U+XOyC+fq6DwPR1G2FYRf82nR/R8CsrrG6E7 mhty0Qpl1zv/bXKuYPzNd1UE9N/34ezpE0W5ECtVqtxH35/I8rnc3nte5BEjYVKsIeff7Si1otCi3 xKJRuWU5wQP430FNlkkC4jstwTxDJV4kinbHfAgpH8+YBc2sIGuWOboHdIRoSRcGKJbwthXEhSiGz ZEIyGnlkqxuu5QImIGQnwyRYzAfDWTbShj90iUSHQHPMQXRec9xBFiIvWx+ZasFJtJ6z0ufFjb6uY D3r46Yxw==; Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1q8pUm-0037O3-FX for linux-arm-kernel@lists.infradead.org; Mon, 12 Jun 2023 21:54:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686606843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Lig8bfKofULub0rdesjmJTGhCjl+c+cZITPDTaTBD/c=; b=WSP/+8dtM7LEY7fSlBaAkDyREk/STy7BiBoMz9BPoTP5xINNUlN0gYSKk7NEHiFHojh83E eGjR2/408c0HWDwBmP/cKwLOPoAt4To9jW/67vP/HbHQy0VQfZre8PfZRzq/KNTkcNEjWT Dmn9tY/ydD2gQX2eB5MsrnmEpPmN2K4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686606844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Lig8bfKofULub0rdesjmJTGhCjl+c+cZITPDTaTBD/c=; b=fPWFmFwunKiUaaRMWXF7Axt745gMn/2/WIrIfhRr2ZLIKp1ol1be3OU6BwSATvVitBkYCd k4mQeyLUQkSfeKmvrn97sOxVMJ1spQYE3SJ7/Ktukrd1DaD7FYFUdjCitMrmTD6nPdAv8V B1etNfyV57OI3+T7Vp7DC70a37pB3+w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686606877; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Lig8bfKofULub0rdesjmJTGhCjl+c+cZITPDTaTBD/c=; b=UpcDLJb6vpTuui06wBkj5TTCqqYm8FMsPUSR689OI0IMasgiLSDpRrPVWphqo8KkJDlJLB ae2f9tEFmGs38sURaM1/QqtJvwZwUCAU0RBDK0o8uab/ILDB10NAKF8IrmiEJkhZqSj+dx wjAhH/QnTywwioJH7bGzRm9kg4LeMuQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-W1ZvhZdEM3qOs92rcYUgtg-1; Mon, 12 Jun 2023 17:52:50 -0400 X-MC-Unique: W1ZvhZdEM3qOs92rcYUgtg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-30e4d85e1ffso7233716f8f.0 for ; Mon, 12 Jun 2023 14:52:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686606769; x=1689198769; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Lig8bfKofULub0rdesjmJTGhCjl+c+cZITPDTaTBD/c=; b=GaSscONK1wGEsKAbH2vKyZCUFchiQnJnShWFrXDEn5Pim+buWxR5hpYusn5oClnWmh CR7D5TmqeS2Ge6elXjwfxfN88rAom7Ts9x6S9Z1KA9AxCoYXqCoWuQzBB4sMQHTliPB+ polC8n4S5ryZ4f20em6XKYmr2rclIsZ2gVNySsBqCGZ6ixvu9tsxpV6X5hjL4h2zkk6m 7mR2j650GNp3P7ZBTmmJwQ61lDWga/WBgmKDbT8/IlJxSfHxJH7h8p+Nn1+fAP/vuTxb Z9QpAf8RTEnMCSrwiW3aboALkLfbygg53eZEB8oP3bHWvc6dCtEq60YB5AtjKH7FyLkb gSIg== X-Gm-Message-State: AC+VfDwwYOncfCyTtCVvTs9tNE+u0ilcZuhKa7bYFROKvwGn6ND8XRKu 06boRtIJU1wCCXAX/fN+OLOe7yo3J/plJimXZl2IQuLCLUlVdUEYDQDVlS6zTp9PNKkoa86TPxe BdnlPJEjuRMgI5Z4sR7GO5Ok+4iq38AN4rcE= X-Received: by 2002:a5d:4e85:0:b0:30a:d2e6:6a78 with SMTP id e5-20020a5d4e85000000b0030ad2e66a78mr5644106wru.24.1686606769102; Mon, 12 Jun 2023 14:52:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ533dy2vongGwe/ijXoDrZL6tuCydkYrtVs8jx5yk/Ac46ZodmFGImZx55e7jFjVeMCqkk2YQ== X-Received: by 2002:a5d:4e85:0:b0:30a:d2e6:6a78 with SMTP id e5-20020a5d4e85000000b0030ad2e66a78mr5644097wru.24.1686606768769; Mon, 12 Jun 2023 14:52:48 -0700 (PDT) Received: from localhost (net-130-25-106-149.cust.vodafonedsl.it. [130.25.106.149]) by smtp.gmail.com with ESMTPSA id a11-20020a05600c224b00b003f8126bcf34sm8119367wmm.48.2023.06.12.14.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 14:52:48 -0700 (PDT) Date: Mon, 12 Jun 2023 23:52:46 +0200 From: Lorenzo Bianconi To: "Russell King (Oracle)" Cc: Daniel Golle , netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, AngeloGioacchino Del Regno , Matthias Brugger , Lorenzo Bianconi , Mark Lee , Sean Wang , John Crispin , Felix Fietkau , Conor Dooley , Krzysztof Kozlowski , Rob Herring , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Sam Shih Subject: Re: [PATCH net-next 3/8] net: ethernet: mtk_eth_soc: move MAX_DEVS in mtk_soc_data Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230612_225440_683603_720637F0 X-CRM114-Status: GOOD ( 20.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============7614548866775809105==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============7614548866775809105== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+jV/BeWnWuWrIw8B" Content-Disposition: inline --+jV/BeWnWuWrIw8B Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > On Sun, Jun 11, 2023 at 01:35:17AM +0100, Daniel Golle wrote: > > @@ -1106,14 +1105,14 @@ struct mtk_eth { > > spinlock_t tx_irq_lock; > > spinlock_t rx_irq_lock; > > struct net_device dummy_dev; > > - struct net_device *netdev[MTK_MAX_DEVS]; > > - struct mtk_mac *mac[MTK_MAX_DEVS]; > > + struct net_device **netdev; > > + struct mtk_mac **mac; > > int irq[3]; > > u32 msg_enable; > > unsigned long sysclk; > > struct regmap *ethsys; > > struct regmap *infra; > > - struct phylink_pcs *sgmii_pcs[MTK_MAX_DEVS]; > > + struct phylink_pcs **sgmii_pcs; > > struct regmap *pctl; > > bool hwlro; > > refcount_t dma_refcnt; >=20 > Is it really worth the extra allocations? >=20 > There's three pointers here per device. Let's talk about modern systems, > so that's 8 bytes each, and if MTK_MAX_DEVS was two, that's 48 bytes in > all. If we expanded the array to allow three, that would be 72 bytes. >=20 > If we allocate separately, then we're allocating 16 or 24 bytes three > times depending on whether we want two or three of them. >=20 > On arm64, I'm seeing the minimum slab size as 128 bytes, which means > that's the minimum memory allocation. So, allocating three arrays will > be 384 bytes in all, irrespective of whether we want two or three > entries. >=20 > That's a waste of about 5x the memory over just expanding the arrays! ack, I agree. I will fix it. Regards, Lorenzo >=20 > If you want to go down the route of dynamically allocating these, it > would make better sense to combine them into a single structure that > itself is an array, and thus requiring only one allocation. That > reduces the wastage to about 56 bytes for three ports or 80 bytes > for two. >=20 > Thanks. >=20 > --=20 > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! >=20 --+jV/BeWnWuWrIw8B Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCZIeTrgAKCRA6cBh0uS2t rNj4AP9deO0Gr7/2QBPFl0zwa5owkvBsU7Fw1f3Xo0VOcoEEOQEApfOn/gVjmHQW s9GY/xg59Fhdvwhh8lfHmXEvgidsqAg= =V5g1 -----END PGP SIGNATURE----- --+jV/BeWnWuWrIw8B-- --===============7614548866775809105== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============7614548866775809105==--