[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070216123605.56e697ac@freekitty>
Date: Fri, 16 Feb 2007 12:36:05 -0800
From: Stephen Hemminger <shemminger@...ux-foundation.org>
To: Francois Romieu <romieu@...zoreil.com>
Cc: Jarek Poplawski <jarkao2@...pl>, jeff@...zik.org,
akpm@...ux-foundation.org, netdev@...r.kernel.org,
Ben Greear <greearb@...delatech.com>,
Kyle Lucke <klucke@...ibm.com>,
Raghavendra Koushik <raghavendra.koushik@...erion.com>,
Al Viro <viro@....linux.org.uk>
Subject: Re: [PATCH 3/4] 8139too: RTNL and flush_scheduled_work deadlock
On Fri, 16 Feb 2007 21:20:34 +0100
Francois Romieu <romieu@...zoreil.com> wrote:
> Jarek Poplawski <jarkao2@...pl> :
> [...]
> > > diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
> > > index 35ad5cf..99304b2 100644
> > > --- a/drivers/net/8139too.c
> > > +++ b/drivers/net/8139too.c
> > > @@ -1109,6 +1109,8 @@ static void __devexit rtl8139_remove_one (struct pci_dev *pdev)
> > >
> > > assert (dev != NULL);
> > >
> > > + flush_scheduled_work();
> > > +
> >
> > IMHO there should be rather cancel_rearming_delayed_work
> > instead of this.
>
> The delayed_work is initialized even if tp->have_thread is false,
> so cancel_rearming_delayed_work() will work, yes. Feel free to
> send a patch.
>
> [...]
> > > @@ -1603,18 +1605,21 @@ static void rtl8139_thread (struct work_struct *work)
> > > struct net_device *dev = tp->mii.dev;
> > > unsigned long thr_delay = next_tick;
> > >
> > > + rtnl_lock();
> > > +
> > > + if (!netif_running(dev))
> > > + goto out_unlock;
> >
> > I wonder, why you don't do netif_running before
> > rtnl_lock ? It's an atomic operation. And I'm not sure if increasing
> > rtnl_lock range is really needed here.
>
> thread A: netif_running()
> user task B: rtnl_lock()
> user task B: dev->close()
> user task B: rtnl_unlock()
> thread A: rtnl_lock()
> thread A: mess with closed device
>
> Btw, the thread runs every 3*HZ at most.
You need to hold a dev reference (dev_hold) as well. to keep the device
from disappearing. or do a flush_scheduled_work in the remove routine.
--
Stephen Hemminger <shemminger@...ux-foundation.org>
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists