From: Suzanne Wood <suzannew@cs.pdx.edu>
To: herbert@gondor.apana.org.au, linux-kernel@vger.kernel.org
Cc: g4klx@g4klx.demon.co.uk, hch@infradead.org, jreuter@yaina.de,
paulmck@us.ibm.com, suzannew@cs.pdx.edu, walpole@cs.pdx.edu
Subject: Re: [RFC][PATCH] rcu in drivers/net/hamradio
Date: Fri, 14 Oct 2005 09:38:54 -0700 (PDT) [thread overview]
Message-ID: <200510141638.j9EGcsJa000437@rastaban.cs.pdx.edu> (raw)
Thank you and please consider the following patch to drivers/net/hamradio/bpqether.c.
> From: "Herbert Xu"
> Sent: Friday, October 14, 2005 6:37 AM
>
> Suzanne Wood <suzannew@cs.pdx.edu> wrote:
>>
>> (1) bpq_new_device() calls list_add_rcu() labeled as
>> "list protected by RTNL." The comment may need to go
>> since the only apparent rtnl_lock()/unlock() pair encloses
>> the call to bpq_free_device() in bpq_cleanup_driver()
>> called upon module_exit().
>
> The RTNL comment is correct actually.
>
> bpq_new_device can only be called from bpq_device_event which
> is called from a netdev event handler. All netdev event handlers
> must be called uner the RTNL.
Thank you very much. I'll reinstate the comment and
submit this corrected patch
Signed-off-by: suzannew@cs.pdx.edu
ChangeLog:
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().
This requires the insertion of rcu_read_lock()/unlock().
A consequence of list_for_each_entry_rcu(bpq, &bpq_devices, bpq_list)
is that the future dereference of the pointer to the bpqdev
struct bpq is rcu-protected. But bpq_get_ax25_dev()
returns bpq->axdev, a pointer to a net_device struct. The
rcu_read_lock() in bpq_rcv() likely implies that is another
pointer to receive rcu-protected dereference.
The rcu_read_lock()/unlock() in bpq_device_event()
are removed due to the following found by considering
the cases of the switch statement:
(1) bpq_new_device() calls list_add_rcu() labeled as
"list protected by RTNL."
(2) dev_close() as defined in net/core/dev.c
employs a memory barrier.
(3) bpq_free_device() calls list_del_rcu() which, according
to list.h, requires synchronize_rcu() which can block or
call_rcu() or call_rcu_bh() which cannot block.
None of these is called anywhere in the directory drivers/net,
so synchronize_irq() might address this.
-------
bpqether.c | 11 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
-------
--- src/linux-2.6.14-rc4/drivers/net/hamradio/bpqether.c 2005-10-10 18:19:19.000000000 -0700
+++ patch/linux-2.6.14-rc4/drivers/net/hamradio/bpqether.c 2005-10-14 08:56:12.000000000 -0700
@@ -144,10 +144,13 @@ static inline struct net_device *bpq_get
{
struct bpqdev *bpq;
- list_for_each_entry(bpq, &bpq_devices, bpq_list) {
+ rcu_read_lock();
+ list_for_each_entry_rcu(bpq, &bpq_devices, bpq_list) {
if (bpq->ethdev == dev)
+ rcu_read_unlock();
return bpq->axdev;
}
+ rcu_read_unlock();
return NULL;
}
@@ -179,7 +182,7 @@ static int bpq_rcv(struct sk_buff *skb,
goto drop;
rcu_read_lock();
- dev = bpq_get_ax25_dev(dev);
+ dev = rcu_dereference(bpq_get_ax25_dev(dev));
if (dev == NULL || !netif_running(dev))
goto drop_unlock;
@@ -561,8 +564,6 @@ static int bpq_device_event(struct notif
if (!dev_is_ethdev(dev))
return NOTIFY_DONE;
- rcu_read_lock();
-
switch (event) {
case NETDEV_UP: /* new ethernet device -> new BPQ interface */
if (bpq_get_ax25_dev(dev) == NULL)
@@ -581,7 +582,6 @@ static int bpq_device_event(struct notif
default:
break;
}
- rcu_read_unlock();
return NOTIFY_DONE;
}
next reply other threads:[~2005-10-14 16:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-14 16:38 Suzanne Wood [this message]
2005-10-14 22:36 ` Herbert Xu
-- strict thread matches above, loose matches on Subject: below --
2005-10-16 17:03 Suzanne Wood
2005-10-15 22:24 Suzanne Wood
2005-10-16 7:21 ` Herbert Xu
2005-10-15 7:57 Suzanne Wood
2005-10-15 8:05 ` Herbert Xu
2005-10-14 8:04 Suzanne Wood
2005-10-14 13:37 ` Herbert Xu
2005-10-15 11:24 ` Francois Romieu
2005-10-15 12:03 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200510141638.j9EGcsJa000437@rastaban.cs.pdx.edu \
--to=suzannew@cs.pdx.edu \
--cc=g4klx@g4klx.demon.co.uk \
--cc=hch@infradead.org \
--cc=herbert@gondor.apana.org.au \
--cc=jreuter@yaina.de \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@us.ibm.com \
--cc=walpole@cs.pdx.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®