Re: [patch 02/13] workqueue: Provide work_on_cpu_safe()
From: Thomas Gleixner
Date: Fri Apr 14 2017 - 05:51:25 EST
On Fri, 14 Apr 2017, Peter Zijlstra wrote:
> On Wed, Apr 12, 2017 at 10:07:28PM +0200, Thomas Gleixner wrote:
> > +long work_on_cpu_safe(int cpu, long (*fn)(void *), void *arg)
> > +{
> > + long ret = -ENODEV;
> > +
> > + get_online_cpus();
> > + if (cpu_online(cpu))
> > + ret = work_on_cpu(cpu, fn, arg);
> > + put_online_cpus();
> > + return ret;
> > +}
>
> But doesn't workqueue have this lovelt 'feature' where it will unbind
> per-cpu work and run it on random CPUs when hotplug happens?
>
> That is, I think you need a flush_work() before put_online_cpus() if you
> want to guarantee anything.
work_on_cpu() is sychnronous, it flushes already.
Thanks,
tglx