Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/7293/?format=api
https://patches.dpdk.org/api/patches/7293/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1443603881-4700-2-git-send-email-remy.horton@intel.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1443603881-4700-2-git-send-email-remy.horton@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1443603881-4700-2-git-send-email-remy.horton@intel.com", "date": "2015-09-30T09:04:39", "name": "[dpdk-dev,v2,1/3] rte: add keep alive functionality", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "687a592ca40c5071d463aa87627b97a20e9b85ce", "submitter": { "id": 326, "url": "https://patches.dpdk.org/api/people/326/?format=api", "name": "Remy Horton", "email": "remy.horton@intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1443603881-4700-2-git-send-email-remy.horton@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/7293/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/7293/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 95BDC8D9E;\n\tWed, 30 Sep 2015 11:05:03 +0200 (CEST)", "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id 06F008D36\n\tfor <dev@dpdk.org>; Wed, 30 Sep 2015 11:05:00 +0200 (CEST)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga103.jf.intel.com with ESMTP; 30 Sep 2015 02:04:43 -0700", "from rhorton-mobl.ger.corp.intel.com (HELO localhost.ir.intel.com)\n\t([163.33.229.80])\n\tby fmsmga002.fm.intel.com with ESMTP; 30 Sep 2015 02:04:43 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.17,611,1437462000\"; d=\"scan'208\";a=\"816043127\"", "From": "Remy Horton <remy.horton@intel.com>", "To": "dev@dpdk.org", "Date": "Wed, 30 Sep 2015 10:04:39 +0100", "Message-Id": "<1443603881-4700-2-git-send-email-remy.horton@intel.com>", "X-Mailer": "git-send-email 1.9.3", "In-Reply-To": "<1443603881-4700-1-git-send-email-remy.horton@intel.com>", "References": "<1443603881-4700-1-git-send-email-remy.horton@intel.com>", "Subject": "[dpdk-dev] [PATCH v2 1/3] rte: add keep alive functionality", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Adds functions for detecting and reporting the live-ness of LCores,\nthe primary requirement of which is minimal overheads for the\ncore(s) being checked. Core failures are notified via an application\ndefined callback.\n\nSigned-off-by: Remy Horton <remy.horton@intel.com>\n---\n lib/librte_eal/bsdapp/eal/Makefile | 1 +\n lib/librte_eal/common/Makefile | 2 +-\n lib/librte_eal/common/include/rte_keepalive.h | 140 ++++++++++++++++++++++++++\n lib/librte_eal/common/rte_keepalive.c | 122 ++++++++++++++++++++++\n lib/librte_eal/linuxapp/eal/Makefile | 1 +\n 5 files changed, 265 insertions(+), 1 deletion(-)\n create mode 100644 lib/librte_eal/common/include/rte_keepalive.h\n create mode 100644 lib/librte_eal/common/rte_keepalive.c", "diff": "diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile\nindex a49dcec..65b293f 100644\n--- a/lib/librte_eal/bsdapp/eal/Makefile\n+++ b/lib/librte_eal/bsdapp/eal/Makefile\n@@ -80,6 +80,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_thread.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += rte_malloc.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += malloc_elem.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += malloc_heap.c\n+SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += rte_keepalive.c\n \n CFLAGS_eal.o := -D_GNU_SOURCE\n #CFLAGS_eal_thread.o := -D_GNU_SOURCE\ndiff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile\nindex 0c43d6a..7f1757a 100644\n--- a/lib/librte_eal/common/Makefile\n+++ b/lib/librte_eal/common/Makefile\n@@ -40,7 +40,7 @@ INC += rte_string_fns.h rte_version.h\n INC += rte_eal_memconfig.h rte_malloc_heap.h\n INC += rte_hexdump.h rte_devargs.h rte_dev.h\n INC += rte_pci_dev_feature_defs.h rte_pci_dev_features.h\n-INC += rte_malloc.h\n+INC += rte_malloc.h rte_keepalive.h\n \n ifeq ($(CONFIG_RTE_INSECURE_FUNCTION_WARNING),y)\n INC += rte_warnings.h\ndiff --git a/lib/librte_eal/common/include/rte_keepalive.h b/lib/librte_eal/common/include/rte_keepalive.h\nnew file mode 100644\nindex 0000000..d67bf4b\n--- /dev/null\n+++ b/lib/librte_eal/common/include/rte_keepalive.h\n@@ -0,0 +1,140 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright 2015 Intel Shannon Ltd. All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Intel Corporation nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+/**\n+ * @file keepalive.h\n+ * DPDK RTE LCore Keepalive Monitor.\n+ *\n+ **/\n+\n+#ifndef _KEEPALIVE_H_\n+#define _KEEPALIVE_H_\n+\n+#include <rte_memory.h>\n+\n+#ifndef RTE_KEEPALIVE_MAXCORES\n+/**\n+ * Number of cores to track.\n+ * @note Must be larger than the highest core id. */\n+#define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE\n+#endif\n+\n+\n+/**\n+ * Keepalive failure callback.\n+ *\n+ * Receives a data pointer passed to rte_keepalive_create() and the id of the\n+ * failed core.\n+ */\n+typedef void (*rte_keepalive_failure_callback_t)(\n+\tvoid *data,\n+\tconst int id_core);\n+\n+\n+/**\n+ * Keepalive state structure.\n+ * @internal\n+ */\n+struct rte_keepalive {\n+\t/** Core Liveness. */\n+\tuint32_t __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES];\n+\n+\t/** Last-seen-alive timestamps */\n+\tuint64_t last_alive[RTE_KEEPALIVE_MAXCORES];\n+\n+\t/**\n+\t * Cores to check.\n+\t * Indexed by core id, non-zero if the core should be checked.\n+\t */\n+\tuint8_t active_cores[RTE_KEEPALIVE_MAXCORES];\n+\n+\t/** Dead core handler. */\n+\trte_keepalive_failure_callback_t callback;\n+\n+\t/**\n+\t * Dead core handler app data.\n+\t * Pointer is passed to dead core handler.\n+\t */\n+\tvoid *callback_data;\n+\tuint64_t tsc_initial;\n+\tuint64_t tsc_mhz;\n+};\n+\n+\n+/**\n+ * Initialise keepalive sub-system.\n+ * @param callback\n+ * Function called upon detection of a dead core.\n+ * @param data\n+ * Data pointer to be passed to function callback.\n+ * @return\n+ * Keepalive structure success, NULL on failure.\n+ */\n+struct rte_keepalive *rte_keepalive_create(\n+\trte_keepalive_failure_callback_t callback,\n+\tvoid *data);\n+\n+\n+/**\n+ * @param *ptr_timer Triggering timer (unused)\n+ * @param *ptr_data Data pointer (keepalive structure)\n+ */\n+void rte_keepalive_dispatch_pings(__attribute__((unused)) void *ptr_timer,\n+\tvoid *ptr_data);\n+\n+\n+/**\n+ * Registers a core for keepalive checks.\n+ * @param *keepcfg\n+ * Keepalive structure pointer\n+ * @param id_core\n+ * ID number of core to register.\n+ */\n+void rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core);\n+\n+\n+/**\n+ * Per-core keepalive check.\n+ * @param *keepcfg\n+ * Keepalive structure pointer\n+ *\n+ * This function needs to be called from within the main process loop of\n+ * the LCore to be checked.\n+ */\n+static inline void\n+rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)\n+{\n+\tkeepcfg->state_flags[rte_lcore_id()] = 1;\n+}\n+\n+\n+#endif /* _KEEPALIVE_H_ */\ndiff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c\nnew file mode 100644\nindex 0000000..cbdd801\n--- /dev/null\n+++ b/lib/librte_eal/common/rte_keepalive.c\n@@ -0,0 +1,122 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright 2015 Intel Shannon Ltd. All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Intel Corporation nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <inttypes.h>\n+\n+#include <rte_cycles.h>\n+#include <rte_lcore.h>\n+#include <rte_keepalive.h>\n+\n+#ifdef KEEPALIVE_DEBUG_MSGS\n+static void\n+print_trace(const char *msg, struct rte_keepalive *keepcfg, int idx_core)\n+{\n+\tprintf(\"%sLast seen %\" PRId64 \"ms ago.\\n\",\n+\t\tmsg,\n+\t\t((rte_rdtsc() - keepcfg->last_alive[idx_core])*1000)\n+\t\t/ rte_get_tsc_hz()\n+\t );\n+}\n+#else\n+static void\n+print_trace(__attribute__((unused)) const char *msg,\n+\t__attribute__((unused)) struct rte_keepalive *keepcfg,\n+\t__attribute__((unused)) int idx_core)\n+{\n+}\n+#endif\n+\n+\n+\n+void\n+rte_keepalive_dispatch_pings(__attribute__((unused)) void *ptr_timer,\n+\tvoid *ptr_data)\n+{\n+\tstruct rte_keepalive *keepcfg = (struct rte_keepalive *)ptr_data;\n+\tint idx_core;\n+\n+\tfor (idx_core = 0; idx_core < RTE_KEEPALIVE_MAXCORES; idx_core++) {\n+\t\tif (keepcfg->active_cores[idx_core] == 0)\n+\t\t\tcontinue;\n+\t\tswitch (keepcfg->state_flags[idx_core]) {\n+\t\tcase 1: /* Alive */\n+\t\t\tkeepcfg->state_flags[idx_core] = 0;\n+\t\t\tkeepcfg->last_alive[idx_core] = rte_rdtsc();\n+\t\t\tbreak;\n+\t\tcase 0: /* MIA */\n+\t\t\tprint_trace(\"Core MIA. \", keepcfg, idx_core);\n+\t\t\tkeepcfg->state_flags[idx_core] = 2;\n+\t\t\tbreak;\n+\t\tcase 2: /* Dead */\n+\t\t\tkeepcfg->state_flags[idx_core] = 3;\n+\t\t\tprint_trace(\"Core died. \", keepcfg, idx_core);\n+\t\t\tif (keepcfg->callback)\n+\t\t\t\tkeepcfg->callback(\n+\t\t\t\t\tkeepcfg->callback_data,\n+\t\t\t\t\tidx_core\n+\t\t\t\t\t);\n+\t\t\tbreak;\n+\t\tcase 3: /* Buried */\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+}\n+\n+\n+struct rte_keepalive *\n+rte_keepalive_create(rte_keepalive_failure_callback_t callback,\n+\tvoid *data)\n+{\n+\tint idx_core;\n+\tstruct rte_keepalive *keepcfg;\n+\n+\tkeepcfg = malloc(sizeof(struct rte_keepalive));\n+\tif (keepcfg != NULL) {\n+\t\tfor (idx_core = 0; idx_core < RTE_KEEPALIVE_MAXCORES; idx_core++) {\n+\t\t\tkeepcfg->state_flags[idx_core] = 0;\n+\t\t\tkeepcfg->active_cores[idx_core] = 0;\n+\t\t}\n+\t\tkeepcfg->callback = callback;\n+\t\tkeepcfg->callback_data = data;\n+\t\tkeepcfg->tsc_initial = rte_rdtsc();\n+\t\tkeepcfg->tsc_mhz = rte_get_tsc_hz() / 1000;\n+\t}\n+\treturn keepcfg;\n+}\n+\n+\n+void\n+rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)\n+{\n+\tif (id_core < RTE_KEEPALIVE_MAXCORES)\n+\t\tkeepcfg->active_cores[id_core] = 1;\n+}\ndiff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile\nindex d62196e..05a44d7 100644\n--- a/lib/librte_eal/linuxapp/eal/Makefile\n+++ b/lib/librte_eal/linuxapp/eal/Makefile\n@@ -90,6 +90,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += eal_common_thread.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += rte_malloc.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += malloc_elem.c\n SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += malloc_heap.c\n+SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) += rte_keepalive.c\n \n CFLAGS_eal.o := -D_GNU_SOURCE\n CFLAGS_eal_interrupts.o := -D_GNU_SOURCE\n", "prefixes": [ "dpdk-dev", "v2", "1/3" ] }{ "id": 7293, "url": "