Skip to contentSkip to conversation

Keep-alive enhancements

PATCH Superseded Remy Horton 4 participants 24 messages Apr 29, 2016 – Jun 16, 2016

lore
Share & tools
lore
#0 lore raw

cover Keep-alive enhancements

This patchset adds enhancements to the keepalive core monitoring and reporting sub-system. The first is support for idled (sleeping and frequency-stepped) CPU cores, and the second is support for applications to be notified of active as well as faulted cores. The latter is to allow core state to be relayed to external (secondary) processes, which is demonstrated by changes to the l2fed-keepalive example.

Remy Horton (3):
eal: add new keepalive state & callback hook examples/l2fwd-keepalive: add IPC liveness reporting
doc: add keepalive enhancement documentation

 doc/guides/rel_notes/release_16_07.rst          |   5 +
 examples/Makefile                               |   1 +
 examples/l2fwd-keepalive/Makefile               |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile      |  51 ++++++++++
 examples/l2fwd-keepalive/ka-agent/main.c        | 128 +++++++++++++++++++++++
 examples/l2fwd-keepalive/main.c                 |  22 +++-
 examples/l2fwd-keepalive/shm.c                  | 130 ++++++++++++++++++++++++
 examples/l2fwd-keepalive/shm.h                  | 102 +++++++++++++++++++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   7 ++
 lib/librte_eal/common/include/rte_keepalive.h   |  40 ++++++++
 lib/librte_eal/common/rte_keepalive.c           |  35 ++++++-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   7 ++
 12 files changed, 526 insertions(+), 6 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h
Signature · 1 line
2.5.5
#1 lore raw

PATCH 1/3 eal: add new keepalive state & callback hook

---
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  7 +++++
 lib/librte_eal/common/include/rte_keepalive.h   | 40 +++++++++++++++++++++++++
 lib/librte_eal/common/rte_keepalive.c           | 35 ++++++++++++++++++++--
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  7 +++++
 4 files changed, 87 insertions(+), 2 deletions(-)
lib/librte_eal/bsdapp/eal/rte_eal_version.map +7 -0
index 58c2951..9a33441 100644
@@ -151,3 +151,10 @@ DPDK_16.04 {
 	rte_eal_primary_proc_alive;
 
 } DPDK_2.2;
+
+DPDK_16.7 {
+	global:
+
+	rte_keepalive_register_alive_callback;
+
+} DPDK_16.04;
lib/librte_eal/common/include/rte_keepalive.h +40 -0
index 10dac2e..3159730 100644
@@ -59,6 +59,16 @@ typedef void (*rte_keepalive_failure_callback_t)(
 	const int id_core);
 
 /**
+ * Keepalive 'alive' callback.
+ *
+ *  Receives a data pointer passed to rte_keepalive_register_alive_callback()
+ *  and the id of the failed core.
+ */
+typedef void (*rte_keepalive_alive_callback_t)(
+	void *data,
+	const int id_core);
+
+/**
  * Keepalive state structure.
  * @internal
  */
@@ -105,4 +115,34 @@ void rte_keepalive_register_core(struct rte_keepalive *keepcfg,
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg);
 
+/**
+ * Per-core sleep-time indication.
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ *
+ * This function needs to be called from within the main process loop of
+ * the LCore going to sleep.
+ */
+void
+rte_keepalive_mark_sleep(struct rte_keepalive *keepcfg);
+
+/**
+ * Registers a 'live core' callback.
+ *
+ * The complement of the 'dead core' callback. This is called when a
+ * core is known to be alive, and is intended for cases when an app
+ * needs to know 'liveness' beyond just knowing when a core has died.
+ *
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ * @param callback
+ *   Function called upon detection of a dead core.
+ * @param data
+ *   Data pointer to be passed to function callback.
+ */
+void
+rte_keepalive_register_alive_callback(struct rte_keepalive *keepcfg,
+	rte_keepalive_alive_callback_t callback,
+	void *data);
+
 #endif /* _KEEPALIVE_H_ */
lib/librte_eal/common/rte_keepalive.c +33 -2
index 23363ec..7af3558 100644
@@ -46,7 +46,8 @@ struct rte_keepalive {
 		ALIVE = 1,
 		MISSING = 0,
 		DEAD = 2,
-		GONE = 3
+		GONE = 3,
+		SLEEP = 4
 	} __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES];
 
 	/** Last-seen-alive timestamps */
@@ -68,6 +69,15 @@ struct rte_keepalive {
 	void *callback_data;
 	uint64_t tsc_initial;
 	uint64_t tsc_mhz;
+
+	/** Live core handler. */
+	rte_keepalive_failure_callback_t alive_callback;
+
+	/**
+	 * Live core handler app data.
+	 * Pointer is passed to live core handler.
+	 */
+	void *alive_callback_data;
 };
 
 static void
@@ -95,6 +105,11 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
 		case ALIVE: /* Alive */
 			keepcfg->state_flags[idx_core] = MISSING;
 			keepcfg->last_alive[idx_core] = rte_rdtsc();
+			if (keepcfg->alive_callback)
+				keepcfg->alive_callback(
+					keepcfg->alive_callback_data,
+					idx_core
+					);
 			break;
 		case MISSING: /* MIA */
 			print_trace("Core MIA. ", keepcfg, idx_core);
@@ -111,6 +126,8 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
 			break;
 		case GONE: /* Buried */
 			break;
+		case SLEEP: /* Idled core */
+			break;
 		}
 	}
 }
@@ -133,11 +150,19 @@ rte_keepalive_create(rte_keepalive_failure_callback_t callback,
 	return keepcfg;
 }
 
+void rte_keepalive_register_alive_callback(struct rte_keepalive *keepcfg,
+	rte_keepalive_failure_callback_t callback,
+	void *data)
+{
+	keepcfg->alive_callback = callback;
+	keepcfg->alive_callback_data = data;
+}
+
 void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
 	if (id_core < RTE_KEEPALIVE_MAXCORES) {
-		keepcfg->active_cores[id_core] = 1;
+		keepcfg->active_cores[id_core] = ALIVE;
 		keepcfg->last_alive[id_core] = rte_rdtsc();
 	}
 }
@@ -147,3 +172,9 @@ rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
 {
 	keepcfg->state_flags[rte_lcore_id()] = ALIVE;
 }
+
+void
+rte_keepalive_mark_sleep(struct rte_keepalive *keepcfg)
+{
+	keepcfg->state_flags[rte_lcore_id()] = SLEEP;
+}
lib/librte_eal/linuxapp/eal/rte_eal_version.map +7 -0
index 12503ef..862bc92 100644
@@ -154,3 +154,10 @@ DPDK_16.04 {
 	rte_eal_primary_proc_alive;
 
 } DPDK_2.2;
