[ovs-dev] [PATCH v2 3/3] netdev-dpdk: reset queue number for vhost devices on vm shutdown

David Marchand david.marchand at redhat.com
Wed Apr 17 08:37:53 UTC 2019


On Tue, Apr 16, 2019 at 4:01 PM Ilya Maximets <i.maximets at samsung.com>
wrote:

> On 16.04.2019 12:45, David Marchand wrote:
> > Rather than poll all disabled queues and waste some memory for vms that
> > have been shutdown, we can reconfigure when receiving a destroy
> > connection notification from the vhost library.
> >
> > $ while true; do
> >   ovs-appctl dpif-netdev/pmd-rxq-show |awk '
> >   /port: / {
> >     tot++;
> >     if ($NF == "disabled") {
> >       dis++;
> >     }
> >   }
> >   END {
> >     print "total: " tot ", enabled: " (tot - dis)
> >   }'
> >   sleep 1
> > done
> >
> > total: 66, enabled: 66
> > total: 6, enabled: 2
> >
> > Note: this patch requires a fix for the vhost library submitted here:
> > http://patchwork.dpdk.org/patch/52680/
> >
> > Without it, this change will do nothing but have openvswitch complain
> > that the vhost device is unknown:
> >
> > dpdk|INFO|VHOST_CONFIG: vhost peer closed
> > dpdk|ERR|VHOST_CONFIG: (0) device not found.
> >
> > dpdk|INFO|VHOST_CONFIG: vhost peer closed
> > dpdk|ERR|VHOST_CONFIG: (1) device not found.
> >
> > Signed-off-by: David Marchand <david.marchand at redhat.com>
> > ---
> >  lib/netdev-dpdk.c | 35 ++++++++++++++++++++++++++++++++++-
> >  1 file changed, 34 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> > index fc554db..a7fae4f 100644
> > --- a/lib/netdev-dpdk.c
> > +++ b/lib/netdev-dpdk.c
> > @@ -186,12 +186,15 @@ static const struct rte_eth_conf port_conf = {
> >  static int new_device(int vid);
> >  static void destroy_device(int vid);
> >  static int vring_state_changed(int vid, uint16_t queue_id, int enable);
> > +static void destroy_connection(int vid);
> >  static const struct vhost_device_ops virtio_net_device_ops =
> >  {
> >      .new_device =  new_device,
> >      .destroy_device = destroy_device,
> >      .vring_state_changed = vring_state_changed,
> > -    .features_changed = NULL
> > +    .features_changed = NULL,
> > +    .new_connection = NULL,
> > +    .destroy_connection = destroy_connection,
> >  };
> >
> >  enum { DPDK_RING_SIZE = 256 };
> > @@ -3661,6 +3664,36 @@ vring_state_changed(int vid, uint16_t queue_id,
> int enable)
> >      return 0;
> >  }
> >
> > +static void
> > +destroy_connection(int vid)
> > +{
> > +    struct netdev_dpdk *dev;
> > +    char ifname[IF_NAME_SZ];
> > +
> > +    rte_vhost_get_ifname(vid, ifname, sizeof ifname);
> > +
> > +    ovs_mutex_lock(&dpdk_mutex);
> > +    /* Add device to the vhost port with the same name as that passed
> down. */
>
> This comment is a leftover from the 'new_device'. It could be dropped.
>

Yep.



> > +    LIST_FOR_EACH (dev, list_node, &dpdk_list) {
> > +        ovs_mutex_lock(&dev->mutex);
> > +        if (nullable_string_is_equal(ifname, dev->vhost_id)) {
> > +            uint32_t qp_num = NR_QUEUE;
> > +
>
> It might be good to check if device is destroyed here and log an error
> otherwise.
>

So that we have a log similar to what we have in destroy_device() ?


-- 
David Marchand


More information about the dev mailing list