From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDGJF-00015m-Dx for qemu-devel@nongnu.org; Wed, 15 Jun 2016 15:17:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDGJC-00030Y-N9 for qemu-devel@nongnu.org; Wed, 15 Jun 2016 15:17:05 -0400 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]:33165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDGJB-00030Q-Sj for qemu-devel@nongnu.org; Wed, 15 Jun 2016 15:17:02 -0400 Received: by mail-lf0-x229.google.com with SMTP id f6so26595144lfg.0 for ; Wed, 15 Jun 2016 12:17:01 -0700 (PDT) References: <874m8uh55x.fsf@linaro.org> From: Sergey Fedorov Message-ID: <5761A9AB.4050600@gmail.com> Date: Wed, 15 Jun 2016 22:16:59 +0300 MIME-Version: 1.0 In-Reply-To: <874m8uh55x.fsf@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] exec: Safe work in quiescent state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Alex_Benn=c3=a9e?= Cc: QEMU Developers , MTTCG Devel , =?UTF-8?B?S09OUkFEIEZyw6lkw6lyaWM=?= , Alvise Rigo , "Emilio G. Cota" , Paolo Bonzini , Richard Henderson , Peter Maydell On 15/06/16 17:56, Alex Bennée wrote: > Sergey Fedorov writes: (snip) > Just some quick comments for context: > >> Alex's reiteration of Fred's approach [2]: >> - maintains a single global safe work queue; > Having separate queues can lead to problems with draining queues as only > queue gets drained at a time and some threads exit more frequently than > others. I think it can't happen if we drain all the queues from all the CPUs, as we should. The requirement is: stop all the CPUs and process all the pending work. If we follow this requirement, I think it's not important whether we have separate queues for each CPU or just a single global queue. > >> - uses GArray rather than linked list to implement the work queue; > This was to minimise g_malloc on job creation and working through the > list. An awful lot of jobs just need the CPU id and a single parameter. > This is why I made it the simple case. I think it would be nice to avoid g_malloc but don't use an array at the same time. I have some thoughts how to do this easily, let's see the code ;-) >> - introduces a global counter of CPUs which have entered their execution >> loop; >> - makes use of the last CPU exited its execution loop to drain the safe >> work queue; > I suspect you can still race with other deferred work as those tasks are > being done outside the exec loop. This should be fixable though. Will keep an eye on this, thanks. > >> - still does not support user-mode emulation. > There is not particular reason it couldn't. However it would mean > updating the linux-user cpu_exec loop which most likely needs a good > clean-up and re-factoring to avoid making the change to $ARCH loops. Yes, you are right, I just fixed the facts here :) Kind regards, Sergey