[ovs-dev] [RFC PATCH 15/21] dpif-netdev: Add additional datapath health checks.

Bhanuprakash Bodireddy bhanuprakash.bodireddy at intel.com
Wed Jun 7 16:15:11 UTC 2017


This commit enables additional datapath health checks. The checks
are enabled only on a PMD heartbeat failure. On missing three successive
heartbeats additional health checks needs to be performed on each PMD
to confirm and flag the failure.

The datapath health is monitored periodically from keepalive thread.
It should be noted that the PMD health checks are only performed on
the PMD threads whose health check is enabled.

Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy at intel.com>
---
 lib/dpif-netdev.c | 23 +++++++++++++++++++++++
 lib/keepalive.c   | 24 ++++++++++++++++++++++++
 lib/keepalive.h   |  3 +++
 3 files changed, 50 insertions(+)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 6ac1bd3..b2f0611 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -970,6 +970,28 @@ sorted_poll_thread_list(struct dp_netdev *dp,
     *n = k;
 }
 
+static void
+pmd_health_check(struct dp_netdev_pmd_thread *pmd OVS_UNUSED)
+{
+    /* Nothing */
+}
+
+static void
+get_datapath_health(struct dp_netdev *dp)
+{
+    for (int core_id = 0; core_id < KEEPALIVE_MAXCORES; core_id++) {
+        struct dp_netdev_pmd_thread *pmd;
+
+        /* Check only PMD threads whose health check is enabled. */
+        if (OVS_LIKELY(!ka_is_pmdhealth_check_needed(core_id))) {
+            continue;
+        }
+
+        pmd = dp_netdev_get_pmd(dp, core_id);
+        pmd_health_check(pmd);
+    }
+}
+
 static void *
 ovs_keepalive(void *f_)
 {
@@ -981,6 +1003,7 @@ ovs_keepalive(void *f_)
         int n_pmds = cmap_count(&dp->poll_threads) - 1;
         if (n_pmds > 0) {
             dispatch_heartbeats();
+            get_datapath_health(dp);
             get_ka_stats();
         }
 
diff --git a/lib/keepalive.c b/lib/keepalive.c
index da830ab..9fa9ad9 100644
--- a/lib/keepalive.c
+++ b/lib/keepalive.c
@@ -42,6 +42,8 @@ struct keepalive_shm *ka_shm = NULL;
 static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER;
 static struct smap *keepalive_stats OVS_GUARDED_BY(mutex);
 
+static bool ka_pmd_core_health[KEEPALIVE_MAXCORES] = {false};
+
 /* Return the Keepalive shared memory block name. */
 static inline const char *
 get_ka_shm_blk(void)
@@ -124,6 +126,28 @@ ka_mark_pmd_thread_sleep(void)
     }
 }
 
+void
+ka_enable_pmd_health_check(unsigned core_id)
+{
+    if (is_ka_enabled()) {
+        ka_pmd_core_health[core_id] = true;
+    }
+}
+
+void
+ka_disable_pmd_health_check(unsigned core_id)
+{
+    if (is_ka_enabled()) {
+        ka_pmd_core_health[core_id] = false;
+    }
+}
+
+bool
+ka_is_pmdhealth_check_needed(unsigned core_id)
+{
+    return ka_pmd_core_health[core_id];
+}
+
 /* Retrieve and return the keepalive timer interval from OVSDB. */
 static uint32_t
 get_ka_timer_interval(const struct smap *ovs_other_config OVS_UNUSED)
diff --git a/lib/keepalive.h b/lib/keepalive.h
index 63f35f0..32ea729 100644
--- a/lib/keepalive.h
+++ b/lib/keepalive.h
@@ -60,6 +60,9 @@ void ka_register_pmd_thread(unsigned);
 void ka_unregister_pmd_thread(unsigned);
 void ka_mark_pmd_thread_alive(void);
 void ka_mark_pmd_thread_sleep(void);
+void ka_enable_pmd_health_check(unsigned);
+void ka_disable_pmd_health_check(unsigned);
+bool ka_is_pmdhealth_check_needed(unsigned);
 
 void ka_get_tid(unsigned core);
 bool is_ka_enabled(void);
-- 
2.4.11



More information about the dev mailing list