Re: [PATCH] cnic: don't take the rtnl_read_lock in cnic_rcv_netevent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 30, 2014 at 10:58:11AM -0700, Michael Chan wrote:
> On Fri, 2014-05-30 at 11:00 -0400, Neil Horman wrote: 
> > The Cnic driver handles lots of ulp operations in its netdevice event hanlder.
> > To do this, it accesses the ulp_ops array, which is an rcu protected array.
> > However, some ulp operations (like bnx2fc_indicate_netevent) try to lock
> > mutexes, which might sleep (somthing that you can't do while holding rcu read
> > side locks if you've configured non-preemptive rcu.
> > 
> > Fix this by changing the dereference method.  All accesses to the ulp_ops array
> > for a cnic dev are modified under the protection of the rtnl lock, and so we can
> > safely just use rcu_dereference_rtnl, and remove the rcu_read_lock here
> 
> Because the bnx2fc function can sleep, we need a more complete fix to
> prevent the ulp_ops from going away when the device is unregistered.
> synchronize_rcu() won't be able to protect it.  I'll post the patch
> later today.  Thanks.
> 
The device can't be unregistered while we hold rtnl, can it?  Since we hold it
in this path it seems safe to me, even if we sleep, or am I missing something?
Neil

> > 
> > Signed-off-by: Neil Horman <nhorman@xxxxxxxxxxxxx>
> > CC: "David S. Miller" <davem@xxxxxxxxxxxxx>
> > CC: Michael Chan <mchan@xxxxxxxxxxxx>
> > CC: fcoe-devel@xxxxxxxxxxxxx
> > CC: Robert Love <robert.w.love@xxxxxxxxx>
> > CC: Vasu Dev <vasu.dev@xxxxxxxxx>
> > ---
> >  drivers/net/ethernet/broadcom/cnic.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
> > index f58a8b8..bfdb9f0 100644
> > --- a/drivers/net/ethernet/broadcom/cnic.c
> > +++ b/drivers/net/ethernet/broadcom/cnic.c
> > @@ -5622,12 +5622,11 @@ static void cnic_rcv_netevent(struct cnic_local *cp, unsigned long event,
> >  {
> >  	int if_type;
> >  
> > -	rcu_read_lock();
> >  	for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) {
> >  		struct cnic_ulp_ops *ulp_ops;
> >  		void *ctx;
> >  
> > -		ulp_ops = rcu_dereference(cp->ulp_ops[if_type]);
> > +		ulp_ops = rcu_dereference_rtnl(cp->ulp_ops[if_type]);
> >  		if (!ulp_ops || !ulp_ops->indicate_netevent)
> >  			continue;
> >  
> > @@ -5635,7 +5634,6 @@ static void cnic_rcv_netevent(struct cnic_local *cp, unsigned long event,
> >  
> >  		ulp_ops->indicate_netevent(ctx, event, vlan_id);
> >  	}
> > -	rcu_read_unlock();
> >  }
> >  
> >  /* netdev event handler */
> 
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Discussion]     [TCP Instrumentation]     [Ethernet Bridging]     [Linux Wireless Networking]     [Linux WPAN Networking]     [Linux Host AP]     [Linux WPAN Networking]     [Linux Bluetooth Networking]     [Linux ATH6KL Networking]     [Linux Networking Users]     [Linux Coverity]     [VLAN]     [Git]     [IETF Annouce]     [Linux Assembly]     [Security]     [Bugtraq]     [Yosemite Information]     [MIPS Linux]     [ARM Linux Kernel]     [ARM Linux]     [Linux Virtualization]     [Linux IDE]     [Linux RAID]     [Linux SCSI]