From afee281f7f4f4b477e5c12bf18fe00d097ce8e96 Mon Sep 17 00:00:00 2001 From: Kevin Traynor Date: Fri, 5 Feb 2016 17:07:16 +0000 Subject: [PATCH] netdev-dpdk: Fix dpdk_watchdog failure to quiesce. Fix issue whereby vhost_thread is waiting for dpdk_watchdog thread to quiesce and at the same time dpdk_watchdog thread is waiting for vhost_thread to give up dpdk_mutex. Reported-by: Patrik Andersson R Signed-off-by: Patrik Andersson R Signed-off-by: Kevin Traynor Signed-off-by: Daniele Di Proietto --- AUTHORS | 1 + lib/netdev-dpdk.c | 35 ++++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/AUTHORS b/AUTHORS index 492f91a6b..3539e55b2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -360,6 +360,7 @@ Niels van Adrichem N.L.M.vanAdrichem@tudelft.nl Niklas Andersson nandersson@nicira.com Pankaj Thakkar thakkar@nicira.com Pasi Kärkkäinen pasik@iki.fi +Patrik Andersson R patrik.r.andersson@ericsson.com Paulo Cravero pcravero@as2594.net Pawan Shukla shuklap@vmware.com Peter Amidon peter@picnicpark.org diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 2a479e2c7..e4f789b14 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1904,6 +1904,7 @@ static void destroy_device(volatile struct virtio_net *dev) { struct netdev_dpdk *vhost_dev; + bool exists = false; ovs_mutex_lock(&dpdk_mutex); LIST_FOR_EACH (vhost_dev, list_node, &dpdk_list) { @@ -1912,24 +1913,32 @@ destroy_device(volatile struct virtio_net *dev) ovs_mutex_lock(&vhost_dev->mutex); dev->flags &= ~VIRTIO_DEV_RUNNING; ovsrcu_set(&vhost_dev->virtio_dev, NULL); + exists = true; ovs_mutex_unlock(&vhost_dev->mutex); - - /* - * Wait for other threads to quiesce before - * setting the virtio_dev to NULL. - */ - ovsrcu_synchronize(); - /* - * As call to ovsrcu_synchronize() will end the quiescent state, - * put thread back into quiescent state before returning. - */ - ovsrcu_quiesce_start(); + break; } } + ovs_mutex_unlock(&dpdk_mutex); - VLOG_INFO("vHost Device '%s' %"PRIu64" has been removed", dev->ifname, - dev->device_fh); + if (exists == true) { + /* + * Wait for other threads to quiesce after setting the 'virtio_dev' + * to NULL, before returning. + */ + ovsrcu_synchronize(); + /* + * As call to ovsrcu_synchronize() will end the quiescent state, + * put thread back into quiescent state before returning. + */ + ovsrcu_quiesce_start(); + VLOG_INFO("vHost Device '%s' %"PRIu64" has been removed", dev->ifname, + dev->device_fh); + } else { + VLOG_INFO("vHost Device '%s' %"PRIu64" not found", dev->ifname, + dev->device_fh); + } + } struct virtio_net * -- 2.20.1