+
+DPDK_16.7 {
+	global:
+
+	rte_keepalive_register_alive_callback;
+
+} DPDK_16.04;
Signature · 1 line
2.5.5
#2 lore raw

PATCH 2/3 examples/l2fwd-keepalive: add IPC liveness reporting

In reply to Remy Horton
---
 examples/Makefile                          |   1 +
 examples/l2fwd-keepalive/Makefile          |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile |  51 +++++++++++
 examples/l2fwd-keepalive/ka-agent/main.c   | 128 ++++++++++++++++++++++++++++
 examples/l2fwd-keepalive/main.c            |  22 ++++-
 examples/l2fwd-keepalive/shm.c             | 130 +++++++++++++++++++++++++++++
 examples/l2fwd-keepalive/shm.h             | 102 ++++++++++++++++++++++
 7 files changed, 434 insertions(+), 4 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h
examples/Makefile +1 -0
index b28b30e..bd688b9 100644
@@ -64,6 +64,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += l2fwd-crypto
 DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += l2fwd-ivshmem
 DIRS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += l2fwd-jobstats
 DIRS-y += l2fwd-keepalive
+DIRS-y += l2fwd-keepalive/ka-agent
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += l3fwd
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += l3fwd-acl
 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
examples/l2fwd-keepalive/Makefile +2 -2
index 568edcb..3fcf513 100644
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l2fwd-keepalive
 
 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c shm.c
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
examples/l2fwd-keepalive/ka-agent/Makefile new file +51 -0

51 lines not on this page · raw message

examples/l2fwd-keepalive/ka-agent/main.c new file +128 -0

128 lines not on this page · raw message

examples/l2fwd-keepalive/main.c +20 -2
index 8da89aa..8ebf1fd 100644
@@ -72,6 +72,8 @@
 #include <rte_timer.h>
 #include <rte_keepalive.h>
 
+#include "shm.h"
+
 #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1
 
 #define NB_MBUF   8192
@@ -523,17 +525,25 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 }
 
 static void
-dead_core(__attribute__((unused)) void *ptr_data, const int id_core)
+dead_core(void *ptr_data, const int id_core)
 {
 	printf("Dead core %i - restarting..\n", id_core);
 	if (rte_eal_get_lcore_state(id_core) == FINISHED) {
 		rte_eal_wait_lcore(id_core);
 		rte_eal_remote_launch(l2fwd_launch_one_lcore, NULL, id_core);
+		rte_keepalive_shm_dead((struct rte_keepalive_shm *)ptr_data,
+			id_core);
 	} else {
 		printf("..false positive!\n");
 	}
 }
 
