[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220823075215.gunhf2tsss3zpuip@wse-c0155>
Date: Tue, 23 Aug 2022 09:52:15 +0200
From: Casper Andersson <casper.casan@...il.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
Horatiu Vultur <horatiu.vultur@...rochip.com>,
Lars Povlsen <lars.povlsen@...rochip.com>,
Steen Hegelund <Steen.Hegelund@...rochip.com>,
UNGLinuxDriver@...rochip.com
Subject: Re: [PATCH net-next 2/3] net: sparx5: add list for mdb entries in
driver
On 2022-08-22 17:21, Andrew Lunn wrote:
> > +struct sparx5_mdb_entry {
> > + struct list_head list;
> > + unsigned char addr[ETH_ALEN];
> > + u16 vid;
> > + DECLARE_BITMAP(port_mask, SPX5_PORTS);
> > + bool cpu_copy;
> > + u16 pgid_idx;
> > +};
>
> You have a number of holes in that structure. Maybe this is better:
>
> > +struct sparx5_mdb_entry {
> > + struct list_head list;
> > + DECLARE_BITMAP(port_mask, SPX5_PORTS);
> > + unsigned char addr[ETH_ALEN];
> > + bool cpu_copy;
> > + u16 vid;
> > + u16 pgid_idx;
> > +};
>
> Hopefully the compiler can pack the bool straight after the 6 byte MAC
> address. And the two u16 should make one u32.
I had not considered that. Will fix for v2 and keep in mind for the
future!
> > +static int sparx5_alloc_mdb_entry(struct sparx5 *sparx5,
> > + const unsigned char *addr,
> > + u16 vid,
> > + struct sparx5_mdb_entry **entry_out)
> > +{
> > + struct sparx5_mdb_entry *entry;
> > + u16 pgid_idx;
> > + int err;
> > +
> > + entry = devm_kzalloc(sparx5->dev, sizeof(struct sparx5_mdb_entry), GFP_ATOMIC);
>
> Does devm_kzalloc make sense here? A MDB entry has a much shorter life
> time than the driver. devm has overheads, so it is good for large
> allocations which last as long as the device, but less so for lots of
> small short lives structures.
You're right. Reading up on it I can see why kzalloc would make more
sense. Will fix! Do I have to free any remaining mdb entries when the
module is unloaded? Or is it able to handle that by deleting them when
unregistering?
Thanks for the feedback.
Best regards
Casper
Powered by blists - more mailing lists