From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5t59-00072O-Hl for qemu-devel@nongnu.org; Thu, 26 May 2016 07:04:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5t55-0002xD-B9 for qemu-devel@nongnu.org; Thu, 26 May 2016 07:04:02 -0400 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:34914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5t54-0002wt-UP for qemu-devel@nongnu.org; Thu, 26 May 2016 07:03:59 -0400 Received: by mail-lf0-x241.google.com with SMTP id p10so5687214lfb.2 for ; Thu, 26 May 2016 04:03:58 -0700 (PDT) References: <1459870344-16773-1-git-send-email-alex.bennee@linaro.org> <1459870344-16773-8-git-send-email-alex.bennee@linaro.org> From: Sergey Fedorov Message-ID: <5746D81C.8030506@gmail.com> Date: Thu, 26 May 2016 14:03:56 +0300 MIME-Version: 1.0 In-Reply-To: <1459870344-16773-8-git-send-email-alex.bennee@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC v2 07/11] tcg: cpus rm tcg_exec_all() 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 On 05/04/16 18:32, Alex Bennée wrote: > diff --git a/cpus.c b/cpus.c > index e118fdf..46732a5 100644 > --- a/cpus.c > +++ b/cpus.c (snip) > @@ -1109,7 +1108,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg) > #endif > } > > -static void tcg_exec_all(void); > +static int tcg_cpu_exec(CPUState *cpu); Why don't just move tcg_cpu_exec() here and avoid this forward declaration. Such forward declarations of static functions are a bit annoying :) > > static void *qemu_tcg_cpu_thread_fn(void *arg) > { > @@ -1140,8 +1139,35 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) > /* process any pending work */ > atomic_mb_set(&exit_request, 1); > > + cpu = first_cpu; > + > while (1) { > - tcg_exec_all(); > + /* Account partial waits to QEMU_CLOCK_VIRTUAL. */ > + qemu_account_warp_timer(); > + > + if (!cpu) { > + cpu = first_cpu; > + } > + > + for (; cpu != NULL && !exit_request; cpu = CPU_NEXT(cpu)) { Maybe a "while" cycle would be a bit neater here, like: while (cpu != NULL && !exit_request) { /* ... */ cpu = CPU_NEXT(cpu); } > + > + qemu_clock_enable(QEMU_CLOCK_VIRTUAL, > + (cpu->singlestep_enabled & SSTEP_NOTIMER) == 0); > + > + if (cpu_can_run(cpu)) { > + int r = tcg_cpu_exec(cpu); > + if (r == EXCP_DEBUG) { > + cpu_handle_guest_debug(cpu); > + break; > + } > + } else if (cpu->stop || cpu->stopped) { > + break; > + } > + > + } /* for cpu.. */ > + > + /* Pairs with smp_wmb in qemu_cpu_kick. */ While at it, we could also fix this comment like this: /* Pairs with atomic_mb_read() in cpu_exec(). */ > + atomic_mb_set(&exit_request, 0); > > if (use_icount) { > int64_t deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); Kind regards, Sergey