+static void
+alive_core(void *ptr_data, const int id_core)
+{
+	rte_keepalive_shm_alive((struct rte_keepalive_shm *)ptr_data, id_core);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -725,10 +735,18 @@ main(int argc, char **argv)
 	rte_timer_init(&stats_timer);
 
 	if (check_period > 0) {
+		struct rte_keepalive_shm *ka_shm;
+
+		ka_shm = rte_keepalive_shm_create();
+		if (ka_shm == NULL)
+			rte_exit(EXIT_FAILURE,
+				"rte_keepalive_shm_create() failed");
 		rte_global_keepalive_info =
-			rte_keepalive_create(&dead_core, NULL);
+			rte_keepalive_create(&dead_core, ka_shm);
 		if (rte_global_keepalive_info == NULL)
 			rte_exit(EXIT_FAILURE, "init_keep_alive() failed");
+		rte_keepalive_register_alive_callback(rte_global_keepalive_info,
+			alive_core, ka_shm);
 		rte_timer_init(&hb_timer);
 		if (rte_timer_reset(&hb_timer,
 				(check_period * rte_get_timer_hz()) / 1000,
examples/l2fwd-keepalive/shm.c new file +130 -0

130 lines not on this page · raw message

examples/l2fwd-keepalive/shm.h new file +102 -0

102 lines not on this page · raw message

Signature · 1 line
2.5.5
#3 lore raw

PATCH 3/3 doc: add keepalive enhancement documentation

In reply to Remy Horton
---
 doc/guides/rel_notes/release_16_07.rst | 5 +++++
 1 file changed, 5 insertions(+)
doc/guides/rel_notes/release_16_07.rst +5 -0
index 83c841b..7309877 100644
@@ -34,6 +34,11 @@ This section should contain new features added in this release. Sample format:
 
   Refer to the previous release notes for examples.
 
+* **Added keepalive enhancements.**
+
+   Adds support for reporting LCore liveness to secondary processes and
+   support for idled CPUs.
+
 
 Resolved Issues
 ---------------
Signature · 1 line
2.5.5
#4 lore raw

cover Keep-alive enhancements

In reply to Remy Horton

Shucong:
The validation for patches has been done.

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Horton, Remy
Sent: Friday, April 29, 2016 1:41 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH v1 0/3] Keep-alive enhancements

This patchset adds enhancements to the keepalive core monitoring and reporting sub-system. The first is support for idled (sleeping and
frequency-stepped) CPU cores, and the second is support for applications to be notified of active as well as faulted cores. The latter is to allow core state to be relayed to external (secondary) processes, which is demonstrated by changes to the l2fed-keepalive example.

Remy Horton (3):
eal: add new keepalive state & callback hook examples/l2fwd-keepalive: add IPC liveness reporting
doc: add keepalive enhancement documentation

 doc/guides/rel_notes/release_16_07.rst          |   5 +
 examples/Makefile                               |   1 +
 examples/l2fwd-keepalive/Makefile               |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile      |  51 ++++++++++
 examples/l2fwd-keepalive/ka-agent/main.c        | 128 +++++++++++++++++++++++
 examples/l2fwd-keepalive/main.c                 |  22 +++-
 examples/l2fwd-keepalive/shm.c                  | 130 ++++++++++++++++++++++++
 examples/l2fwd-keepalive/shm.h                  | 102 +++++++++++++++++++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   7 ++
 lib/librte_eal/common/include/rte_keepalive.h   |  40 ++++++++
 lib/librte_eal/common/rte_keepalive.c           |  35 ++++++-
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   7 ++
 12 files changed, 526 insertions(+), 6 deletions(-)  create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c  create mode 100644 examples/l2fwd-keepalive/shm.h

--
2.5.5

#5 lore raw

v2 cover Keep-alive enhancements

In reply to Remy Horton

This patchset adds enhancements to the keepalive core monitoring and reporting sub-system. The first is support for idled (sleeping and frequency-stepped) CPU cores, and the second is support for applications to be notified of active as well as faulted cores. The latter is to allow core state to be relayed to external (secondary) processes, which is demonstrated by changes to the l2fed-keepalive example.

--

v2 changes:
* Some date & typos fixups
* State enum made public and extended with new states
* Generalised 'alive' callback to all states
* Last-alive shows gone-to-sleep time for idle cores
* Removed some redundant sanity checks
* Last-alive time exposed to application
* #define'd semaphore timeout
* Agent checks for dead keepalive

Remy Horton (3):
eal: add new keepalive states & callback hooks examples/l2fwd-keepalive: add IPC liveness reporting
doc: add keepalive enhancement documentation

 doc/guides/rel_notes/release_16_07.rst          |   5 +
 examples/Makefile                               |   3 +-
 examples/l2fwd-keepalive/Makefile               |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile      |  51 ++++++++
 examples/l2fwd-keepalive/ka-agent/main.c        | 150 ++++++++++++++++++++++++
 examples/l2fwd-keepalive/main.c                 |  22 +++-
 examples/l2fwd-keepalive/shm.c                  | 128 ++++++++++++++++++++
 examples/l2fwd-keepalive/shm.h                  |  89 ++++++++++++++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   7 ++
 lib/librte_eal/common/include/rte_keepalive.h   |  55 ++++++++-
 lib/librte_eal/common/rte_keepalive.c           |  48 ++++++--
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   7 ++
 12 files changed, 556 insertions(+), 13 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h
Signature · 1 line
2.5.5
#6 lore raw

PATCH v2 1/3 eal: add new keepalive states & callback hooks

---
 examples/Makefile                               |  2 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  7 ++++
 lib/librte_eal/common/include/rte_keepalive.h   | 55 ++++++++++++++++++++++++-
 lib/librte_eal/common/rte_keepalive.c           | 48 +++++++++++++++++----
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  7 ++++
 5 files changed, 110 insertions(+), 9 deletions(-)
examples/Makefile +1 -1
index b28b30e..3bc635a 100644
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2014 6WIND S.A.
+#   Copyright(c) 2016 6WIND S.A.
 #
 #   Redistribution and use in source and binary forms, with or without
 #   modification, are permitted provided that the following conditions
lib/librte_eal/bsdapp/eal/rte_eal_version.map +7 -0
index 58c2951..9a33441 100644
@@ -151,3 +151,10 @@ DPDK_16.04 {
 	rte_eal_primary_proc_alive;
 
 } DPDK_2.2;
+
+DPDK_16.7 {
+	global:
+
+	rte_keepalive_register_alive_callback;
+
+} DPDK_16.04;
lib/librte_eal/common/include/rte_keepalive.h +54 -1

77 lines not on this page · raw message

lib/librte_eal/common/rte_keepalive.c +41 -7

86 lines not on this page · raw message

lib/librte_eal/linuxapp/eal/rte_eal_version.map +7 -0
index 12503ef..862bc92 100644
@@ -154,3 +154,10 @@ DPDK_16.04 {
 	rte_eal_primary_proc_alive;
 
 } DPDK_2.2;
+
+DPDK_16.7 {
+	global:
+
+	rte_keepalive_register_alive_callback;
+
+} DPDK_16.04;
Signature · 1 line
2.5.5
#7 lore raw

Re: [PATCH v2 1/3] eal: add new keepalive states & callback hooks

2016-05-18 10:30, Remy Horton:

The explanations are missing.
Probably you should split this patch.

Quoted 1 line

[...]

lib/librte_eal/common/include/rte_keepalive.h line 59

Quoted 9 lines
lib/librte_eal/common/include/rte_keepalive.h +9 -0
+enum rte_keepalive_state {
+	UNUSED = 0,
+	ALIVE = 1,
+	MISSING = 4,
+	DEAD = 2,
+	GONE = 3,
+	DOZING = 5,
+	SLEEP = 6
+};

Please use RTE_ prefix.

[...]

Quoted 6 lines

/**
+ * Keepalive relay callback.
+ *
+ * Receives a data pointer passed to rte_keepalive_register_relay_callback()
+ * and the id of the core for which state is to be forwarded.
+ */

Please document each parameter.

Quoted 6 lines
lib/librte_eal/common/include/rte_keepalive.h +6 -0
+typedef void (*rte_keepalive_relay_callback_t)(
+	void *data,
+	const int id_core,
+	enum rte_keepalive_state core_state,
+	uint64_t last_seen
+	);

[...]

Quoted 7 lines

+/**
+ * Per-core sleep-time indication.
+ * @param *keepcfg
+ * Keepalive structure pointer
+ *
+ * This function needs to be called from within the main process loop of
+ * the LCore going to sleep.

Why? Please add more comments.

Quoted 1 line

+ */

#8 lore raw

PATCH v2 2/3 examples/l2fwd-keepalive: add IPC liveness reporting

In reply to Remy Horton
---
 examples/Makefile                          |   1 +
 examples/l2fwd-keepalive/Makefile          |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile |  51 ++++++++++
 examples/l2fwd-keepalive/ka-agent/main.c   | 150 +++++++++++++++++++++++++++++
 examples/l2fwd-keepalive/main.c            |  22 ++++-
 examples/l2fwd-keepalive/shm.c             | 128 ++++++++++++++++++++++++
 examples/l2fwd-keepalive/shm.h             |  89 +++++++++++++++++
 7 files changed, 441 insertions(+), 4 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h
examples/Makefile +1 -0
index 3bc635a..f650d3e 100644
@@ -64,6 +64,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += l2fwd-crypto
 DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += l2fwd-ivshmem
 DIRS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += l2fwd-jobstats
 DIRS-y += l2fwd-keepalive
+DIRS-y += l2fwd-keepalive/ka-agent
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += l3fwd
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += l3fwd-acl
 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
examples/l2fwd-keepalive/Makefile +2 -2
index 568edcb..3fcf513 100644
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l2fwd-keepalive
 
 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c shm.c
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
examples/l2fwd-keepalive/ka-agent/Makefile new file +51 -0

51 lines not on this page · raw message

examples/l2fwd-keepalive/ka-agent/main.c new file +150 -0

150 lines not on this page · raw message

examples/l2fwd-keepalive/main.c +20 -2
index 8da89aa..a69cbb9 100644
@@ -72,6 +72,8 @@
 #include <rte_timer.h>
 #include <rte_keepalive.h>
 
+#include "shm.h"
+
 #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1
 
 #define NB_MBUF   8192
@@ -523,7 +525,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 }
 
 static void
-dead_core(__attribute__((unused)) void *ptr_data, const int id_core)
+dead_core(__rte_unused void *ptr_data, const int id_core)
 {
 	printf("Dead core %i - restarting..\n", id_core);
 	if (rte_eal_get_lcore_state(id_core) == FINISHED) {
@@ -534,6 +536,14 @@ dead_core(__attribute__((unused)) void *ptr_data, const int id_core)
 	}
 }
 
+static void
+relay_core_state(void *ptr_data, const int id_core,
+	const enum rte_keepalive_state core_state, uint64_t last_alive)
+{
+	rte_keepalive_relayed_state((struct rte_keepalive_shm *)ptr_data,
+		id_core, core_state, last_alive);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -725,10 +735,18 @@ main(int argc, char **argv)
 	rte_timer_init(&stats_timer);
 
 	if (check_period > 0) {
+		struct rte_keepalive_shm *ka_shm;
+
+		ka_shm = rte_keepalive_shm_create();
+		if (ka_shm == NULL)
+			rte_exit(EXIT_FAILURE,
+				"rte_keepalive_shm_create() failed");
 		rte_global_keepalive_info =
-			rte_keepalive_create(&dead_core, NULL);
+			rte_keepalive_create(&dead_core, ka_shm);
 		if (rte_global_keepalive_info == NULL)
 			rte_exit(EXIT_FAILURE, "init_keep_alive() failed");
+		rte_keepalive_register_relay_callback(rte_global_keepalive_info,
+			relay_core_state, ka_shm);
 		rte_timer_init(&hb_timer);
 		if (rte_timer_reset(&hb_timer,
 				(check_period * rte_get_timer_hz()) / 1000,
examples/l2fwd-keepalive/shm.c new file +128 -0

128 lines not on this page · raw message

examples/l2fwd-keepalive/shm.h new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.5.5
#9 lore raw

PATCH v2 3/3 doc: add keepalive enhancement documentation

In reply to Remy Horton
---
 doc/guides/rel_notes/release_16_07.rst | 5 +++++
 1 file changed, 5 insertions(+)
doc/guides/rel_notes/release_16_07.rst +5 -0
index f6d543c..bc269b0 100644
@@ -34,6 +34,11 @@ This section should contain new features added in this release. Sample format:
 
   Refer to the previous release notes for examples.
 
+* **Added keepalive enhancements.**
+
+   Adds support for reporting LCore liveness to secondary processes and
+   support for idled CPUs.
+
 
 Resolved Issues
 ---------------
Signature · 1 line
2.5.5
#10 lore raw

Re: [PATCH v2 3/3] doc: add keepalive enhancement documentation

2016-05-18 10:30, Remy Horton:

There is no explanation and it is totally normal, because this patch must be squashed with the code change.

Quoted 18 lines
---
 doc/guides/rel_notes/release_16_07.rst | 5 +++++
 1 file changed, 5 insertions(+)
doc/guides/rel_notes/release_16_07.rst +5 -0
index f6d543c..bc269b0 100644
@@ -34,6 +34,11 @@ This section should contain new features added in this release. Sample format:
 
   Refer to the previous release notes for examples.
 
+* **Added keepalive enhancements.**
+
+   Adds support for reporting LCore liveness to secondary processes and
+   support for idled CPUs.
+
#11 lore raw

Re: [PATCH v2 3/3] doc: add keepalive enhancement documentation

Quoted 9 lines · Thomas Monjalon

2016-05-18 10:30, Remy Horton:

There is no explanation and it is totally normal, because this patch must be squashed with the code change.

Quoted 4 lines
---
  doc/guides/rel_notes/release_16_07.rst | 5 +++++
  1 file changed, 5 insertions(+)

Done for v3. I tend to keep documentation changes in a seperate commit as from my experience they cause the most problems when rebasing.

..Remy

Acked-by on the v2 series
#12 lore raw
In reply to Remy Horton
Quoted 5 lines

From: dev [mailto:[email protected]] On Behalf Of Remy Horton
Sent: Wednesday, May 18, 2016 10:30 AM
To: [email protected]; Mcnamara, John <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/3] Keep-alive enhancements

Quoted 8 lines

This patchset adds enhancements to the keepalive core monitoring and reporting sub-system. The first is support for idled (sleeping and frequency-stepped) CPU cores, and the second is support for applications to be notified of active as well as faulted cores. The latter is to allow core state to be relayed to external (secondary) processes, which is demonstrated by changes to the l2fed-keepalive example.

--

#13 lore raw

v3 cover Keep-alive enhancements

In reply to Remy Horton

This patchset adds enhancements to the keepalive core monitoring and reporting sub-system. The first is support for idled (sleeping and frequency-stepped) CPU cores, and the second is support for applications to be notified of active as well as faulted cores. The latter is to allow core state to be relayed to external (secondary) processes, which is demonstrated by changes to the l2fed-keepalive example.

--

v3 changes
* Rebased to master
* Changed keepalive state enumerations to use RTE_ prefix
* Added missing parameter documentation
* Doc changes squashed

v2 changes:
* Some date & typos fixups
* State enum made public and extended with new states
* Generalised 'alive' callback to all states
* Last-alive shows gone-to-sleep time for idle cores
* Removed some redundant sanity checks
* Last-alive time exposed to application
* #define'd semaphore timeout
* Agent checks for dead keepalive

Remy Horton (3):
eal: export keepalive state enumerations
eal: add additional keepalive callbacks examples/l2fwd-keepalive: add IPC liveness reporting

 doc/guides/rel_notes/release_16_07.rst          |   6 +
 examples/Makefile                               |   3 +-
 examples/l2fwd-keepalive/Makefile               |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile      |  48 ++++++++
 examples/l2fwd-keepalive/ka-agent/main.c        | 150 ++++++++++++++++++++++++
 examples/l2fwd-keepalive/main.c                 |  22 +++-
 examples/l2fwd-keepalive/shm.c                  | 128 ++++++++++++++++++++
 examples/l2fwd-keepalive/shm.h                  |  89 ++++++++++++++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   1 +
 lib/librte_eal/common/include/rte_keepalive.h   |  63 +++++++++-
 lib/librte_eal/common/rte_keepalive.c           |  64 +++++++---
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   1 +
 12 files changed, 558 insertions(+), 21 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h
Signature · 1 line
2.5.5
#14 lore raw

PATCH v3 1/3 eal: export keepalive state enumerations

Changes the keepalive state from an anonymous enum to a declared one which is externally visible, so that keepalive enum values can be used by applications.

---
 lib/librte_eal/common/include/rte_keepalive.h | 12 +++++++++-
 lib/librte_eal/common/rte_keepalive.c         | 34 +++++++++++++++------------
 2 files changed, 30 insertions(+), 16 deletions(-)
lib/librte_eal/common/include/rte_keepalive.h +11 -1
index 10dac2e..2f856c3 100644
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -48,6 +48,16 @@
 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
 #endif
 
+enum rte_keepalive_state {
+	RTE_UNUSED = 0,
+	RTE_ALIVE = 1,
+	RTE_MISSING = 4,
+	RTE_DEAD = 2,
+	RTE_GONE = 3,
+	RTE_DOZING = 5,
+	RTE_SLEEP = 6
+};
+
 /**
  * Keepalive failure callback.
  *
lib/librte_eal/common/rte_keepalive.c +19 -15
index 23363ec..dd18e9f 100644
@@ -42,12 +42,8 @@
 
 struct rte_keepalive {
 	/** Core Liveness. */
-	enum rte_keepalive_state {
-		ALIVE = 1,
-		MISSING = 0,
-		DEAD = 2,
-		GONE = 3
-	} __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES];
+	enum rte_keepalive_state __rte_cache_aligned state_flags[
+		RTE_KEEPALIVE_MAXCORES];
 
 	/** Last-seen-alive timestamps */
 	uint64_t last_alive[RTE_KEEPALIVE_MAXCORES];
@@ -92,16 +88,18 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
 			continue;
 
 		switch (keepcfg->state_flags[idx_core]) {
-		case ALIVE: /* Alive */
-			keepcfg->state_flags[idx_core] = MISSING;
+		case RTE_UNUSED:
+			break;
+		case RTE_ALIVE: /* Alive */
+			keepcfg->state_flags[idx_core] = RTE_MISSING;
 			keepcfg->last_alive[idx_core] = rte_rdtsc();
 			break;
-		case MISSING: /* MIA */
+		case RTE_MISSING: /* MIA */
 			print_trace("Core MIA. ", keepcfg, idx_core);
-			keepcfg->state_flags[idx_core] = DEAD;
+			keepcfg->state_flags[idx_core] = RTE_DEAD;
 			break;
-		case DEAD: /* Dead */
-			keepcfg->state_flags[idx_core] = GONE;
+		case RTE_DEAD: /* Dead */
+			keepcfg->state_flags[idx_core] = RTE_GONE;
 			print_trace("Core died. ", keepcfg, idx_core);
 			if (keepcfg->callback)
 				keepcfg->callback(
@@ -109,7 +107,13 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
 					idx_core
 					);
 			break;
-		case GONE: /* Buried */
+		case RTE_GONE: /* Buried */
+			break;
+		case RTE_DOZING: /* Core going idle */
+			keepcfg->state_flags[idx_core] = RTE_SLEEP;
+			keepcfg->last_alive[idx_core] = rte_rdtsc();
+			break;
+		case RTE_SLEEP: /* Idled core */
 			break;
 		}
 	}
@@ -137,7 +141,7 @@ void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
 	if (id_core < RTE_KEEPALIVE_MAXCORES) {
-		keepcfg->active_cores[id_core] = 1;
+		keepcfg->active_cores[id_core] = RTE_ALIVE;
 		keepcfg->last_alive[id_core] = rte_rdtsc();
 	}
 }
@@ -145,5 +149,5 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
 {
-	keepcfg->state_flags[rte_lcore_id()] = ALIVE;
+	keepcfg->state_flags[rte_lcore_id()] = RTE_ALIVE;
 }
Signature · 1 line
2.5.5
#15 lore raw

Re: [PATCH v3 1/3] eal: export keepalive state enumerations

2016-06-15 10:17, Remy Horton:

lib/librte_eal/common/include/rte_keepalive.h line 59

Quoted 9 lines
lib/librte_eal/common/include/rte_keepalive.h +9 -0
+enum rte_keepalive_state {
+	RTE_UNUSED = 0,
+	RTE_ALIVE = 1,
+	RTE_MISSING = 4,
+	RTE_DEAD = 2,
+	RTE_GONE = 3,
+	RTE_DOZING = 5,
+	RTE_SLEEP = 6
+};

I'm concerned about the namespace here.
RTE_UNUSED and others have a chance to not be unique enough. Is it possible to have a longer prefix like RTE_KA_ or RTE_STATE_ or RTE_KA_STATE_?

#16 lore raw

Re: [PATCH v3 1/3] eal: export keepalive state enumerations

On 15/06/2016 10:27, Thomas Monjalon wrote:
[..]

Quoted 5 lines

I'm concerned about the namespace here.
RTE_UNUSED and others have a chance to not be unique enough. Is it possible to have a longer prefix like RTE_KA_ or RTE_STATE_ or RTE_KA_STATE_?

Good point - I'll go with RTE_KA_STATE_ as it is most descriptive.

..Remy

#17 lore raw

PATCH v3 2/3 eal: add additional keepalive callbacks

In reply to Remy Horton

Adds and documents new callbacks that allow transitions to core states other than dead to be reported to applications.

---
 doc/guides/rel_notes/release_16_07.rst          |  6 +++
 examples/Makefile                               |  2 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/include/rte_keepalive.h   | 51 +++++++++++++++++++++++++
 lib/librte_eal/common/rte_keepalive.c           | 30 +++++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 6 files changed, 90 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_16_07.rst +6 -0
index c0f6b02..df95321 100644
@@ -66,6 +66,12 @@ New Features
   * Enable RSS per network interface through the configuration file.
   * Streamline the CLI code.
 
+* **Added keepalive enhancements.**
+
+  Adds support for reporting of core states other than dead to
+  monitoring applications, enabling the support of broader liveness
+  reporting to external processes.
+
 
 Resolved Issues
 ---------------
examples/Makefile +1 -1
index b28b30e..3bc635a 100644
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2014 6WIND S.A.
+#   Copyright(c) 2016 6WIND S.A.
 #
 #   Redistribution and use in source and binary forms, with or without
 #   modification, are permitted provided that the following conditions
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
index f8c3dea..0fb1cf2 100644
@@ -156,5 +156,6 @@ DPDK_16.07 {
 	global:
 
 	pci_get_sysfs_path;
+	rte_keepalive_register_alive_callback;
 
 } DPDK_16.04;
lib/librte_eal/common/include/rte_keepalive.h +51 -0

67 lines not on this page · raw message

lib/librte_eal/common/rte_keepalive.c +30 -0
index dd18e9f..0aeee46 100644
@@ -64,6 +64,15 @@ struct rte_keepalive {
 	void *callback_data;
 	uint64_t tsc_initial;
 	uint64_t tsc_mhz;
+
+	/** Core state relay handler. */
+	rte_keepalive_relay_callback_t relay_callback;
+
+	/**
+	 * Core state relay handler app data.
+	 * Pointer is passed to live core handler.
+	 */
+	void *relay_callback_data;
 };
 
 static void
@@ -116,6 +125,13 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
 		case RTE_SLEEP: /* Idled core */
 			break;
 		}
+		if (keepcfg->relay_callback)
+			keepcfg->relay_callback(
+				keepcfg->relay_callback_data,
+				idx_core,
+				keepcfg->state_flags[idx_core],
+				keepcfg->last_alive[idx_core]
+				);
 	}
 }
 
