(2012/09/26 16:48), Sjur BRENDELAND wrote: >>> -static struct port_buffer *alloc_buf(size_t buf_size) >>> +static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size, >>> + int nrbufs) >>> { >>> struct port_buffer *buf; >>> + size_t alloc_size; >>> >>> - buf = kmalloc(sizeof(*buf), GFP_KERNEL); >>> + /* Allocate buffer and the scatter list */ >>> + alloc_size = sizeof(*buf) + sizeof(struct scatterlist) * nrbufs; >> >> This allocates one redundant sg entry when nrbuf > 0, >> but I think it is OK. (just a comment) > > I did this on purpose for the sake of simplicity, but I can > change this to something like: > alloc_size = sizeof(*buf) + sizeof(buf->sg) * max(nrbufs - 1, 1);
You wouldn't need to change that. I think current code is enough simple and reasonable. :) Thanks! -- Masami HIRAMATSU Software Platform Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: masami.hiramatsu...@hitachi.com _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization