Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757940AbcDEKFo (ORCPT ); Tue, 5 Apr 2016 06:05:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:53895 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756369AbcDEKFh (ORCPT ); Tue, 5 Apr 2016 06:05:37 -0400 Subject: Re: [PATCH v4 3/6] smp: add function to execute a function synchronously on a cpu To: Peter Zijlstra References: <1459833007-11618-1-git-send-email-jgross@suse.com> <1459833007-11618-4-git-send-email-jgross@suse.com> <20160405081107.GH3448@twins.programming.kicks-ass.net> Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, boris.ostrovsky@oracle.com, david.vrabel@citrix.com, mingo@redhat.com, Douglas_Warzecha@dell.com, pali.rohar@gmail.com, jdelvare@suse.com, linux@roeck-us.net, tglx@linutronix.de, hpa@zytor.com, jeremy@goop.org, chrisw@sous-sol.org, akataria@vmware.com, rusty@rustcorp.com.au, virtualization@lists.linux-foundation.org, x86@kernel.org From: Juergen Gross Message-ID: <57038DEE.3070201@suse.com> Date: Tue, 5 Apr 2016 12:05:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <20160405081107.GH3448@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1031 Lines: 41 On 05/04/16 10:11, Peter Zijlstra wrote: > 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. I don't mind either way. As you don't like .pin, lets name it .phys. > Also, as per smp_call_function_single() would it not be more consistent > to make this the last argument? Okay, I'll change it. > >> +{ >> + 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)) Indeed, good idea. >> + return -ENXIO; > > Seeing how its fairly hard to schedule work on a cpu that's not actually > there. Really? ;-) Juergen