@@ -137,6 +153,14 @@ rte_keepalive_create(rte_keepalive_failure_callback_t callback,
 	return keepcfg;
 }
 
+void rte_keepalive_register_relay_callback(struct rte_keepalive *keepcfg,
+	rte_keepalive_relay_callback_t callback,
+	void *data)
+{
+	keepcfg->relay_callback = callback;
+	keepcfg->relay_callback_data = data;
+}
+
 void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
@@ -151,3 +175,9 @@ rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
 {
 	keepcfg->state_flags[rte_lcore_id()] = RTE_ALIVE;
 }
+
+void
+rte_keepalive_mark_sleep(struct rte_keepalive *keepcfg)
+{
+	keepcfg->state_flags[rte_lcore_id()] = RTE_DOZING;
+}
lib/librte_eal/linuxapp/eal/rte_eal_version.map +1 -0
index 3d0ff93..34f44a7 100644
@@ -159,5 +159,6 @@ DPDK_16.07 {
 	global:
 
 	pci_get_sysfs_path;
+	rte_keepalive_register_alive_callback;
 
 } DPDK_16.04;
Signature · 1 line
2.5.5
#18 lore raw

PATCH v3 3/3 examples/l2fwd-keepalive: add IPC liveness reporting

In reply to Remy Horton

