[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YwOe5hNa1PJFr077@lunn.ch>
Date: Mon, 22 Aug 2022 17:21:10 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Casper Andersson <casper.casan@...il.com>
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
> +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.
> +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.
Andrew
Powered by blists - more mailing lists