From: Paolo Bonzini Subject: Re: [PATCH kvm-unit-tests 0/3] arm/arm64: smp: prepare for on_cpu Date: Tue, 30 May 2017 16:26:34 +0200 Message-ID: <4e31a9bf-4c8f-ce45-9542-4f3dd35fe7f1@redhat.com> References: <20170529135804.22891-1-drjones@redhat.com> <20170530133938.75zlzc2qm7dhsdsw@kamzik.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: kvm@vger.kernel.org, rkrcmar@redhat.com To: Andrew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:56258 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751419AbdE3O0m (ORCPT ); Tue, 30 May 2017 10:26:42 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 4187EC04B94A for ; Tue, 30 May 2017 14:26:37 +0000 (UTC) In-Reply-To: <20170530133938.75zlzc2qm7dhsdsw@kamzik.brq.redhat.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 30/05/2017 15:39, Andrew Jones wrote: > On Tue, May 30, 2017 at 02:13:34PM +0200, Paolo Bonzini wrote: > Yes, I know, I even wrote something similar to that already and it > works fine, *if* the calling cpu can always expect the target cpu > to eventually (for some value of eventually) run its code (the "other > side" code above). When I implemented it I decided that that code > implements an idle loop, i.e. > > void secondary_halt(void) <-- maybe rename to do_idle() > { > cpu = smp_processor_id(); > set_cpu_idle(cpu, true); > for (;;) { > while (cpu_idle(cpu)) > wfe(); > ... > cb(opaque); > set_cpu_idle(cpu, true); > } > } > > This implies on_cpu*() must wait for a target cpu's currently running > task to finish, i.e., as I said above, no arbitrary preemption. Yes, that's okay. > So it's not as nice as an IPI solution that doesn't block an asynchronise > caller (possibly indefinitely), which would mean it doesn't actually > implement the semantics of on_cpu_async anyway. It's probably a bug anyway to have on_cpu_async while a previous on_cpu_async is running. If you look at x86 tests, on_cpu_async usually is followed by a busy wait for all CPUs to complete. Paolo