From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abPAY-0001cP-CT for qemu-devel@nongnu.org; Thu, 03 Mar 2016 04:03:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abOv4-0000B2-LX for qemu-devel@nongnu.org; Thu, 03 Mar 2016 03:47:44 -0500 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:38372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abOv4-0000Ax-EB for qemu-devel@nongnu.org; Thu, 03 Mar 2016 03:47:38 -0500 Received: by mail-wm0-x233.google.com with SMTP id l68so21819745wml.1 for ; Thu, 03 Mar 2016 00:47:38 -0800 (PST) Sender: Paolo Bonzini References: From: Paolo Bonzini Message-ID: <56D7FA27.7020207@redhat.com> Date: Thu, 3 Mar 2016 09:47:35 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Doubts regarding parallelism on KVM, IO threads List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gaurav Sharma , QEMU-DEVEL On 03/03/2016 07:09, Gaurav Sharma wrote: > Hi was trying to do some digging for multi core scenarios both with and > without KVM. > > In short i have some devices and a user application that does some r/w > operations on those devices. > > As per my understanding, in case binary translation using TCG is > invoked, we only create a single Qemuthread for all vcpu's. In case of > KVM we have a Qemuthread for each vcpu as TCG is bypassed in this case. > > > [Test scenario] > Lets say i have devices dev1 and dev2. Test application for dev1 is > executed on core0 and dev2 on core1. > For device dev1, for testing purposes i specified some sleep whenever a > read comes. > In case KVM is enabled, whenever the sleep is hit my whole VM freezes. > > 1. Are are devices emulated in a separate single thread ? No, but device emulation and I/O all run behind the same mutex (affectionately called "big QEMU lock"). See qemu_mutex_lock_iothread and qemu_mutex_unlock_iothread. Paolo > 2. How and where in the code do we do a switch between CPU thread and > IOthread ?