All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
Cc: Stephen Rothwell <sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org>,
	Xen Mailing List
	<xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.org>,
	"jmk-zzFmDc4TPjtKvsKVC3L/VUEOCMrvLtNR@public.gmane.org"
	<jmk-zzFmDc4TPjtKvsKVC3L/VUEOCMrvLtNR@public.gmane.org>,
	kvm-devel
	<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	virtualization
	<virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	Christian Borntraeger
	<cborntra-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>,
	Latchesar Ionkov <lionkov-YOWKrPYUwWM@public.gmane.org>,
	Suzanne McIntosh
	<skranjac-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>,
	Jens Axboe <jens.axboe-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	Martin Schwidefsky
	<schwidefsky-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH RFC 3/3] Virtio draft III: example block driver
Date: Tue, 19 Jun 2007 11:34:46 +0300	[thread overview]
Message-ID: <46779526.9080009@qumranet.com> (raw)
In-Reply-To: <1182234466.19064.51.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>

Rusty Russell wrote:
> On Mon, 2007-06-18 at 12:09 +0300, Avi Kivity wrote:
>   
>> Rusty Russell wrote:
>>     
>>> On Sun, 2007-06-17 at 17:25 +0300, Avi Kivity wrote:
>>>   
>>>       
>>>> Rusty Russell wrote:
>>>>     
>>>>         
>>>>> +	/* Set up for reply. */
>>>>> +	vblk->sg[0].page = virt_to_page(&vbr->in_hdr);
>>>>> +	vblk->sg[0].offset = offset_in_page(&vbr->in_hdr);
>>>>> +	vblk->sg[0].length = sizeof(vbr->in_hdr);
>>>>> +	num = blk_rq_map_sg(q, vbr->req, vblk->sg+1);
>>>>> +	vbr->out_hdr.id = vblk->vdev->ops->add_inbuf(vblk->vdev, vblk->sg,
>>>>> +						     1+num, vbr);
>>>>> +	if (IS_ERR_VALUE(vbr->out_hdr.id))
>>>>> +		goto full;
>>>>> +
>>>>> +	vblk->sg[0].page = virt_to_page(&vbr->out_hdr);
>>>>> +	vblk->sg[0].offset = offset_in_page(&vbr->out_hdr);
>>>>> +	vblk->sg[0].length = sizeof(vbr->out_hdr);
>>>>> +
>>>>> +	vbr->out_id = vblk->vdev->ops->add_outbuf(vblk->vdev, vblk->sg, 1,
>>>>> +						  vbr);
>>>>>       
>>>>>           
>>>> This strikes me as wasteful.  Why not set up a single descriptor which 
>>>> contains both placement and the data itself?
>>>>     
>>>>         
>>> We could actually do this for write, but not for read (where the length
>>> & sector need to be sent to other end, and the data comes from other
>>> end).
>>>       
>> So you map the first sg entry for output, and the rest for input.
>>
>> Less pretty, but more efficient.
>>     
>
> At the moment there are two kinds of sgs: input and output.  You're
> proposing instead that we have a single kind, and a flag on each segment
> which indicates direction.  That may make block a little efficient,
> depending on particular implementation of virtio.
>
> Yet network really wants in and out separate.  I'm not even sure how
> we'd implement a mixed-sg scheme efficiently for that case.  At the
> moment it's very straightforward.
>
>   

I think the differences are deeper than that.  Network wants two queues, 
disk wants one queue.  The directionality of the dma transfer is 
orthogonal to that.

For a disk, the initiator is always the guest; you issue a request and 
expend a completion within a few milliseconds.  Read and write requests 
are similar in nature; you want them in a single queue because you want 
the elevator to run on both read and write request.  When idling, the 
queue is empty.

For a network interface, the guest initiates transmits, but the host 
initiates receives.  Yes, the guest preloads the queue with rx 
descriptors, but it can't expect a response in any given time, hence the 
need for two queues.  When idling, the tx queue is empty, the rx queue 
is full.

So I'd suggest having a struct virtio_queue to represent a queue (so a 
network interface would have two of them), and the dma direction to be 
specified separately:

+	unsigned long (*add_buf)(struct virtio_queue *q,
+				 const struct scatterlist out_sg[], int out_nr,
+				 const struct scatterlist in_sg[], int in_nr,
+				 void *data);


I think this fits better with the Xen model (which has one ring for 
block, two each for network and console, if memory serves).

> Of course, I'm carrying two implementations and two drivers, so it's
> natural for me to try to resist changes 8

