From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932078Ab2LRNoH (ORCPT ); Tue, 18 Dec 2012 08:44:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49231 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754888Ab2LRNoE (ORCPT ); Tue, 18 Dec 2012 08:44:04 -0500 Message-ID: <50D07317.8050902@redhat.com> Date: Tue, 18 Dec 2012 14:43:51 +0100 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: "Michael S. Tsirkin" CC: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, gaowanlong@cn.fujitsu.com, hutao@cn.fujitsu.com, linux-scsi@vger.kernel.org, virtualization@lists.linux-foundation.org, rusty@rustcorp.com.au, asias@redhat.com, stefanha@redhat.com, nab@linux-iscsi.org Subject: Re: [PATCH v2 1/5] virtio: add functions for piecewise addition of buffers References: <1355833972-20319-1-git-send-email-pbonzini@redhat.com> <1355833972-20319-2-git-send-email-pbonzini@redhat.com> <20121218133606.GC26110@redhat.com> In-Reply-To: <20121218133606.GC26110@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 18/12/2012 14:36, Michael S. Tsirkin ha scritto: > Some comments without arguing about whether the performance > benefit is worth it. > > On Tue, Dec 18, 2012 at 01:32:48PM +0100, Paolo Bonzini wrote: >> diff --git a/include/linux/virtio.h b/include/linux/virtio.h >> index cf8adb1..39d56c4 100644 >> --- a/include/linux/virtio.h >> +++ b/include/linux/virtio.h >> @@ -7,6 +7,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> /** >> @@ -40,6 +41,26 @@ int virtqueue_add_buf(struct virtqueue *vq, >> void *data, >> gfp_t gfp); >> >> +struct virtqueue_buf { >> + struct virtqueue *vq; >> + struct vring_desc *indirect, *tail; > > This is wrong: virtio.h does not include virito_ring.h, > and it shouldn't by design depend on it. > >> + int head; >> +}; >> + > > Can't we track state internally to the virtqueue? > Exposing it seems to buy us nothing since you can't > call add_buf between start and end anyway. I wanted to keep the state for these functions separate from the rest. I don't think it makes much sense to move it to struct virtqueue unless virtqueue_add_buf is converted to use the new API (doesn't make much sense, could even be a tad slower). On the other hand moving it there would eliminate the dependency on virtio_ring.h. Rusty, what do you think? >> +int virtqueue_start_buf(struct virtqueue *_vq, >> + struct virtqueue_buf *buf, >> + void *data, >> + unsigned int count, >> + unsigned int count_sg, >> + gfp_t gfp); >> + >> +void virtqueue_add_sg(struct virtqueue_buf *buf, >> + struct scatterlist sgl[], >> + unsigned int count, >> + enum dma_data_direction dir); >> + > > And idea: in practice virtio scsi seems to always call sg_init_one, no? > So how about we pass in void* or something and avoid using sg and count? > This would make it useful for -net BTW. It also passes the scatterlist from the LLD. It calls sg_init_one for the request/response headers. Paolo >> +void virtqueue_end_buf(struct virtqueue_buf *buf); >> + >> void virtqueue_kick(struct virtqueue *vq); >> >> bool virtqueue_kick_prepare(struct virtqueue *vq); >> -- >> 1.7.1 >>