* [Patch net-next v3] netpoll: fix a rtnl lock assertion failure
@ 2013-01-14 10:43 Cong Wang
2013-01-14 10:54 ` Jiri Pirko
2013-01-14 17:07 ` Eric Dumazet
0 siblings, 2 replies; 6+ messages in thread
From: Cong Wang @ 2013-01-14 10:43 UTC (permalink / raw)
To: netdev; +Cc: Jiri Pirko, David S. Miller, Cong Wang
From: Cong Wang <amwang@redhat.com>
This patch fixes the following warning:
[ 72.013864] RTNL: assertion failed at net/core/dev.c (4955)
[ 72.017758] Pid: 668, comm: netpoll-prep-v6 Not tainted 3.8.0-rc1+ #474
[ 72.019582] Call Trace:
[ 72.020295] [<ffffffff8176653d>] netdev_master_upper_dev_get+0x35/0x58
[ 72.022545] [<ffffffff81784edd>] netpoll_setup+0x61/0x340
[ 72.024846] [<ffffffff815d837e>] store_enabled+0x82/0xc3
[ 72.027466] [<ffffffff815d7e51>] netconsole_target_attr_store+0x35/0x37
[ 72.029348] [<ffffffff811c3479>] configfs_write_file+0xe2/0x10c
[ 72.030959] [<ffffffff8115d239>] vfs_write+0xaf/0xf6
[ 72.032359] [<ffffffff81978a05>] ? sysret_check+0x22/0x5d
[ 72.033824] [<ffffffff8115d453>] sys_write+0x5c/0x84
[ 72.035328] [<ffffffff819789d9>] system_call_fastpath+0x16/0x1b
Just hold RCU read lock and call netdev_master_upper_dev_get_rcu(),
as suggested by Jiri.
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
---
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 9f05067..5d1f856 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -1055,11 +1055,14 @@ int netpoll_setup(struct netpoll *np)
return -ENODEV;
}
- if (netdev_master_upper_dev_get(ndev)) {
+ rcu_read_lock();
+ if (netdev_master_upper_dev_get_rcu(ndev)) {
+ rcu_read_unlock();
np_err(np, "%s is a slave device, aborting\n", np->dev_name);
err = -EBUSY;
goto put;
}
+ rcu_read_unlock();
if (!netif_running(ndev)) {
unsigned long atmost, atleast;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Patch net-next v3] netpoll: fix a rtnl lock assertion failure
2013-01-14 10:43 [Patch net-next v3] netpoll: fix a rtnl lock assertion failure Cong Wang
@ 2013-01-14 10:54 ` Jiri Pirko
2013-01-14 17:07 ` Eric Dumazet
1 sibling, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2013-01-14 10:54 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, David S. Miller
Mon, Jan 14, 2013 at 11:43:54AM CET, amwang@redhat.com wrote:
>From: Cong Wang <amwang@redhat.com>
>
>This patch fixes the following warning:
>
>[ 72.013864] RTNL: assertion failed at net/core/dev.c (4955)
>[ 72.017758] Pid: 668, comm: netpoll-prep-v6 Not tainted 3.8.0-rc1+ #474
>[ 72.019582] Call Trace:
>[ 72.020295] [<ffffffff8176653d>] netdev_master_upper_dev_get+0x35/0x58
>[ 72.022545] [<ffffffff81784edd>] netpoll_setup+0x61/0x340
>[ 72.024846] [<ffffffff815d837e>] store_enabled+0x82/0xc3
>[ 72.027466] [<ffffffff815d7e51>] netconsole_target_attr_store+0x35/0x37
>[ 72.029348] [<ffffffff811c3479>] configfs_write_file+0xe2/0x10c
>[ 72.030959] [<ffffffff8115d239>] vfs_write+0xaf/0xf6
>[ 72.032359] [<ffffffff81978a05>] ? sysret_check+0x22/0x5d
>[ 72.033824] [<ffffffff8115d453>] sys_write+0x5c/0x84
>[ 72.035328] [<ffffffff819789d9>] system_call_fastpath+0x16/0x1b
>
>Just hold RCU read lock and call netdev_master_upper_dev_get_rcu(),
>as suggested by Jiri.
>
>Cc: Jiri Pirko <jiri@resnulli.us>
>Cc: David S. Miller <davem@davemloft.net>
>Signed-off-by: Cong Wang <amwang@redhat.com>
Reviewed-by: Jiri Pirko <jiri@resnulli.us>
>
>---
>diff --git a/net/core/netpoll.c b/net/core/netpoll.c
>index 9f05067..5d1f856 100644
>--- a/net/core/netpoll.c
>+++ b/net/core/netpoll.c
>@@ -1055,11 +1055,14 @@ int netpoll_setup(struct netpoll *np)
> return -ENODEV;
> }
>
>- if (netdev_master_upper_dev_get(ndev)) {
>+ rcu_read_lock();
>+ if (netdev_master_upper_dev_get_rcu(ndev)) {
>+ rcu_read_unlock();
> np_err(np, "%s is a slave device, aborting\n", np->dev_name);
> err = -EBUSY;
> goto put;
> }
>+ rcu_read_unlock();
>
> if (!netif_running(ndev)) {
> unsigned long atmost, atleast;
Thanks Amerigo.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch net-next v3] netpoll: fix a rtnl lock assertion failure
2013-01-14 10:43 [Patch net-next v3] netpoll: fix a rtnl lock assertion failure Cong Wang
2013-01-14 10:54 ` Jiri Pirko
@ 2013-01-14 17:07 ` Eric Dumazet
2013-01-14 17:09 ` Eric Dumazet
1 sibling, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2013-01-14 17:07 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, Jiri Pirko, David S. Miller
On Mon, 2013-01-14 at 18:43 +0800, Cong Wang wrote:
> From: Cong Wang <amwang@redhat.com>
>
> This patch fixes the following warning:
>
> [ 72.013864] RTNL: assertion failed at net/core/dev.c (4955)
> [ 72.017758] Pid: 668, comm: netpoll-prep-v6 Not tainted 3.8.0-rc1+ #474
> [ 72.019582] Call Trace:
> [ 72.020295] [<ffffffff8176653d>] netdev_master_upper_dev_get+0x35/0x58
> [ 72.022545] [<ffffffff81784edd>] netpoll_setup+0x61/0x340
> [ 72.024846] [<ffffffff815d837e>] store_enabled+0x82/0xc3
> [ 72.027466] [<ffffffff815d7e51>] netconsole_target_attr_store+0x35/0x37
> [ 72.029348] [<ffffffff811c3479>] configfs_write_file+0xe2/0x10c
> [ 72.030959] [<ffffffff8115d239>] vfs_write+0xaf/0xf6
> [ 72.032359] [<ffffffff81978a05>] ? sysret_check+0x22/0x5d
> [ 72.033824] [<ffffffff8115d453>] sys_write+0x5c/0x84
> [ 72.035328] [<ffffffff819789d9>] system_call_fastpath+0x16/0x1b
>
> Just hold RCU read lock and call netdev_master_upper_dev_get_rcu(),
> as suggested by Jiri.
>
> Cc: Jiri Pirko <jiri@resnulli.us>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Cong Wang <amwang@redhat.com>
>
> ---
> diff --git a/net/core/netpoll.c b/net/core/netpoll.c
> index 9f05067..5d1f856 100644
> --- a/net/core/netpoll.c
> +++ b/net/core/netpoll.c
> @@ -1055,11 +1055,14 @@ int netpoll_setup(struct netpoll *np)
> return -ENODEV;
> }
>
> - if (netdev_master_upper_dev_get(ndev)) {
> + rcu_read_lock();
> + if (netdev_master_upper_dev_get_rcu(ndev)) {
> + rcu_read_unlock();
> np_err(np, "%s is a slave device, aborting\n", np->dev_name);
> err = -EBUSY;
> goto put;
> }
> + rcu_read_unlock();
>
> if (!netif_running(ndev)) {
> unsigned long atmost, atleast;
> --
Strange, why dont we call netdev_master_upper_dev_get() instead ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch net-next v3] netpoll: fix a rtnl lock assertion failure
2013-01-14 17:07 ` Eric Dumazet
@ 2013-01-14 17:09 ` Eric Dumazet
2013-01-14 23:13 ` David Miller
2013-01-15 2:23 ` Cong Wang
0 siblings, 2 replies; 6+ messages in thread
From: Eric Dumazet @ 2013-01-14 17:09 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, Jiri Pirko, David S. Miller
On Mon, 2013-01-14 at 09:07 -0800, Eric Dumazet wrote:
> Strange, why dont we call netdev_master_upper_dev_get() instead ?
>
>
What I meant is : the result of this check might be of little use, if we
don't hold any lock preventing another thread to change things behind
us.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch net-next v3] netpoll: fix a rtnl lock assertion failure
2013-01-14 17:09 ` Eric Dumazet
@ 2013-01-14 23:13 ` David Miller
2013-01-15 2:23 ` Cong Wang
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2013-01-14 23:13 UTC (permalink / raw)
To: eric.dumazet; +Cc: amwang, netdev, jiri
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 14 Jan 2013 09:09:56 -0800
> On Mon, 2013-01-14 at 09:07 -0800, Eric Dumazet wrote:
>
>> Strange, why dont we call netdev_master_upper_dev_get() instead ?
>>
>>
>
> What I meant is : the result of this check might be of little use, if we
> don't hold any lock preventing another thread to change things behind
> us.
Agreed, this test is going to be racey.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch net-next v3] netpoll: fix a rtnl lock assertion failure
2013-01-14 17:09 ` Eric Dumazet
2013-01-14 23:13 ` David Miller
@ 2013-01-15 2:23 ` Cong Wang
1 sibling, 0 replies; 6+ messages in thread
From: Cong Wang @ 2013-01-15 2:23 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev, Jiri Pirko, David S. Miller
On Mon, 2013-01-14 at 09:09 -0800, Eric Dumazet wrote:
> On Mon, 2013-01-14 at 09:07 -0800, Eric Dumazet wrote:
>
> > Strange, why dont we call netdev_master_upper_dev_get() instead ?
> >
> >
>
> What I meant is : the result of this check might be of little use, if we
> don't hold any lock preventing another thread to change things behind
> us.
>
>
Even if so, enslaving this device can still happen after we release the
rtnl lock, unless we take this lock for the whole netpoll_setup().
Am I missing anything?
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-01-15 2:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-14 10:43 [Patch net-next v3] netpoll: fix a rtnl lock assertion failure Cong Wang
2013-01-14 10:54 ` Jiri Pirko
2013-01-14 17:07 ` Eric Dumazet
2013-01-14 17:09 ` Eric Dumazet
2013-01-14 23:13 ` David Miller
2013-01-15 2:23 ` Cong Wang
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).