Changes the l2fwd keepalive example to show how the new keepalive enhancements can be used to relay core state to an external process.

---
 examples/Makefile                          |   1 +
 examples/l2fwd-keepalive/Makefile          |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile |  48 +++++++++
 examples/l2fwd-keepalive/ka-agent/main.c   | 150 +++++++++++++++++++++++++++++
 examples/l2fwd-keepalive/main.c            |  22 ++++-
 examples/l2fwd-keepalive/shm.c             | 128 ++++++++++++++++++++++++
 examples/l2fwd-keepalive/shm.h             |  89 +++++++++++++++++
 7 files changed, 438 insertions(+), 4 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h
examples/Makefile +1 -0
index 3bc635a..f650d3e 100644
@@ -64,6 +64,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += l2fwd-crypto
 DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += l2fwd-ivshmem
 DIRS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += l2fwd-jobstats
 DIRS-y += l2fwd-keepalive
+DIRS-y += l2fwd-keepalive/ka-agent
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += l3fwd
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += l3fwd-acl
 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
examples/l2fwd-keepalive/Makefile +2 -2
index 568edcb..3fcf513 100644
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l2fwd-keepalive
 
 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c shm.c
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
examples/l2fwd-keepalive/ka-agent/Makefile new file +48 -0

