From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Add kerneldoc for flush_scheduled_work()
Date: Wed, 12 Aug 2009 18:27:57 +0000 [thread overview]
Message-ID: <1250101677.8829.4.camel@mulgrave.site> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0908121407140.23954-100000@iolanthe.rowland.org>
On Wed, 2009-08-12 at 14:16 -0400, Alan Stern wrote:
> On Wed, 12 Aug 2009, James Bottomley wrote:
>
> > If it's a local lock, how would something someone else submitted to the
> > queue, which would be out of scope, take this local lock? A local lock,
> > by definition is local to the code scope you control.
>
> This can happen easily. Somebody else submits a work item to the
> queue, the work routine calls one of your publicly exported functions,
> and that function takes the local lock.
Fine, so local means not exported and not usable by exported functions.
> > > Not at all. With cancel_work_sync() you must verify only that the
> > > item you want to cancel obeys the rules. There's no need to check the
> > > other items -- and a public workqueue like keventd_wq certainly will
> > > contain other items.
> >
> > Um, so this is called on driver removal, which is an asynchronous event.
> > Thus, how can you assure that what's on the queue (which you are
> > advocating calling cancel sync for) doesn't violate the locking rules at
> > the time the driver is removed, unless you assure that every piece of
> > work submitted doesn't violate them.
>
> You can assure it by auditing the work routine's code. A single work
> item involves a single function, plus whatever that function calls --
> it is easily checked.
>
> You don't need to inspect every work item ever added to the queue, only
> the one that you want to cancel.
This is true, but not relevant to the documentation you were trying to
add. You're advocating using cancel sync as a replacement for flush ...
thus you have to cancel every pending piece of your work currently on
the queue. My contention is that this means your rules for submission
if you do this must be the same as they would be if you'd just called
flush; making the advice moot.
James
> > Thus the rules for calling flush and cancel sync are the same.
>
> They are not. With cancel you need to verify that the one item you are
> cancelling obeys the rules. With flush you need to verify that
> _everything_ on the queue is safe with respect to locking.
>
> The only valid reason for a driver to call flush_scheduled_work()
> would be that it knows there's an outstanding work item, which has to
> be completed or cancelled, but it doesn't have a pointer to the item.
> Then cancellation is impossible.
>
> Alan Stern
next prev parent reply other threads:[~2009-08-12 18:28 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-11 21:06 Alan Stern
2009-08-12 9:41 ` Ingo Molnar
2009-08-12 10:47 ` Peter Zijlstra
2009-08-12 10:51 ` Ingo Molnar
2009-08-12 14:13 ` Alan Stern
2009-08-12 14:17 ` Ingo Molnar
2009-08-12 15:56 ` [PATCH ver 2] " Alan Stern
2009-08-12 16:22 ` [PATCH] " James Bottomley
2009-08-13 7:25 ` Ingo Molnar
2009-08-13 8:47 ` Johannes Weiner
2009-08-13 10:03 ` Ingo Molnar
2009-08-13 14:37 ` James Bottomley
2009-08-12 14:01 ` James Bottomley
2009-08-12 14:54 ` Alan Stern
2009-08-12 15:00 ` James Bottomley
2009-08-12 15:44 ` Alan Stern
2009-08-12 15:58 ` James Bottomley
2009-08-12 16:23 ` Alan Stern
2009-08-12 17:02 ` James Bottomley
2009-08-12 17:25 ` Alan Stern
2009-08-12 17:36 ` James Bottomley
2009-08-12 18:16 ` Alan Stern
2009-08-12 18:27 ` James Bottomley [this message]
2009-08-12 18:48 ` Alan Stern
2009-08-12 20:28 ` James Bottomley
2009-08-12 20:41 ` Alan Stern
2009-08-12 18:14 Randy Dunlap
2009-08-13 12:06 Randy Dunlap
2009-08-13 14:51 ` Johannes Weiner
2009-08-13 15:04 ` James Bottomley
2009-08-13 16:20 ` Randy Dunlap
2009-08-13 18:08 ` Johannes Weiner
2009-08-14 18:23 ` Randy Dunlap
2009-08-18 9:04 ` Johannes Weiner
2009-08-19 22:23 ` Johannes Weiner
2009-08-19 23:21 ` Randy Dunlap
2009-08-19 23:27 ` Randy Dunlap
2009-08-24 19:06 ` Johannes Weiner
2009-08-24 19:27 ` Randy Dunlap
2009-08-24 20:09 ` Johannes Weiner
2009-08-24 20:25 ` Randy Dunlap
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=1250101677.8829.4.camel@mulgrave.site \
--to=james.bottomley@hansenpartnership.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=stern@rowland.harvard.edu \
/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
all inboxes | Powered by JetHome®