From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0liU-00037n-VF for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:16:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0liT-0000Ww-TM for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:16:02 -0400 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:37125) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d0liT-0000Vp-Mb for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:16:01 -0400 Received: by mail-wm0-x22c.google.com with SMTP id m123so6210523wma.0 for ; Wed, 19 Apr 2017 02:16:01 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Peter Maydell Date: Wed, 19 Apr 2017 10:15:40 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] Hight Processor time of Socket communciation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jiahuan Zhang Cc: QEMU Developers On 19 April 2017 at 09:56, Jiahuan Zhang wrote: > Do you mean that it is reasonable for QEMU emulation consumes high CPU time > when doing host-guest interaction, since the interaction calls many QEMU > codes in the background? > Since my guest app is rather simple and no while() is included, according to > your words, > can I conclude that the high processor time is cause by the callbacks for > guest to host data transfer? What is happening is that the guest kernel's serial driver has a loop that (simplified) looks like this: do { if (pl011_read(REG_FR) & FR_TXFF) break; /* fifo full, try again later */ pl011_write(buffer[x], REG_DR); /* send one byte */ x++; } while (x != len); This is a lot of guest CPU instructions (and two callouts to QEMU's device emulation) for every single byte. >> You will likely get better throughput if you use the 'virt' board >> where you can use the virtio-serial device which can send >> data more efficiently. > Here, can I understand your statement in this way, > a transmit buffer in the serial device for guest to host data transfer > may reduce the processor time, and in turn, increase the throughput? The reason virtio-serial is faster is because the guest kernel driver can essentially tell QEMU "the data is in guest memory at address X length L" and then QEMU takes all that data at once. This is much more efficient. thanks -- PMM