From: Paolo Bonzini Subject: Re: [PATCH kvm-unit-tests 0/3] arm/arm64: smp: prepare for on_cpu Date: Tue, 30 May 2017 14:13:34 +0200 Message-ID: References: <20170529135804.22891-1-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: rkrcmar@redhat.com To: Andrew Jones , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58906 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750898AbdE3MNh (ORCPT ); Tue, 30 May 2017 08:13:37 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B168C057FAB for ; Tue, 30 May 2017 12:13:37 +0000 (UTC) In-Reply-To: <20170529135804.22891-1-drjones@redhat.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 29/05/2017 15:58, Andrew Jones wrote: > Paolo inspired me to add x86's on_cpu and on_cpu_asynch to ARM's API. > I messed around with it a while, but haven't really settled on what > I want to do. I played with the following approaches: > - wfe/sev, requires the concept of an idle state and knowing that the > target CPU is in that state - i.e. no arbitrary preemption. WFE really is just a power-save NOP. I think you'd do something like spin_lock(&dest->ipi_lock); assert(dest->ipi_cb == NULL); dest->ipi_cb = fn; dest->ipi_opaque = opaque; spin_unlock(&dest->ipi_lock); asm("dsb; sev"); while (dest->ipi_cb != NULL) asm("wfe"); and on the other side: while (dest->ipi_cb == NULL) asm("wfe"); spin_lock(&dest->ipi_lock); cb = dest->ipi_cb; opaque = dest->ipi_opaque; dest->ipi_cb = NULL; spin_unlock(&dest->ipi_lock); asm("dsb; sev"); cb(opaque); Thanks, Paolo > - IPI, allows arbitrary preemption, but requires the GIC to be setup > enough to receive SGIs and also a dedicated SGI for the scheduling > - PSCI, poweroff state isn't better than an idle state, and PSCI works > asynchronously wrt CPUs