48 lines not on this page · raw message

examples/l2fwd-keepalive/ka-agent/main.c new file +150 -0

150 lines not on this page · raw message

examples/l2fwd-keepalive/main.c +20 -2
index 4a0d9b6..84a59eb 100644
@@ -72,6 +72,8 @@
 #include <rte_timer.h>
 #include <rte_keepalive.h>
 
+#include "shm.h"
+
 #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1
 
 #define NB_MBUF   8192
@@ -523,7 +525,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 }
 
 static void
-dead_core(__attribute__((unused)) void *ptr_data, const int id_core)
+dead_core(__rte_unused void *ptr_data, const int id_core)
 {
 	printf("Dead core %i - restarting..\n", id_core);
 	if (rte_eal_get_lcore_state(id_core) == FINISHED) {
@@ -534,6 +536,14 @@ dead_core(__attribute__((unused)) void *ptr_data, const int id_core)
 	}
 }
 
+static void
+relay_core_state(void *ptr_data, const int id_core,
+	const enum rte_keepalive_state core_state, uint64_t last_alive)
+{
+	rte_keepalive_relayed_state((struct rte_keepalive_shm *)ptr_data,
+		id_core, core_state, last_alive);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -722,10 +732,18 @@ main(int argc, char **argv)
 	rte_timer_init(&stats_timer);
 
 	if (check_period > 0) {
+		struct rte_keepalive_shm *ka_shm;
+
+		ka_shm = rte_keepalive_shm_create();
+		if (ka_shm == NULL)
+			rte_exit(EXIT_FAILURE,
+				"rte_keepalive_shm_create() failed");
 		rte_global_keepalive_info =
-			rte_keepalive_create(&dead_core, NULL);
+			rte_keepalive_create(&dead_core, ka_shm);
 		if (rte_global_keepalive_info == NULL)
 			rte_exit(EXIT_FAILURE, "init_keep_alive() failed");
+		rte_keepalive_register_relay_callback(rte_global_keepalive_info,
+			relay_core_state, ka_shm);
 		rte_timer_init(&hb_timer);
 		if (rte_timer_reset(&hb_timer,
 				(check_period * rte_get_timer_hz()) / 1000,
examples/l2fwd-keepalive/shm.c new file +128 -0

128 lines not on this page · raw message

examples/l2fwd-keepalive/shm.h new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.5.5
#19 lore raw

v4 cover Keep-alive enhancements

In reply to Remy Horton

This patchset adds enhancements to the keepalive core monitoring and reporting sub-system. The first is support for idled (sleeping and frequency-stepped) CPU cores, and the second is support for applications to be notified of active as well as faulted cores. The latter is to allow core state to be relayed to external (secondary) processes, which is demonstrated by changes to the l2fwd-keepalive example.

--

v4 changes
* Use RTE_KA_STATE_ prefix instead of RTE_ (namespace issues)

v3 changes
* Rebased to master
* Exposed keepalive state enumerations
* Changed keepalive state enumerations to use RTE_ prefix
* Added missing parameter documentation
* Doc changes squashed

v2 changes:
* Some date & typos fixups
* State enum made public and extended with new states
* Generalised 'alive' callback to all states
* Last-alive shows gone-to-sleep time for idle cores
* Removed some redundant sanity checks
* Last-alive time exposed to application
* #define'd semaphore timeout
* Agent checks for dead keepalive

Remy Horton (3):
eal: export keepalive state enumerations
eal: add additional keepalive callbacks examples/l2fwd-keepalive: add IPC liveness reporting

 doc/guides/rel_notes/release_16_07.rst          |   6 +
 examples/Makefile                               |   3 +-
 examples/l2fwd-keepalive/Makefile               |   5 +-
 examples/l2fwd-keepalive/ka-agent/Makefile      |  49 ++++++++
 examples/l2fwd-keepalive/ka-agent/main.c        | 150 ++++++++++++++++++++++++
 examples/l2fwd-keepalive/main.c                 |  22 +++-
 examples/l2fwd-keepalive/shm.c                  | 129 ++++++++++++++++++++
 examples/l2fwd-keepalive/shm.h                  |  89 ++++++++++++++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   1 +
 lib/librte_eal/common/include/rte_keepalive.h   |  63 +++++++++-
 lib/librte_eal/common/rte_keepalive.c           |  64 +++++++---
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   2 +
 12 files changed, 562 insertions(+), 21 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h
Signature · 1 line
2.5.5
#20 lore raw

PATCH v4 1/3 eal: export keepalive state enumerations

Changes the keepalive state from an anonymous enum to a declared one which is externally visible, so that keepalive enum values can be used by applications.

---
 lib/librte_eal/common/include/rte_keepalive.h | 12 +++++++++-
 lib/librte_eal/common/rte_keepalive.c         | 34 +++++++++++++++------------
 2 files changed, 30 insertions(+), 16 deletions(-)
lib/librte_eal/common/include/rte_keepalive.h +11 -1
index 10dac2e..d01a654 100644
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -48,6 +48,16 @@
 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
 #endif
 
+enum rte_keepalive_state {
+	RTE_KA_STATE_UNUSED = 0,
+	RTE_KA_STATE_ALIVE = 1,
+	RTE_KA_STATE_MISSING = 4,
+	RTE_KA_STATE_DEAD = 2,
+	RTE_KA_STATE_GONE = 3,
+	RTE_KA_STATE_DOZING = 5,
+	RTE_KA_STATE_SLEEP = 6
+};
+
 /**
  * Keepalive failure callback.
  *
lib/librte_eal/common/rte_keepalive.c +19 -15
index 23363ec..8b14370 100644
@@ -42,12 +42,8 @@
 
 struct rte_keepalive {
 	/** Core Liveness. */
-	enum rte_keepalive_state {
-		ALIVE = 1,
-		MISSING = 0,
-		DEAD = 2,
-		GONE = 3
-	} __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES];
+	enum rte_keepalive_state __rte_cache_aligned state_flags[
+		RTE_KEEPALIVE_MAXCORES];
 
 	/** Last-seen-alive timestamps */
 	uint64_t last_alive[RTE_KEEPALIVE_MAXCORES];
@@ -92,16 +88,18 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
 			continue;
 
 		switch (keepcfg->state_flags[idx_core]) {
-		case ALIVE: /* Alive */
-			keepcfg->state_flags[idx_core] = MISSING;
+		case RTE_KA_STATE_UNUSED:
+			break;
+		case RTE_KA_STATE_ALIVE: /* Alive */
+			keepcfg->state_flags[idx_core] = RTE_KA_STATE_MISSING;
 			keepcfg->last_alive[idx_core] = rte_rdtsc();
 			break;
-		case MISSING: /* MIA */
+		case RTE_KA_STATE_MISSING: /* MIA */
 			print_trace("Core MIA. ", keepcfg, idx_core);
-			keepcfg->state_flags[idx_core] = DEAD;
+			keepcfg->state_flags[idx_core] = RTE_KA_STATE_DEAD;
 			break;
-		case DEAD: /* Dead */
-			keepcfg->state_flags[idx_core] = GONE;
+		case RTE_KA_STATE_DEAD: /* Dead */
+			keepcfg->state_flags[idx_core] = RTE_KA_STATE_GONE;
 			print_trace("Core died. ", keepcfg, idx_core);
 			if (keepcfg->callback)
 				keepcfg->callback(
@@ -109,7 +107,13 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
 					idx_core
 					);
 			break;
-		case GONE: /* Buried */
+		case RTE_KA_STATE_GONE: /* Buried */
+			break;
+		case RTE_KA_STATE_DOZING: /* Core going idle */
+			keepcfg->state_flags[idx_core] = RTE_KA_STATE_SLEEP;
+			keepcfg->last_alive[idx_core] = rte_rdtsc();
+			break;
+		case RTE_KA_STATE_SLEEP: /* Idled core */
 			break;
 		}
 	}
@@ -137,7 +141,7 @@ void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
 	if (id_core < RTE_KEEPALIVE_MAXCORES) {
-		keepcfg->active_cores[id_core] = 1;
+		keepcfg->active_cores[id_core] = RTE_KA_STATE_ALIVE;
 		keepcfg->last_alive[id_core] = rte_rdtsc();
 	}
 }
@@ -145,5 +149,5 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
 {
-	keepcfg->state_flags[rte_lcore_id()] = ALIVE;
+	keepcfg->state_flags[rte_lcore_id()] = RTE_KA_STATE_ALIVE;
 }
Signature · 1 line
2.5.5
#21 lore raw

PATCH v4 2/3 eal: add additional keepalive callbacks

In reply to Remy Horton

Adds and documents new callbacks that allow transitions to core states other than dead to be reported to applications.

---
 doc/guides/rel_notes/release_16_07.rst          |  6 +++
 examples/Makefile                               |  2 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/include/rte_keepalive.h   | 51 +++++++++++++++++++++++++
 lib/librte_eal/common/rte_keepalive.c           | 30 +++++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  2 +
 6 files changed, 91 insertions(+), 1 deletion(-)
doc/guides/rel_notes/release_16_07.rst +6 -0
index c0f6b02..df95321 100644
@@ -66,6 +66,12 @@ New Features
   * Enable RSS per network interface through the configuration file.
   * Streamline the CLI code.
 
+* **Added keepalive enhancements.**
+
+  Adds support for reporting of core states other than dead to
+  monitoring applications, enabling the support of broader liveness
+  reporting to external processes.
+
 
 Resolved Issues
 ---------------
examples/Makefile +1 -1
index b28b30e..3bc635a 100644
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2014 6WIND S.A.
+#   Copyright(c) 2016 6WIND S.A.
 #
 #   Redistribution and use in source and binary forms, with or without
 #   modification, are permitted provided that the following conditions
lib/librte_eal/bsdapp/eal/rte_eal_version.map +1 -0
index f8c3dea..0fb1cf2 100644
@@ -156,5 +156,6 @@ DPDK_16.07 {
 	global:
 
 	pci_get_sysfs_path;
+	rte_keepalive_register_alive_callback;
 
 } DPDK_16.04;
lib/librte_eal/common/include/rte_keepalive.h +51 -0

67 lines not on this page · raw message

lib/librte_eal/common/rte_keepalive.c +30 -0
index 8b14370..9765d1b 100644
@@ -64,6 +64,15 @@ struct rte_keepalive {
 	void *callback_data;
 	uint64_t tsc_initial;
 	uint64_t tsc_mhz;
+
+	/** Core state relay handler. */
+	rte_keepalive_relay_callback_t relay_callback;
+
+	/**
+	 * Core state relay handler app data.
+	 * Pointer is passed to live core handler.
+	 */
+	void *relay_callback_data;
 };
 
 static void
@@ -116,6 +125,13 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
 		case RTE_KA_STATE_SLEEP: /* Idled core */
 			break;
 		}
