* unregister_netdev() deadlock
@ 2008-02-27 15:44 Jeba Anandhan
2008-02-27 16:46 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Jeba Anandhan @ 2008-02-27 15:44 UTC (permalink / raw)
To: netdev; +Cc: matthew.hattersley
Hi all,
I have doubts about unregister the netdevice.
Scenario
I have two netdevice entities. I wish to unregister one entity.
struct net_device *dev1;
struct net_device *dev2;
dev1->timer = XXX;
dev2->timer = YYY;
dev1->ioctl() {
...
case delete_other:
unregister_netdev(dev2);
free_netdev(dev2);
return 0;
...
}
The dev2->refcnt is not zero in this case. unregister_netdev(dev2) cause
deadlock. Could you tell me why it happens?.
It works smoothly when we call the unregister_netdev(dev2) from
cleanup_module(). dev2->refcnt is not zero in this case. Still it is
able to unregister.
Thanks
Jeba
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: unregister_netdev() deadlock
2008-02-27 15:44 unregister_netdev() deadlock Jeba Anandhan
@ 2008-02-27 16:46 ` Stephen Hemminger
2008-02-27 17:05 ` Jeba Anandhan
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2008-02-27 16:46 UTC (permalink / raw)
To: Jeba Anandhan; +Cc: netdev, matthew.hattersley
On Wed, 27 Feb 2008 15:44:54 +0000
Jeba Anandhan <jeba.anandhan@vaioni.com> wrote:
> Hi all,
> I have doubts about unregister the netdevice.
>
> Scenario
> I have two netdevice entities. I wish to unregister one entity.
>
> struct net_device *dev1;
> struct net_device *dev2;
>
> dev1->timer = XXX;
> dev2->timer = YYY;
>
> dev1->ioctl() {
>
> ...
> case delete_other:
> unregister_netdev(dev2);
> free_netdev(dev2);
> return 0;
> ...
> }
>
> The dev2->refcnt is not zero in this case. unregister_netdev(dev2) cause
> deadlock. Could you tell me why it happens?.
>
>
> It works smoothly when we call the unregister_netdev(dev2) from
> cleanup_module(). dev2->refcnt is not zero in this case. Still it is
> able to unregister.
>
>
> Thanks
> Jeba
>
You need to properly manage device refcounts (or delete both).
Also since dev1->ioctl is called with RTNL you can't:
use unregister_netdev() recursive locking (use unregister_netdevice)
or call free_netdev because of netdevice could still be in use (use dev->destructor instead).
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: unregister_netdev() deadlock
2008-02-27 16:46 ` Stephen Hemminger
@ 2008-02-27 17:05 ` Jeba Anandhan
0 siblings, 0 replies; 3+ messages in thread
From: Jeba Anandhan @ 2008-02-27 17:05 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, matthew.hattersley
On Wed, 2008-02-27 at 08:46 -0800, Stephen Hemminger wrote:
> On Wed, 27 Feb 2008 15:44:54 +0000
> Jeba Anandhan <jeba.anandhan@vaioni.com> wrote:
>
> > Hi all,
> > I have doubts about unregister the netdevice.
> >
> > Scenario
> > I have two netdevice entities. I wish to unregister one entity.
> >
> > struct net_device *dev1;
> > struct net_device *dev2;
> >
> > dev1->timer = XXX;
> > dev2->timer = YYY;
> >
> > dev1->ioctl() {
> >
> > ...
> > case delete_other:
> > unregister_netdev(dev2);
> > free_netdev(dev2);
> > return 0;
> > ...
> > }
> >
> > The dev2->refcnt is not zero in this case. unregister_netdev(dev2) cause
> > deadlock. Could you tell me why it happens?.
> >
> >
> > It works smoothly when we call the unregister_netdev(dev2) from
> > cleanup_module(). dev2->refcnt is not zero in this case. Still it is
> > able to unregister.
> >
> >
> > Thanks
> > Jeba
> >
>
> You need to properly manage device refcounts (or delete both).
> Also since dev1->ioctl is called with RTNL you can't:
> use unregister_netdev() recursive locking (use unregister_netdevice)
> or call free_netdev because of netdevice could still be in use (use dev->destructor instead).
*) Is there any chance of deadlock if i try to unregister_netdev() on
the fly using syscall?
*) is dev->refcnt altered by only dev_hold or dev_put?. what are the
general cases where the dev->refcnt is altered?
Thanks
Jeba
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-27 17:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-27 15:44 unregister_netdev() deadlock Jeba Anandhan
2008-02-27 16:46 ` Stephen Hemminger
2008-02-27 17:05 ` Jeba Anandhan
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).