From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752925AbcCKNIF (ORCPT ); Fri, 11 Mar 2016 08:08:05 -0500 Received: from mx2.suse.de ([195.135.220.15]:45458 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752557AbcCKNIC (ORCPT ); Fri, 11 Mar 2016 08:08:02 -0500 Subject: Re: [PATCH 2/6] sched: add function to execute a function synchronously on a physical cpu To: Peter Zijlstra References: <1457697574-6710-1-git-send-email-jgross@suse.com> <1457697574-6710-3-git-send-email-jgross@suse.com> <20160311121950.GZ6344@twins.programming.kicks-ass.net> <20160311124238.GN6375@twins.programming.kicks-ass.net> <56E2BE8C.9030309@suse.com> <20160311125706.GC6344@twins.programming.kicks-ass.net> Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, konrad.wilk@oracle.com, 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, x86@kernel.org From: Juergen Gross Message-ID: <56E2C32C.5070808@suse.com> Date: Fri, 11 Mar 2016 14:07:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160311125706.GC6344@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 On 11/03/16 13:57, Peter Zijlstra wrote: > On Fri, Mar 11, 2016 at 01:48:12PM +0100, Juergen Gross wrote: >> On 11/03/16 13:42, Peter Zijlstra wrote: >>> how about something like: >>> >>> struct xen_callback_struct { >>> struct work_struct work; >>> struct completion done; > int (*func)(void*); >>> void * data; >>> int ret; >>> }; >>> >>> static void xen_callback_f(struct work_struct *work) >>> { >>> struct xen_callback_struct *xcs = container_of(work, struct xen_callback_struct, work); >>> >>> xcs->ret = xcs->func(xcs->data); >>> >>> complete(&xcs->done); >>> } >>> >>> xen_call_on_cpu_sync(int cpu, int (*func)(void *), void *data) >>> { >>> struct xen_callback_state xcs = { >>> .work = __WORK_INITIALIZER(xcs.work, xen_callback_f); >>> .done = COMPLETION_INITIALIZER_ONSTACK(xcs.done), > .func = func, >>> .data = data, >>> }; >>> >>> queue_work_on(&work, cpu); >>> wait_for_completion(&xcs.done); >>> >>> return xcs.ret; >>> } >>> >>> No mucking about with the scheduler state, no new exported functions >>> etc.. >>> >> >> Hey, I like it. Can't be limited to Xen as on bare metal the function >> needs to be called on cpu 0, too. But avoiding the scheduler fiddling >> is much better! As this seems to be required for Dell hardware only, >> I could add it to some Dell base driver in case you don't want to add >> it to core code. > > Urgh yeah, saw that in your other mail. It looks like I should go look > at set_cpus_allowed_ptr() abuse :/ > > Not sure where this would fit best, maybe somewhere near workqueue.c or > smp.c. At a first glance I think smp.c would be the better choice. I'll have a try. Thanks, Juergen