From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9UDV-000827-MP for qemu-devel@nongnu.org; Thu, 17 Dec 2015 03:47:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9UDQ-0004j1-Jo for qemu-devel@nongnu.org; Thu, 17 Dec 2015 03:47:17 -0500 Received: from mx0.arrikto.com ([212.71.252.59]:59296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9UDQ-0004ir-Dv for qemu-devel@nongnu.org; Thu, 17 Dec 2015 03:47:12 -0500 References: <1450284917-10508-1-git-send-email-apyrgio@arrikto.com> <5671AA78.8050603@redhat.com> From: Alex Pyrgiotis Message-ID: <5672768E.70101@arrikto.com> Date: Thu, 17 Dec 2015 10:47:10 +0200 MIME-Version: 1.0 In-Reply-To: <5671AA78.8050603@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 0/9] Add full scatter-gather support for SCSI generic devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org Hi Paolo, On 12/16/2015 08:16 PM, Paolo Bonzini wrote: > > > On 16/12/2015 17:55, Alex Pyrgiotis wrote: >> Hi all, >> >> This patch is an attempt to boost the performance of "scsi-generic" and >> "scsi-block" device types, by removing an extra data copy and reducing >> their memory footprint. More specifically, the problem lies in the >> functions in the `scsi-generic_req_ops` struct of scsi-generic.c. These >> functions rely on an intermediate buffer to do the SG_IO ioctl request, >> without checking if the SCSI controller has provided a scatter-gather >> list with the request. >> >> In a nutshell, our proposal is to map the provided scatter-gather list >> (if any) to the address space of the QEMU process and use the resulting >> iovec as the buffer for the ioctl request. You'll find that the logic is >> quite similar to the one used in scsi-disk.c. > > Which commands have large payloads and are on the data path, for > scsi-block? Or is the use case just scsi-generic (e.g. tape devices?)? > > (Just trying to understand before I dive into the patches). Sure, no problem. The commands that have large payloads and are on the data path are the classic SCSI READ/WRITE commands. Usually, these commands are implemented with vectored reads/writes, which utilize the controller's scatter-gather list. However, when opening a "scsi-block" device with the default cache policy (cache=writeback), QEMU fallbacks to the "scsi-generic" functions (i.e, SG_IO ioctl requests) for reading/writing data [1]. In this case, the data are copied in a bounce buffer, which is the issue that this patch tackles. Thanks, Alex [1]: I'll quote the comment on the code for the rationale behind this choice: "If we are not using O_DIRECT, we might read stale data from the host cache if writes were made using other commands than these ones (such as WRITE SAME or EXTENDED COPY, etc.). So, without O_DIRECT everything must go through SG_IO."