Commit bc0a7438 authored by Ralf Baechle's avatar Ralf Baechle Committed by Jeff Garzik

[PATCH] rcu in bpqether driver.

From Suzanne Wood <suzannew@cs.pdx.edu>:

Clarify RCU implementation in bpqether.c.

Because bpq_new_device() calls list_add_rcu() and bpq_free_device() calls
list_del_rcu(), substitute list_for_each_entry_rcu() for
list_for_each_entry() in bpq_get_ax25_dev() and in bpq_seq_start().

Add rcu dereference protection in bpq_seq_next().

The rcu_read_lock()/unlock() in bpq_device_event() are removed because
netdev event handlers are called with RTNL locking in place.

FYI: bpq_free_device() calls list_del_rcu() which, per list.h, requires
synchronize_rcu() which can block or call_rcu() or call_rcu_bh() which
cannot block.  Herbert Xu notes that synchronization is done here by
unregister_netdevice().  This calls synchronize_net() which in turn uses
synchronize_rcu().
Signed-off-by: default avatarRalf Baechle DL5RB <ralf@linux-mips.org>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent ad4ebed0
...@@ -144,7 +144,7 @@ static inline struct net_device *bpq_get_ax25_dev(struct net_device *dev) ...@@ -144,7 +144,7 @@ static inline struct net_device *bpq_get_ax25_dev(struct net_device *dev)
{ {
struct bpqdev *bpq; struct bpqdev *bpq;
list_for_each_entry(bpq, &bpq_devices, bpq_list) { list_for_each_entry_rcu(bpq, &bpq_devices, bpq_list) {
if (bpq->ethdev == dev) if (bpq->ethdev == dev)
return bpq->axdev; return bpq->axdev;
} }
...@@ -399,7 +399,7 @@ static void *bpq_seq_start(struct seq_file *seq, loff_t *pos) ...@@ -399,7 +399,7 @@ static void *bpq_seq_start(struct seq_file *seq, loff_t *pos)
if (*pos == 0) if (*pos == 0)
return SEQ_START_TOKEN; return SEQ_START_TOKEN;
list_for_each_entry(bpqdev, &bpq_devices, bpq_list) { list_for_each_entry_rcu(bpqdev, &bpq_devices, bpq_list) {
if (i == *pos) if (i == *pos)
return bpqdev; return bpqdev;
} }
...@@ -418,7 +418,7 @@ static void *bpq_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -418,7 +418,7 @@ static void *bpq_seq_next(struct seq_file *seq, void *v, loff_t *pos)
p = ((struct bpqdev *)v)->bpq_list.next; p = ((struct bpqdev *)v)->bpq_list.next;
return (p == &bpq_devices) ? NULL return (p == &bpq_devices) ? NULL
: list_entry(p, struct bpqdev, bpq_list); : rcu_dereference(list_entry(p, struct bpqdev, bpq_list));
} }
static void bpq_seq_stop(struct seq_file *seq, void *v) static void bpq_seq_stop(struct seq_file *seq, void *v)
...@@ -561,8 +561,6 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi ...@@ -561,8 +561,6 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
if (!dev_is_ethdev(dev)) if (!dev_is_ethdev(dev))
return NOTIFY_DONE; return NOTIFY_DONE;
rcu_read_lock();
switch (event) { switch (event) {
case NETDEV_UP: /* new ethernet device -> new BPQ interface */ case NETDEV_UP: /* new ethernet device -> new BPQ interface */
if (bpq_get_ax25_dev(dev) == NULL) if (bpq_get_ax25_dev(dev) == NULL)
...@@ -581,7 +579,6 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi ...@@ -581,7 +579,6 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
default: default:
break; break;
} }
rcu_read_unlock();
return NOTIFY_DONE; return NOTIFY_DONE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment