From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8V2i-00056k-BG for qemu-devel@nongnu.org; Thu, 02 Jun 2016 12:00:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8V2e-0004oA-C1 for qemu-devel@nongnu.org; Thu, 02 Jun 2016 12:00:20 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:37320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8V2d-0004nv-Nu for qemu-devel@nongnu.org; Thu, 02 Jun 2016 12:00:16 -0400 Received: by mail-wm0-x229.google.com with SMTP id z87so75489849wmh.0 for ; Thu, 02 Jun 2016 09:00:15 -0700 (PDT) References: <1459870344-16773-1-git-send-email-alex.bennee@linaro.org> <1459870344-16773-10-git-send-email-alex.bennee@linaro.org> <570C19AB.5020106@gmail.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <570C19AB.5020106@gmail.com> Date: Thu, 02 Jun 2016 17:00:22 +0100 Message-ID: <87oa7j7f8p.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC v2 09/11] tcg: add kick timer for single-threaded vCPU emulation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov Cc: mttcg@listserver.greensocs.com, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, 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 Sergey Fedorov writes: > On 05/04/16 18:32, Alex Bennée wrote: >> +static void kick_tcg_thread(void *opaque) >> +{ >> + QEMUTimer *self = *(QEMUTimer **) opaque; >> + timer_mod(self, >> + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + >> + NANOSECONDS_PER_SECOND / 10); >> + qemu_cpu_kick_no_halt(); >> +} >> > > It would be nice to have some definition (e.g. macro) of TCG thread kick > period. Will do. > > (snip) > >> @@ -1179,6 +1198,14 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) >> } >> } >> >> + /* Set to kick if we have to do more than one vCPU */ >> + if (CPU_NEXT(first_cpu)) { >> + kick_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, kick_tcg_thread, &kick_timer); >> + timer_mod(kick_timer, >> + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + >> + NANOSECONDS_PER_SECOND / 10); >> + } >> + > > I think cpu_ticks_init() could be more natural place to put this > initialization in. It would be but I need somewhere to keep kick_timer and doing it inside the thread function keeps it nice and local. > > Kind regards, > Sergey -- Alex Bennée