Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752966AbdDNJvW (ORCPT ); Fri, 14 Apr 2017 05:51:22 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:41447 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751612AbdDNJvU (ORCPT ); Fri, 14 Apr 2017 05:51:20 -0400 Date: Fri, 14 Apr 2017 11:51:07 +0200 (CEST) From: Thomas Gleixner To: Peter Zijlstra cc: LKML , Ingo Molnar , Sebastian Siewior , Benjamin Herrenschmidt , "David S. Miller" , Fenghua Yu , Herbert Xu , Lai Jiangshan , Len Brown , Michael Ellerman , "Rafael J. Wysocki" , Tejun Heo , Tony Luck , Viresh Kumar Subject: Re: [patch 02/13] workqueue: Provide work_on_cpu_safe() In-Reply-To: <20170414085459.sp3psluw647ab4lw@hirez.programming.kicks-ass.net> Message-ID: References: <20170412200726.941336635@linutronix.de> <20170412201042.262610721@linutronix.de> <20170414085459.sp3psluw647ab4lw@hirez.programming.kicks-ass.net> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 672 Lines: 25 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