From: Jarek Poplawski <jarkao2@gmail.com>
To: Benjamin Thery <benjamin.thery@bull.net>
Cc: Daniel Lezcano <dlezcano@fr.ibm.com>,
"David S. Miller" <davem@davemloft.net>,
netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH] net: deadlock during net device unregistration - V2
Date: Thu, 2 Oct 2008 20:38:19 +0200 [thread overview]
Message-ID: <20081002183819.GA2664@ami.dom.local> (raw)
In-Reply-To: <48E4E772.2020208@bull.net>
On Thu, Oct 02, 2008 at 05:23:30PM +0200, Benjamin Thery wrote:
> Jarek Poplawski wrote:
>> On Wed, Oct 01, 2008 at 11:06:22PM +0200, Daniel Lezcano wrote:
>>> Jarek Poplawski wrote:
>>>> On Wed, Oct 01, 2008 at 04:14:35PM +0200, Benjamin Thery wrote:
>> ...
>>>>> --- net-next-2.6.orig/net/core/dst.c
>>>>> +++ net-next-2.6/net/core/dst.c
>>>>> @@ -328,6 +328,10 @@ static int dst_dev_event(struct notifier
>>>>> dst_ifdown(dst, dev, event != NETDEV_DOWN);
>>>>> }
>>>>> mutex_unlock(&dst_gc_mutex);
>>>>> +
>>>>> + if (event == NETDEV_UNREGISTER &&
>>>>> + cancel_delayed_work(&dst_gc_work))
>>>>> + dst_gc_task(&dst_gc_work.work);
>>>> Hmm... It seems this shouldn't work yet: cancel_delayed_work() can only
>>>> kill this while on timer, but not when queued and maybe blocked already.
>
> You're right.
>
>>
>> Hmm#2... Then maybe something like this?:
>>
>> if (event == NETDEV_UNREGISTER &&
>> (cancel_delayed_work(&dst_gc_work) ||
>> delayed_work_pending(&dst_gc_work)))
>> dst_gc_task(&dst_gc_work.work);
>
> Hmmm... I'm not sure I understand what this change do?
>
> OK, I see this ensure we will run dst_gc_task() even if
> cancel_delayed_work() failed and the work is still pending (ie. the
> timer has expired and dst_gc_work is already in the queue).
I think, this covers exactly the case of blocking you described, plus
more... (the work is queued but not blocked).
>
> But what if the work was not pending at all at beginning?
> We still need to run dst_gc_task().
Maybe I miss something, but if this is really needed here then it
looks like we are fixing more than "the blocking" bug BTW.
>
> Is something like this better?
> (code expanded to be more readable)
>
> if (event == NETDEV_UNREGISTER) {
> if (!delayed_work_pending(&dst_gc_work))
> /* work is not scheduled (no timer, not in queue) */
/* may be running too */
> dst_gc_task(&dst_gc_work.work);
> else if (cancel_delayed_work(&dst_gc_work) ||
> delayed_work_pending(&dst_gc_work)))
> /* work was scheduled (and may be blocked) */
/* actually could be both running and pending here:
* if it's after rearming
*/
> dst_gc_task(&dst_gc_work.work);
> else
> /* dst_gc_task() is running, do nothing */
So again !delayed_work_pending() - there could be the change of state
while checking - but then looks a bit inconsistent. I think this should
be OK too.
As a matter of fact I've thought about something even simpler, which
probably should help for all above concerns too:
if (event == NETDEV_UNREGISTER)
dst_gc_task(&dst_gc_work.work);
dst_gc_task() locking allows for this, and running this two times in
a row could be even faster than trying to cancel the unnecessary run.
Jarek P.
next prev parent reply other threads:[~2008-10-02 18:37 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080929175412.866679567@theryb.frec.bull.fr>
2008-09-29 17:54 ` [PATCH] net: deadlock during net device unregistration Benjamin Thery
2008-09-30 6:32 ` Jarek Poplawski
2008-09-30 11:52 ` Benjamin Thery
2008-09-30 13:58 ` David Miller
2008-09-30 14:07 ` Benjamin Thery
2008-09-30 14:42 ` Jarek Poplawski
2008-09-30 14:57 ` Jarek Poplawski
2008-09-30 15:18 ` Benjamin Thery
2008-10-01 9:59 ` David Miller
2008-10-01 10:10 ` Daniel Lezcano
2008-10-01 10:12 ` David Miller
2008-10-01 14:14 ` [PATCH] net: deadlock during net device unregistration - V2 Benjamin Thery
2008-10-01 19:48 ` Jarek Poplawski
2008-10-01 21:06 ` Daniel Lezcano
2008-10-01 21:52 ` Jarek Poplawski
2008-10-01 23:31 ` Jarek Poplawski
2008-10-02 15:23 ` Benjamin Thery
2008-10-02 18:38 ` Jarek Poplawski [this message]
2008-10-02 19:55 ` Benjamin Thery
2008-10-02 20:34 ` Jarek Poplawski
2008-10-04 7:42 ` Jarek Poplawski
2008-10-04 7:52 ` Jarek Poplawski
2008-10-03 0:41 ` [PATCH] net: deadlock during net device unregistration Eric W. Biederman
2008-10-05 4:26 ` Herbert Xu
2008-10-05 6:55 ` Jarek Poplawski
2008-10-05 6:56 ` Herbert Xu
2008-10-05 7:12 ` Jarek Poplawski
2008-10-05 7:28 ` Stephen Hemminger
2008-10-05 7:38 ` Herbert Xu
2008-10-05 7:39 ` Herbert Xu
2008-10-06 15:19 ` Benjamin Thery
2008-10-07 22:46 ` David Miller
2008-10-07 22:50 ` David Miller
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=20081002183819.GA2664@ami.dom.local \
--to=jarkao2@gmail.com \
--cc=benjamin.thery@bull.net \
--cc=davem@davemloft.net \
--cc=dlezcano@fr.ibm.com \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.