Life is rough on the frontier.  But all the glory will be yours!

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

  parent reply	other threads:[~2007-06-19  8:34 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-07 12:02 [PATCH RFC 0/3] Virtio draft II Rusty Russell
2007-06-07 12:04 ` [PATCH RFC 1/3] Virtio draft II: virtio.h Rusty Russell
     [not found]   ` <1181217867.14054.195.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-07 12:05     ` [PATCH RFC 2/3] Virtio draft II: example block driver Rusty Russell
2007-06-07 12:07       ` [PATCH RFC 3/3] Virtio draft II: example net driver Rusty Russell
2007-06-07 12:19       ` [PATCH RFC 2/3] Virtio draft II: example block driver Avi Kivity
     [not found]       ` <1181217920.14054.196.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-07 12:07         ` [PATCH RFC 3/3] Virtio draft II: example net driver Rusty Russell
2007-06-07 12:19         ` [PATCH RFC 2/3] Virtio draft II: example block driver Avi Kivity
2007-06-08  1:11           ` Rusty Russell
     [not found]           ` <4667F7C0.3070604-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-08  1:11             ` Rusty Russell
2007-06-07 12:05   ` Rusty Russell
2007-06-07 12:04 ` [PATCH RFC 1/3] Virtio draft II: virtio.h Rusty Russell
2007-06-16 13:12 ` [PATCH RFC 0/3] Virtio draft III Rusty Russell
     [not found] ` <1181217762.14054.192.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:12   ` Rusty Russell
2007-06-16 13:14     ` [PATCH RFC 1/3] Virtio draft III: virtio.h Rusty Russell
2007-06-17 14:14     ` [kvm-devel] [PATCH RFC 0/3] Virtio draft III Avi Kivity
     [not found]     ` <1181999552.6237.255.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:14       ` [PATCH RFC 1/3] Virtio draft III: virtio.h Rusty Russell
2007-06-16 13:17         ` [PATCH RFC 2/3] Virtio draft III: example net driver Rusty Russell
     [not found]         ` <1181999669.6237.257.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:17           ` Rusty Russell
     [not found]             ` <1181999825.6237.260.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:18               ` [PATCH RFC 3/3] Virtio draft III: example block driver Rusty Russell
     [not found]                 ` <1181999920.6237.263.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:28                   ` [PATCH] Lguest implemention of virtio draft III Rusty Russell
     [not found]                     ` <1182000514.6237.273.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-16 13:50                       ` Arnd Bergmann
2007-06-16 13:50                     ` [kvm-devel] " Arnd Bergmann
2007-06-17 14:25                   ` [PATCH RFC 3/3] Virtio draft III: example block driver Avi Kivity
     [not found]                     ` <46754451.2010305-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-18  8:08                       ` Rusty Russell
     [not found]                         ` <1182154095.19064.24.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-18  9:09                           ` Avi Kivity
     [not found]                             ` <46764BB5.6070704-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-19  6:27                               ` Rusty Russell
     [not found]                                 ` <1182234466.19064.51.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-19  8:34                                   ` Avi Kivity [this message]
2007-06-19  8:34                                 ` Avi Kivity
2007-06-19  6:27                             ` Rusty Russell
2007-06-18  9:09                         ` Avi Kivity
2007-06-18  8:08                     ` Rusty Russell
2007-06-16 13:28                 ` [PATCH] Lguest implemention of virtio draft III Rusty Russell
2007-06-17 14:25                 ` [PATCH RFC 3/3] Virtio draft III: example block driver Avi Kivity
2007-06-25 15:26               ` [PATCH RFC 2/3] Virtio draft III: example net driver Brian King
     [not found]                 ` <467FDEAD.4030204-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2007-06-25 19:33                   ` Christoph Hellwig
     [not found]                     ` <20070625193304.GB25736-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2007-06-25 21:54                       ` Avi Kivity
     [not found]                         ` <46803999.4040500-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-25 22:13                           ` Brian King
2007-06-25 22:20                             ` [kvm-devel] " Avi Kivity
     [not found]                             ` <46803E0E.7080103-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2007-06-25 22:20                               ` Avi Kivity
2007-06-25 22:13                         ` [kvm-devel] " Brian King
2007-06-25 21:54                     ` Avi Kivity
2007-06-25 19:33                 ` Christoph Hellwig
2007-06-28 11:20                 ` Rusty Russell
2007-06-28 15:55                   ` Brian King
     [not found]                   ` <1183029641.12401.36.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-06-28 15:55                     ` Brian King
2007-06-28 11:20                 ` Rusty Russell
2007-06-16 13:18             ` [PATCH RFC 3/3] Virtio draft III: example block driver Rusty Russell
2007-06-25 15:26             ` [PATCH RFC 2/3] Virtio draft III: example net driver Brian King
2007-06-17 14:14       ` [PATCH RFC 0/3] Virtio draft III Avi Kivity
2007-06-18  7:48         ` [Xen-devel] Re: [kvm-devel] " Rusty Russell
     [not found]         ` <467541DF.5060907-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-18  7:48           ` [Xen-devel] " Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46779526.9080009@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=cborntra-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
    --cc=jens.axboe-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=jmk-zzFmDc4TPjtKvsKVC3L/VUEOCMrvLtNR@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=lionkov-YOWKrPYUwWM@public.gmane.org \
    --cc=rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org \
    --cc=schwidefsky-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
    --cc=sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org \
    --cc=skranjac-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=xen-devel-GuqFBffKawuULHF6PoxzQEEOCMrvLtNR@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.