From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 3/3] virtio_ring: unify direct/indirect code paths. Date: Fri, 05 Sep 2014 12:55:37 +0200 Message-ID: <540996A9.4060100@redhat.com> References: <1409718556-3041-1-git-send-email-rusty@rustcorp.com.au> <1409718556-3041-4-git-send-email-rusty@rustcorp.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: virtualization@lists.linux-foundation.org, Andy Lutomirski , "Michael S. Tsirkin" To: Rusty Russell , netdev Return-path: In-Reply-To: <1409718556-3041-4-git-send-email-rusty@rustcorp.com.au> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org List-Id: netdev.vger.kernel.org Il 03/09/2014 06:29, Rusty Russell ha scritto: > + desc = kmalloc(total_sg * sizeof(struct vring_desc), gfp); > + if (!desc) > + return NULL; > > - return head; > + for (i = 0; i < total_sg; i++) > + desc[i].next = i+1; > + return desc; > } Would it make sense to keep a cache of a few (say) 8- or 16-element indirect descriptors? You'd only have to do this ugly (and slowish) for loop on the first allocation. Also, since this is mostly an aesthetic patch, > + if (indirect) > + vq->free_head = vq->vring.desc[head].next; > + else > + vq->free_head = i; I'd move the indirect case above, where the vring.desc[head] is actually allocated. Paolo