lkml.org 
[lkml]   [2009]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
DateMon, 26 Jan 2009 23:20:02 +0100
FromIngo Molnar <>
SubjectRe: [PATCH 2/3] work_on_cpu: Use our own workqueue.

* Andrew Morton <akpm@linux-foundation.org> wrote:

> On Mon, 26 Jan 2009 23:05:37 +0100
> Ingo Molnar <mingo@elte.hu> wrote:
>
> >
> > * Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > > Well it turns out that I was having a less-than-usually-senile moment:
> > >
> > > : implement flush_work()
> >
> > > Why isn't that working in this case??
> >
> > how would that work in this case? We defer processing into the workqueue
> > exactly because we want its per-CPU properties.
>
> It detaches the work item, moves it to head-of-queue, reinserts it then
> waits on it. I think.
>
> This might have a race+hole. If a currently-running "unrelated" work
> item tries to take the lock which the flush_work() caller is holding
> then there's no way in which keventd will come back to execute the work
> item which we just put on the head of queue.

Correct - or the unrelated worklet might also be blocked on something - so
the window is rather large.

> > We want work_on_cpu() to be done in the workqueue context on the CPUs
> > that were specified, not in the local CPU context.
>
> flush_work() is supposed to work in the way which you describe.
>
> But Oleg's "we may be running on a different CPU" comment has me all
> confused.

well, we call this on any arbitrary CPU:

long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg)

To execute fn() on 'cpu'. We converted wacky callers that did direct
p->cpus_allowed twiddling (and on-stack saving) and set_cpus_allowed()
calls to this elegant-looking work_on_cpu() call which just promised
exactly this functionality but cleanly so.

Ingo


\
 
 \ /
  Last update: 2009-01-26 23:23    [from the cache]
©2003-2010