From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8Vbz-0004Qk-6F for qemu-devel@nongnu.org; Thu, 02 Jun 2016 12:36:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8Vbu-0000Ol-4T for qemu-devel@nongnu.org; Thu, 02 Jun 2016 12:36:47 -0400 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:36475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8Vbt-0000OR-N6 for qemu-devel@nongnu.org; Thu, 02 Jun 2016 12:36:42 -0400 Received: by mail-wm0-x22e.google.com with SMTP id n184so88487033wmn.1 for ; Thu, 02 Jun 2016 09:36:41 -0700 (PDT) References: <1459870344-16773-1-git-send-email-alex.bennee@linaro.org> <1459870344-16773-12-git-send-email-alex.bennee@linaro.org> <57485238.1020406@gmail.com> <9ac0359b-6c90-4933-ccb9-9f4b6aadf5f9@redhat.com> <57486297.6070509@gmail.com> <8c646051-84f1-c97a-f424-a854f45b9362@redhat.com> <57489800.4060009@gmail.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <57489800.4060009@gmail.com> Date: Thu, 02 Jun 2016 17:36:49 +0100 Message-ID: <87mvn37djy.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC v2 11/11] tcg: enable thread-per-vCPU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov Cc: Paolo Bonzini , mttcg@greensocs.com, fred.konrad@greensocs.com, a.rigo@virtualopensystems.com, cota@braap.org, qemu-devel@nongnu.org, mark.burton@greensocs.com, jan.kiszka@siemens.com, rth@twiddle.net, peter.maydell@linaro.org, claudio.fontana@huawei.com, Peter Crosthwaite Sergey Fedorov writes: > On 27/05/16 18:25, Paolo Bonzini wrote: >> >> On 27/05/2016 17:07, Sergey Fedorov wrote: >>>>>>> 1. Make 'cpu->thread_kicked' access atomic >>>>>>> 2. Remove global 'exit_request' and use per-CPU 'exit_request' >>>>>>> 3. Change how 'current_cpu' is set >>>>>>> 4. Reorganize round-robin CPU TCG thread function >>>>>>> 5. Enable 'mmap_lock' for system mode emulation (do we really want this?) >>>>> No, I don't think so. >>>>> >>>>>>> 6. Enable 'tb_lock' for system mode emulation >>>>>>> 7. Introduce per-CPU TCG thread function >>>>> At least 2/3/7 must be done at the same time, but I agree that this >>>>> patch could use some splitting. :) >>> Hmm, 2/3 do also change single-threaded CPU loop. I think they should >>> apply separately from 7. >> Reviewed the patch now, and I'm not sure how you can do 2/3 for the >> single-threaded CPU loop. They could be moved out of cpu_exec and into >> cpus.c (in a separate patch), but you need exit_request and >> tcg_current_cpu to properly kick the single-threaded CPU loop out of >> qemu_tcg_cpu_thread_fn. > > Summarizing Paolo and my chat on IRC, we want run_on_cpu() to be served > as soon as possible so that it would not block IO thread for too long. > Removing global 'exit_request' would mean that a run_on_cpu() request > from IO thread wouldn't be served until single-threaded CPU loop > schedules the target CPU. This doesn't seem to be acceptable. So I've fixed this by keeping a tcg_current_rr_cpu for the benefit of the round robin scheduling (I needed something similar for the kick timer once the globals had gone). I'm seeing if I can pull out the exit_request stuff and other re-factorings in the big patch to reduce the size of this monster a little. > NB: Calling run_on_cpu() for other CPU from the CPU thread would cause a > deadlock in single-threaded round-robin CPU loop. We've established this doesn't happen as qemu_cpu_is_self compares threads which are all the same for RR TCG. > > Thanks, > Sergey -- Alex Bennée