* Re: [PATCH net-next 3/8] net: ethernet: mtk_eth_soc: move MAX_DEVS in mtk_soc_data
[not found] ` <ZIb6604WRJsevaWN@shell.armlinux.org.uk>
@ 2023-06-12 21:52 ` Lorenzo Bianconi
0 siblings, 0 replies; only message in thread
From: Lorenzo Bianconi @ 2023-06-12 21:52 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Daniel Golle, netdev, linux-mediatek, linux-arm-kernel,
linux-kernel, devicetree, 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
[-- Attachment #1.1: Type: text/plain, Size: 1936 bytes --]
> 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;
>
> Is it really worth the extra allocations?
>
> 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.
>
> If we allocate separately, then we're allocating 16 or 24 bytes three
> times depending on whether we want two or three of them.
>
> 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.
>
> That's a waste of about 5x the memory over just expanding the arrays!
ack, I agree. I will fix it.
Regards,
Lorenzo
>
> 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.
>
> Thanks.
>
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-12 22:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <ZIUWxQ9H7hNSd6rJ@makrotopia.org>
[not found] ` <ZIb6604WRJsevaWN@shell.armlinux.org.uk>
2023-06-12 21:52 ` [PATCH net-next 3/8] net: ethernet: mtk_eth_soc: move MAX_DEVS in mtk_soc_data Lorenzo Bianconi
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).