Subject: Re: [PATCH 0/3] tun: fix aio

From: "Michael S. Tsirkin" <[email-masked]>
Date: Tue, 5 May 2009 11:40:05 +0300

On Tue, May 05, 2009 at 12:48:13PM +0930, Rusty Russell wrote:
> On Mon, 27 Apr 2009 07:04:55 pm Michael S. Tsirkin wrote:
> > On Mon, Apr 27, 2009 at 10:48:37AM +0930, Rusty Russell wrote:
> > > > Sure. Here it is: much smaller, but slightly slower.
> > > 
> > > Which could probably be fixed by using an on-stack version for a iovec
> > > of less than a certain size...
> > 
> > I agree that for large message sizes the malloc would probably be
> > dwarfed by the cost of memory copy. However a large iovec might pass a
> > small message, might it not?
> 
> Sorry, I didn't make myself clear.  Something like:
> 
> 	struct iovec smalliov[512 / sizeof(struct iovec)];
> 
> 	if (count < ARRAY_SIZE(smalliov)) {
> 		iv = smalliov;
> 	} else {
> 		iv = kmalloc(...)
> 	}
> 
> 	...
> 
> 	if (iv != smalliov)
> 		kfree(iv);
> 
> Cheers,
> Rusty.

What I was trying to say is that this special-cases iovecs with count >
64. But I think that such iovecs might be used to still pass around
relatively small messages (theoretically as small as 64 bytes) and then
the overhead of the kmalloc/kfree is noticeable.

-- 
MST