All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Chen, Junjie J" <junjie.j.chen@intel.com>
To: "Yang, Zhiyong" <zhiyong.yang@intel.com>,
	"yliu@fridaylinux.org" <yliu@fridaylinux.org>,
	"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [PATCH] vhost: do deep copy while reallocate vq
Date: Mon, 15 Jan 2018 09:14:47 +0000	[thread overview]
Message-ID: <AA85A5A5E706C44BACB0BEFD5AC08BF63132C026@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <E182254E98A5DA4EB1E657AC7CB9BD2A8B0250EC@BGSMSX101.gar.corp.intel.com>

Hi

> > @@ -227,6 +227,7 @@ vhost_user_set_vring_num(struct virtio_net *dev,
> >  				"zero copy is force disabled\n");
> >  			dev->dequeue_zero_copy = 0;
> >  		}
> > +		TAILQ_INIT(&vq->zmbuf_list);
> >  	}
> >
> >  	vq->shadow_used_ring = rte_malloc(NULL, @@ -261,6 +262,9 @@
> > numa_realloc(struct virtio_net *dev, int index)
> >  	int oldnode, newnode;
> >  	struct virtio_net *old_dev;
> >  	struct vhost_virtqueue *old_vq, *vq;
> > +	struct zcopy_mbuf *new_zmbuf;
> > +	struct vring_used_elem *new_shadow_used_ring;
> > +	struct batch_copy_elem *new_batch_copy_elems;
> >  	int ret;
> >
> >  	old_dev = dev;
> > @@ -285,6 +289,33 @@ numa_realloc(struct virtio_net *dev, int index)
> >  			return dev;
> >
> >  		memcpy(vq, old_vq, sizeof(*vq));
> > +		TAILQ_INIT(&vq->zmbuf_list);
> > +
> > +		new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
> > +			sizeof(struct zcopy_mbuf), 0, newnode);
> > +		if (new_zmbuf) {
> > +			rte_free(vq->zmbufs);
> > +			vq->zmbufs = new_zmbuf;
> > +		}
> 
> You need to consider how to handle the case  ( rte_malloc_socket return
> NULL).

If it failed to allocate new_zmbuf, it uses old zmbufs, so as to keep vhost alive.

> 
> > +		new_shadow_used_ring = rte_malloc_socket(NULL,
> > +			vq->size * sizeof(struct vring_used_elem),
> > +			RTE_CACHE_LINE_SIZE,
> > +			newnode);
> > +		if (new_shadow_used_ring) {
> > +			rte_free(vq->shadow_used_ring);
> > +			vq->shadow_used_ring = new_shadow_used_ring;
> > +		}
> > +
> 
> Ditto
> 
> > +		new_batch_copy_elems = rte_malloc_socket(NULL,
> > +			vq->size * sizeof(struct batch_copy_elem),
> > +			RTE_CACHE_LINE_SIZE,
> > +			newnode);
> > +		if (new_batch_copy_elems) {
> > +			rte_free(vq->batch_copy_elems);
> > +			vq->batch_copy_elems = new_batch_copy_elems;
> > +		}
> 
> Ditto
> 
> > +
> >  		rte_free(old_vq);
> >  	}
> >
> > --
> > 2.0.1

  reply	other threads:[~2018-01-15  9:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15 11:32 [PATCH] vhost: do deep copy while reallocate vq Junjie Chen
2018-01-15  9:05 ` Yang, Zhiyong
2018-01-15  9:14   ` Chen, Junjie J [this message]
2018-01-16  0:57     ` Yang, Zhiyong
2018-01-16  7:38       ` Chen, Junjie J
2018-01-17  1:36         ` Yang, Zhiyong
2018-01-16  8:54 ` Maxime Coquelin
2018-01-17 14:46 ` Yuanhan Liu

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=AA85A5A5E706C44BACB0BEFD5AC08BF63132C026@SHSMSX101.ccr.corp.intel.com \
    --to=junjie.j.chen@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=yliu@fridaylinux.org \
    --cc=zhiyong.yang@intel.com \
    /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.