From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J00jw-0001FB-Jz for qemu-devel@nongnu.org; Wed, 05 Dec 2007 15:21:04 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J00ju-0001CN-Nx for qemu-devel@nongnu.org; Wed, 05 Dec 2007 15:21:03 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J00ju-0001CC-Ds for qemu-devel@nongnu.org; Wed, 05 Dec 2007 15:21:02 -0500 Received: from e1.ny.us.ibm.com ([32.97.182.141]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J00ju-00063p-2m for qemu-devel@nongnu.org; Wed, 05 Dec 2007 15:21:02 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e1.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id lB5KKgQT021484 for ; Wed, 5 Dec 2007 15:20:42 -0500 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id lB5KKg25090382 for ; Wed, 5 Dec 2007 15:20:42 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id lB5KKfHa021489 for ; Wed, 5 Dec 2007 15:20:41 -0500 Message-ID: <47570817.9090908@us.ibm.com> Date: Wed, 05 Dec 2007 14:20:39 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH 2/3] virtio network device References: <4755CC8C.6000001@us.ibm.com> <4755E774.8090408@qumranet.com> <4756DD7A.8070008@us.ibm.com> <200712051744.03916.paul@codesourcery.com> In-Reply-To: <200712051744.03916.paul@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: Rusty Russell , qemu-devel@nongnu.org Paul Brook wrote: >>> Actually according to qemu's standard, one should use >>> cpu_physical_memory_write/ cpu_physical_memory_read functions. >>> This is true also for reading the ring values. >>> >> Yes, and unfortunately, cpu_physical_memory_{read,write} are copy >> interfaces. We really don't want that for high speed I/O. >> > > I really don't like doing direct access to guest ram without implementing a > proper API for zero-copy/scatter-gather access. There was a list thread about > this not so long ago. > I agree that we need a proper API for sg ram access. I'm going to look into that real soon since it's necessary to optimize the network/disk transports. virtio makes things a bit trickier though. There's a shared ring queue between the host and guest. The ring queue is lock-less and depends on the ability to atomically increment ring queue indices to be SMP safe. Using a copy-API wouldn't be a problem for QEMU since the host and guest are always running in lock-step. A copy API is actually needed to deal with differing host/guest alignment and endianness. Once you introduce KVM though, this is no longer true since KVM supports true SMP. The solution may be to implement some sort of atomic_increment function and then have that use a if (kvm) guard to do a direct access verses a copy. Regards, Anthony Liguori > Paul >