+		if (keepcfg->relay_callback)
+			keepcfg->relay_callback(
+				keepcfg->relay_callback_data,
+				idx_core,
+				keepcfg->state_flags[idx_core],
+				keepcfg->last_alive[idx_core]
+				);
 	}
 }
 
@@ -137,6 +153,14 @@ rte_keepalive_create(rte_keepalive_failure_callback_t callback,
 	return keepcfg;
 }
 
+void rte_keepalive_register_relay_callback(struct rte_keepalive *keepcfg,
+	rte_keepalive_relay_callback_t callback,
+	void *data)
+{
+	keepcfg->relay_callback = callback;
+	keepcfg->relay_callback_data = data;
+}
+
 void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
@@ -151,3 +175,9 @@ rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
 {
 	keepcfg->state_flags[rte_lcore_id()] = RTE_KA_STATE_ALIVE;
 }
+
+void
+rte_keepalive_mark_sleep(struct rte_keepalive *keepcfg)
+{
+	keepcfg->state_flags[rte_lcore_id()] = RTE_KA_STATE_DOZING;
+}
lib/librte_eal/linuxapp/eal/rte_eal_version.map +2 -0
index 3d0ff93..cacf9e1 100644
@@ -159,5 +159,7 @@ DPDK_16.07 {
 	global:
 
 	pci_get_sysfs_path;
+	rte_keepalive_register_alive_callback;
+	rte_keepalive_register_relay_callback;
 
 } DPDK_16.04;
