Re: [patch rdma-next v3 1/2] net: mana: Change the function signature of mana_get_primary_netdev_rcu

From: Jason Gunthorpe
Date: Wed Mar 05 2025 - 13:51:10 EST


On Tue, Mar 04, 2025 at 04:00:01PM -0800, longli@xxxxxxxxxxxxxxxxx wrote:
>
> -struct net_device *mana_get_primary_netdev_rcu(struct mana_context *ac, u32 port_index)
> +struct net_device *mana_get_primary_netdev(struct mana_context *ac, u32 port_index)
> {
> struct net_device *ndev;
>
> - RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
> - "Taking primary netdev without holding the RCU read lock");
> if (port_index >= ac->num_ports)
> return NULL;
>
> + rcu_read_lock();
> +
> /* When mana is used in netvsc, the upper netdevice should be returned. */
> if (ac->ports[port_index]->flags & IFF_SLAVE)
> ndev = netdev_master_upper_dev_get_rcu(ac->ports[port_index]);
> else
> ndev = ac->ports[port_index];
>
> + dev_hold(ndev);
> + rcu_read_unlock();

That's much better, yes

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Jason