netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cnic: don't take the rtnl_read_lock in cnic_rcv_netevent
@ 2014-05-30 15:00 Neil Horman
  2014-05-30 17:58 ` Michael Chan
  0 siblings, 1 reply; 8+ messages in thread
From: Neil Horman @ 2014-05-30 15:00 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: fcoe-devel-s9riP+hp16TNLxjTenLetw, David S. Miller

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

Signed-off-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
CC: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
CC: Michael Chan <mchan-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
CC: fcoe-devel-s9riP+hp16TNLxjTenLetw@public.gmane.org
CC: Robert Love <robert.w.love-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
CC: Vasu Dev <vasu.dev-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 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 */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-05-31  5:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-30 15:00 [PATCH] cnic: don't take the rtnl_read_lock in cnic_rcv_netevent Neil Horman
2014-05-30 17:58 ` Michael Chan
     [not found]   ` <1401472691.9728.145.camel-WIqd6NlzC1zwyCTbCWje6raTQr+y5IJFqs7JOtOhHmkAvxtiuMwx3w@public.gmane.org>
2014-05-30 20:03     ` Neil Horman
     [not found]       ` <20140530200311.GG3144-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-05-30 20:13         ` Michael Chan
2014-05-30 20:38           ` Neil Horman
     [not found]             ` <20140530203823.GH3144-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-05-30 20:58               ` Michael Chan
     [not found]                 ` <1401483513.9728.158.camel-WIqd6NlzC1zwyCTbCWje6raTQr+y5IJFqs7JOtOhHmkAvxtiuMwx3w@public.gmane.org>
2014-05-31  2:41                   ` Neil Horman
     [not found]                     ` <20140531024108.GA27184-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2014-05-31  5:50                       ` Michael Chan

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).