This commit implements APIs to retrieve the PMD thread status and return
the status in the below format for each PMD thread.
Format: pmdid="status,core id,last_seen_timestamp"
eg: pmd62="ALIVE,2,9220698256784207"
pmd63="GONE,3,9220698256786231"
The status is periodically retrieved by keepalive thread and stored in
keepalive_stats struc which later shall be retrieved by vswitchd thread.
In case of four PMD threads the status is as below:
"pmd62"="ALIVE,0,9220698256784207"
"pmd63"="ALIVE,1,9220698256784913"
"pmd64"="ALIVE,2,9220698256785902"
"pmd65"="ALIVE,3,9220698256786231"
Signed-off-by: Bhanuprakash Bodireddy <[email protected]>
---
lib/dpif-netdev.c | 1 +
lib/keepalive.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/keepalive.h | 1 +
3 files changed, 75 insertions(+)
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index a06d1fa..33b6fd0 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -985,6 +985,7 @@ ovs_keepalive(void *f_)
int n_pmds = cmap_count(&dp->poll_threads) - 1;
if (n_pmds > 0) {
dispatch_heartbeats();
+ get_ka_stats();
}
ovsrcu_quiesce_start();
diff --git a/lib/keepalive.c b/lib/keepalive.c
index 3270de7..d466cbe 100644
--- a/lib/keepalive.c
+++ b/lib/keepalive.c
@@ -25,6 +25,7 @@
#include "keepalive.h"
#include "lib/vswitch-idl.h"
#include "openvswitch/vlog.h"
+#include "ovs-thread.h"
#include "process.h"
VLOG_DEFINE_THIS_MODULE(keepalive);
@@ -34,6 +35,9 @@ static bool ka_init_status = ka_init_failure; /* Keepalive
initialization */
static uint32_t keepalive_timer_interval; /* keepalive timer interval */
static struct keepalive_info *ka_info = NULL;
+static struct ovs_mutex mutex = OVS_MUTEX_INITIALIZER;
+static struct smap *keepalive_stats OVS_GUARDED_BY(mutex);
+
inline bool
ka_is_enabled(void)
{
@@ -267,6 +271,75 @@ keepalive_info_create(void)
return ka_info;
}
+static void
+get_pmd_status(struct smap *ka_pmd_stats)
+ OVS_REQUIRES(ka_info->proclist_mutex)
+{
+ if (OVS_UNLIKELY(!ka_info)) {
+ return;
+ }
+
+ struct ka_process_info *pinfo, *pinfo_next;
+ HMAP_FOR_EACH_SAFE (pinfo, pinfo_next, node, &ka_info->process_list) {
+ int core_id = pinfo->core_id;
+ char *state = NULL;
+ if (pinfo->core_state == KA_STATE_UNUSED ||
+ pinfo->core_state == KA_STATE_SLEEP ) {
+ continue;
+ }
+
+ switch (pinfo->core_state) {
+ case KA_STATE_ALIVE:
+ state = "ALIVE";
+ break;
+ case KA_STATE_MISSING:
+ state = "MISSING";
+ break;
+ case KA_STATE_DEAD:
+ state = "DEAD";
+ break;
+ case KA_STATE_GONE:
+ state = "GONE";
+ break;
+ case KA_STATE_DOZING:
+ state = "DOZING";
+ break;
+ case KA_STATE_SLEEP:
+ state = "SLEEP";
+ break;
+ case KA_STATE_CHECK:
+ state = "HEALTH_CHECK_RUNNING";
+ break;
+ case KA_STATE_UNUSED:
+ break;
+ }
+
+ smap_add_format(ka_pmd_stats, pinfo->name, "%s,%d,%ld",
+ state, core_id, pinfo->core_last_seen_times);
+ }
+}
+
+void
+get_ka_stats(void)
+{
+ struct smap *ka_pmd_stats;
+ ka_pmd_stats = xmalloc(sizeof *ka_pmd_stats);
+ smap_init(ka_pmd_stats);
+
+ ovs_mutex_lock(&ka_info->proclist_mutex);
+ get_pmd_status(ka_pmd_stats);
+ ovs_mutex_unlock(&ka_info->proclist_mutex);
+
+ ovs_mutex_lock(&mutex);
+ if (keepalive_stats) {
+ smap_destroy(keepalive_stats);
+ free(keepalive_stats);
+ keepalive_stats = NULL;
+ }
+ keepalive_stats = ka_pmd_stats;
+ ovs_mutex_unlock(&mutex);
+}
+
static int
ka_init__(void)
{
diff --git a/lib/keepalive.h b/lib/keepalive.h
index 31ee34c..b18f6e0 100644
--- a/lib/keepalive.h
+++ b/lib/keepalive.h
@@ -100,6 +100,7 @@ uint32_t get_ka_interval(void);
int get_ka_init_status(void);
int ka_alloc_portstats(unsigned, int);
void ka_destroy_portstats(void);
+void get_ka_stats(void);
void dispatch_heartbeats(void);
#endif /* keepalive.h */
--
2.4.11
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev