From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: Re: [PATCH v4 3/6] smp: add function to execute a function synchronously on a cpu Date: Tue, 5 Apr 2016 10:11:07 +0200 Message-ID: <20160405081107.GH3448@twins.programming.kicks-ass.net> References: <1459833007-11618-1-git-send-email-jgross@suse.com> <1459833007-11618-4-git-send-email-jgross@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1459833007-11618-4-git-send-email-jgross@suse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: Juergen Gross Cc: x86@kernel.org, jeremy@goop.org, jdelvare@suse.com, hpa@zytor.com, akataria@vmware.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, chrisw@sous-sol.org, mingo@redhat.com, david.vrabel@citrix.com, Douglas_Warzecha@dell.com, pali.rohar@gmail.com, xen-devel@lists.xenproject.org, boris.ostrovsky@oracle.com, tglx@linutronix.de, linux@roeck-us.net List-Id: virtualization@lists.linuxfoundation.org On Tue, Apr 05, 2016 at 07:10:04AM +0200, Juergen Gross wrote: > +int smp_call_on_cpu(unsigned int cpu, bool pin, int (*func)(void *), void *par) Why .pin and not .phys? .pin does not (to me) reflect the hypervisor/physical-cpu thing. Also, as per smp_call_function_single() would it not be more consistent to make this the last argument? > +{ > + struct smp_call_on_cpu_struct sscs = { > + .work = __WORK_INITIALIZER(sscs.work, smp_call_on_cpu_callback), > + .done = COMPLETION_INITIALIZER_ONSTACK(sscs.done), > + .func = func, > + .data = par, > + .cpu = pin ? cpu : -1, > + }; > + > + if (cpu >= nr_cpu_ids) You might want to also include cpu_online(). if (cpu >= nr_cpu_ids || !cpu_online(cpu)) > + return -ENXIO; Seeing how its fairly hard to schedule work on a cpu that's not actually there. > + > + queue_work_on(cpu, system_wq, &sscs.work); > + wait_for_completion(&sscs.done); > + > + return sscs.ret; > +}