Signature · 1 line
2.5.5
#22 lore raw

PATCH v4 3/3 examples/l2fwd-keepalive: add IPC liveness reporting

In reply to Remy Horton

Changes the l2fwd keepalive example to show how the new keepalive enhancements can be used to relay core state to an external process.

---
 examples/Makefile                          |   1 +
 examples/l2fwd-keepalive/Makefile          |   5 +-
 examples/l2fwd-keepalive/ka-agent/Makefile |  49 ++++++++++
 examples/l2fwd-keepalive/ka-agent/main.c   | 150 +++++++++++++++++++++++++++++
 examples/l2fwd-keepalive/main.c            |  22 ++++-
 examples/l2fwd-keepalive/shm.c             | 129 +++++++++++++++++++++++++
 examples/l2fwd-keepalive/shm.h             |  89 +++++++++++++++++
 7 files changed, 441 insertions(+), 4 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h
examples/Makefile +1 -0
index 3bc635a..f650d3e 100644
@@ -64,6 +64,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += l2fwd-crypto
 DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += l2fwd-ivshmem
 DIRS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += l2fwd-jobstats
 DIRS-y += l2fwd-keepalive
+DIRS-y += l2fwd-keepalive/ka-agent
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += l3fwd
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += l3fwd-acl
 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
examples/l2fwd-keepalive/Makefile +3 -2
index 568edcb..ca45a79 100644
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -42,9 +42,10 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l2fwd-keepalive
 
 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c shm.c
 
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+LDFLAGS += -lrt
 
 include $(RTE_SDK)/mk/rte.extapp.mk
examples/l2fwd-keepalive/ka-agent/Makefile new file +49 -0

49 lines not on this page · raw message

examples/l2fwd-keepalive/ka-agent/main.c new file +150 -0

150 lines not on this page · raw message

examples/l2fwd-keepalive/main.c +20 -2
index 4a0d9b6..84a59eb 100644
@@ -72,6 +72,8 @@
 #include <rte_timer.h>
 #include <rte_keepalive.h>
 
+#include "shm.h"
+
 #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1
 
 #define NB_MBUF   8192
@@ -523,7 +525,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
 }
 
 static void
-dead_core(__attribute__((unused)) void *ptr_data, const int id_core)
+dead_core(__rte_unused void *ptr_data, const int id_core)
 {
 	printf("Dead core %i - restarting..\n", id_core);
 	if (rte_eal_get_lcore_state(id_core) == FINISHED) {
@@ -534,6 +536,14 @@ dead_core(__attribute__((unused)) void *ptr_data, const int id_core)
 	}
 }
 
+static void
+relay_core_state(void *ptr_data, const int id_core,
+	const enum rte_keepalive_state core_state, uint64_t last_alive)
+{
+	rte_keepalive_relayed_state((struct rte_keepalive_shm *)ptr_data,
+		id_core, core_state, last_alive);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -722,10 +732,18 @@ main(int argc, char **argv)
 	rte_timer_init(&stats_timer);
 
 	if (check_period > 0) {
+		struct rte_keepalive_shm *ka_shm;
+
+		ka_shm = rte_keepalive_shm_create();
+		if (ka_shm == NULL)
+			rte_exit(EXIT_FAILURE,
+				"rte_keepalive_shm_create() failed");
 		rte_global_keepalive_info =
-			rte_keepalive_create(&dead_core, NULL);
+			rte_keepalive_create(&dead_core, ka_shm);
 		if (rte_global_keepalive_info == NULL)
 			rte_exit(EXIT_FAILURE, "init_keep_alive() failed");
+		rte_keepalive_register_relay_callback(rte_global_keepalive_info,
+			relay_core_state, ka_shm);
 		rte_timer_init(&hb_timer);
 		if (rte_timer_reset(&hb_timer,
 				(check_period * rte_get_timer_hz()) / 1000,
examples/l2fwd-keepalive/shm.c new file +129 -0

129 lines not on this page · raw message

examples/l2fwd-keepalive/shm.h new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.5.5
#23 lore raw
In reply to Remy Horton
Quoted 4 lines

Remy Horton (3):
eal: export keepalive state enumerations
eal: add additional keepalive callbacks examples/l2fwd-keepalive: add IPC liveness reporting

Applied, thanks

Just a last comment: the agent in the example should not appear in examples/Makefile.