From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9bAG-0008Bj-30 for qemu-devel@nongnu.org; Sun, 05 Jun 2016 12:44:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9bAC-00066q-UB for qemu-devel@nongnu.org; Sun, 05 Jun 2016 12:44:40 -0400 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]:33054) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9bAB-00066Y-VU for qemu-devel@nongnu.org; Sun, 05 Jun 2016 12:44:36 -0400 Received: by mail-lf0-x231.google.com with SMTP id s64so81495826lfe.0 for ; Sun, 05 Jun 2016 09:44:35 -0700 (PDT) References: <1460730231-1184-1-git-send-email-alex.bennee@linaro.org> <1460730231-1184-9-git-send-email-alex.bennee@linaro.org> From: Sergey Fedorov Message-ID: <575456F0.1090402@gmail.com> Date: Sun, 5 Jun 2016 19:44:32 +0300 MIME-Version: 1.0 In-Reply-To: <1460730231-1184-9-git-send-email-alex.bennee@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC v1 07/12] cpus: introduce async_safe_run_on_cpu. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Alex_Benn=c3=a9e?= , mttcg@listserver.greensocs.com, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org Cc: qemu-devel@nongnu.org, mark.burton@greensocs.com, pbonzini@redhat.com, jan.kiszka@siemens.com, rth@twiddle.net, peter.maydell@linaro.org, claudio.fontana@huawei.com, Peter Crosthwaite , =?UTF-8?Q?Andreas_F=c3=a4rber?= On 15/04/16 17:23, Alex Bennée wrote: > +/* > + * Safe work interface > + * > + * Safe work is defined as work that requires the system to be > + * quiescent before making changes. > + */ > + > +void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, void *data) > +{ > + CPUState *iter; > + qemu_safe_work_item wi; We can call the function right away if MTTCG is disabled or there's only one CPU emulated. Kind regards, Sergey > + wi.cpu = cpu; > + wi.func = func; > + wi.data = data; > + > + qemu_mutex_lock(&safe_work_mutex); > + g_array_append_val(safe_work, wi); > + atomic_inc(&safe_work_pending); > + qemu_mutex_unlock(&safe_work_mutex); > + > + /* Signal all vCPUs to halt */ > + CPU_FOREACH(iter) { > + qemu_cpu_kick(iter); > + } > +}