From: Oleg Nesterov <oleg@tv-sign.ru>
To: David Miller <davem@davemloft.net>
Cc: johannes@sipsolutions.net, davej@codemonkey.org.uk,
netdev@vger.kernel.org
Subject: Re: 2.6.25rc7 lockdep trace
Date: Wed, 2 Apr 2008 12:51:26 +0400 [thread overview]
Message-ID: <20080402085126.GA96@tv-sign.ru> (raw)
In-Reply-To: <20080328.180924.154907485.davem@davemloft.net>
On 03/28, David Miller wrote:
>
> From: Johannes Berg <johannes@sipsolutions.net>
> Date: Sat, 29 Mar 2008 02:01:25 +0100
>
> >
> > > > You can't flush a workqueue in the device close handler
> > > > exactly because of this locking conflict.
> > > >
> > > > Nobody has come up with a suitable way to fix this yet.
> > >
> > > Maybe we should check which schedule_work users actually lock the rtnl
> > > within the work function and move them to a uses-rtnl-in-work workqueue
> > > so that everybody else can have rtnl around flush.
> >
> > On the other hand, most drivers don't actually care that their work has
> > run, they just care that it won't run in the future after they give up
> > resources or similar, hence they can and should use cancel_work_sync()
> > which doesn't suffer from the deadlock. But that needs actual inspection
> > because it does change behaviour from "run and wait for it if scheduled"
> > to "cancel if scheduled".
>
> I don't see how you can not race with the transition from
> scheduled to "executing" without taking the runqueue lock
> for the testing.
Yes, cancel_work_sync() takes cwq->lock but this is fine (unless it is buggy ;)
Please note that run_workqueue() drops this lock before calling work->func().
If the caller of cancel_work_sync(work) doesn't share locks with work->func()
we can't deadlock, even if there are other pending/running work_structs which
need the same locks as the caller (say, RTNL).
But, perhaps, you mean wq->lockdep_map? As Johannes pointed out this lock is
fake, but I think this doesn't matter, from the correctness POV it is "real"
lock. What does matter is that cancel_work_sync() doesn't use this lock at all.
(again, Johannes has already explained this all).
> And it is crucial that the workqueue function doesn't
> execute "accidently" due to such a race before the module
> and thus the workqueue code is about to get potentially
> unloaded.
Which race? Unless explicitly queued afterwards, work->func() can't execute
after return from cancel_work_sync(work).
David, I think you misunderstood Johannes, or perhaps I missed something.
Oleg.
next prev parent reply other threads:[~2008-04-02 9:51 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-28 0:00 2.6.25rc7 lockdep trace Dave Jones
2008-03-28 1:55 ` Dave Jones
2008-03-29 0:34 ` David Miller
2008-03-29 0:54 ` Johannes Berg
2008-03-29 1:01 ` Johannes Berg
2008-03-29 1:09 ` David Miller
2008-04-02 8:51 ` Oleg Nesterov [this message]
2008-03-29 1:06 ` David Miller
2008-03-29 10:02 ` Johannes Berg
2008-03-29 12:52 ` Jarek Poplawski
2008-03-29 12:50 ` Johannes Berg
2008-04-03 20:48 ` David Miller
2008-04-04 14:48 ` Johannes Berg
2008-06-11 5:40 ` David Miller
2008-06-11 7:08 ` Jarek Poplawski
2008-06-11 7:10 ` David Miller
2008-06-11 9:36 ` Jarek Poplawski
2008-06-12 0:34 ` David Miller
2008-06-12 6:29 ` Jarek Poplawski
2008-06-11 10:40 ` Jarek Poplawski
2008-06-12 0:31 ` David Miller
2008-06-11 13:14 ` Jarek Poplawski
2008-06-12 5:46 ` David Miller
2008-06-12 7:20 ` Johannes Berg
2008-06-12 8:23 ` David Miller
2008-06-12 6:13 ` Jarek Poplawski
2008-06-12 7:01 ` David Miller
2008-06-12 7:47 ` Jarek Poplawski
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=20080402085126.GA96@tv-sign.ru \
--to=oleg@tv-sign.ru \
--cc=davej@codemonkey.org.uk \
--cc=davem@davemloft.net \
--cc=johannes@sipsolutions.net \
--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 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).