On Tue, 29 Oct 2019 10:02:57 +0100 David Marchand <david.march...@redhat.com> wrote:
> On Tue, Oct 15, 2019 at 9:00 PM Flavio Leitner <f...@sysclose.org> > wrote: > > diff --git a/lib/librte_vhost/virtio_net.c > > b/lib/librte_vhost/virtio_net.c index 5b85b832d..da69ab1db 100644 > > --- a/lib/librte_vhost/virtio_net.c > > +++ b/lib/librte_vhost/virtio_net.c > > @@ -1289,6 +1289,93 @@ get_zmbuf(struct vhost_virtqueue *vq) > > return NULL; > > } > > > > +static void > > +virtio_dev_extbuf_free(void *addr __rte_unused, void *opaque) > > +{ > > + rte_free(opaque); > > +} > > + > > +static int > > +virtio_dev_extbuf_alloc(struct rte_mbuf *pkt, uint32_t size) > > +{ > > + struct rte_mbuf_ext_shared_info *shinfo = NULL; > > + uint32_t total_len = RTE_PKTMBUF_HEADROOM + size; > > + uint16_t buf_len; > > + rte_iova_t iova; > > + void *buf; > > + > > + /* Try to use pkt buffer to store shinfo to reduce the > > amount of memory > > + * required, otherwise store shinfo in the new buffer. > > + */ > > + if (rte_pktmbuf_tailroom(pkt) >= sizeof(*shinfo)) > > + shinfo = rte_pktmbuf_mtod(pkt, > > + struct > > rte_mbuf_ext_shared_info *); > > + else { > > + total_len += sizeof(*shinfo) + sizeof(uintptr_t); > > + total_len = RTE_ALIGN_CEIL(total_len, > > sizeof(uintptr_t)); > > + } > > + > > + if (unlikely(total_len > UINT16_MAX)) > > + return -ENOSPC; > > + > > + buf_len = total_len; > > + buf = rte_malloc(NULL, buf_len, RTE_CACHE_LINE_SIZE); > > Using rte_malloc() means that the allocation can end up on any numa > node. This external buffer might end up on a different node than the > mbuf (which resides on mp->socket_id node). Only if there is no memory in the local socket. It seems better than a failure to me. fbl