Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/54356/?format=api
https://patches.dpdk.org/api/patches/54356/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1559661921-8821-1-git-send-email-arnon@qwilt.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": "<1559661921-8821-1-git-send-email-arnon@qwilt.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1559661921-8821-1-git-send-email-arnon@qwilt.com", "date": "2019-06-04T15:25:21", "name": "[v4] eal: remove non-thread panic calls from init sequence", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "e3ddb67fdf9023d74a7b887d1d15970c48a0774d", "submitter": { "id": 986, "url": "https://patches.dpdk.org/api/people/986/?format=api", "name": "Arnon Warshavsky", "email": "arnon@qwilt.com" }, "delegate": { "id": 1, "url": "https://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1559661921-8821-1-git-send-email-arnon@qwilt.com/mbox/", "series": [ { "id": 4891, "url": "https://patches.dpdk.org/api/series/4891/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=4891", "date": "2019-06-04T15:25:21", "name": "[v4] eal: remove non-thread panic calls from init sequence", "version": 4, "mbox": "https://patches.dpdk.org/series/4891/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/54356/comments/", "check": "fail", "checks": "https://patches.dpdk.org/api/patches/54356/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id BC6F11BB86;\n\tTue, 4 Jun 2019 17:25:28 +0200 (CEST)", "from mta.qwilt.com (mta.qwilt.com [52.9.191.255])\n\tby dpdk.org (Postfix) with ESMTP id 82ED41BAA8\n\tfor <dev@dpdk.org>; Tue, 4 Jun 2019 17:25:27 +0200 (CEST)", "from localhost (localhost [127.0.0.1])\n\tby mta.qwilt.com (Postfix) with ESMTP id 710AA82546D;\n\tTue, 4 Jun 2019 15:25:26 +0000 (UTC)", "from mta.qwilt.com ([127.0.0.1])\n\tby localhost (mta.qwilt.com [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id as6TyVvnwl65; Tue, 4 Jun 2019 15:25:26 +0000 (UTC)", "from rd01.it.qwilt.com.qwilt.com (backup [80.179.204.39])\n\tby mta.qwilt.com (Postfix) with ESMTPSA id E540782546C;\n\tTue, 4 Jun 2019 15:25:24 +0000 (UTC)" ], "X-Virus-Scanned": "amavisd-new at qwilt.com", "From": "Arnon Warshavsky <arnon@qwilt.com>", "To": "dev@dpdk.org, thomas@monjalon.net, david.marchand@redhat.com,\n\tstephen@networkplumber.org", "Cc": "arnonw@qwilt.com,\n\tArnon Warshavsky <arnon@qwilt.com>", "Date": "Tue, 4 Jun 2019 18:25:21 +0300", "Message-Id": "<1559661921-8821-1-git-send-email-arnon@qwilt.com>", "X-Mailer": "git-send-email 1.8.3.1", "In-Reply-To": "<1559546368-32263-1-git-send-email-arnon@qwilt.com>", "References": "<1559546368-32263-1-git-send-email-arnon@qwilt.com>", "Subject": "[dpdk-dev] [PATCH v4] eal: remove non-thread panic calls from init\n\tsequence", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "This patch changes some void functions to return a value,\nso that the init sequence may tear down orderly\ninstead of calling panic.\n\nSigned-off-by: Arnon Warshavsky <arnon@qwilt.com>\n---\n\nThe calls for launching core messaging threads were left in tact\nin all 3 eal implementations.\nThis should be addressed in a different patchset.\nThere are still cases where the PMDs or message threads\nmay call panic with no context for the user.\nFor these I will submit a patch suggesting a callback registration,\nallowing the user to register a context to be called\nin case of a panic that takes place outside the init sequence.\n\n-v2 fix freebsd compilation\n-v3 fix freebsd compilation, haste from the devil\n-v4 fix comments by David\n\n lib/librte_eal/freebsd/eal/eal.c | 59 ++++++++++++++++++--------\n lib/librte_eal/linux/eal/eal.c | 91 +++++++++++++++++++++++++++-------------\n 2 files changed, 103 insertions(+), 47 deletions(-)", "diff": "diff --git a/lib/librte_eal/freebsd/eal/eal.c b/lib/librte_eal/freebsd/eal/eal.c\nindex c6ac902..4b4db3b 100644\n--- a/lib/librte_eal/freebsd/eal/eal.c\n+++ b/lib/librte_eal/freebsd/eal/eal.c\n@@ -215,7 +215,7 @@ enum rte_iova_mode\n * We also don't lock the whole file, so that in future we can use read-locks\n * on other parts, e.g. memzones, to detect if there are running secondary\n * processes. */\n-static void\n+static int\n rte_eal_config_create(void)\n {\n \tvoid *rte_mem_cfg_addr;\n@@ -224,60 +224,79 @@ enum rte_iova_mode\n \tconst char *pathname = eal_runtime_config_path();\n \n \tif (internal_config.no_shconf)\n-\t\treturn;\n+\t\treturn 0;\n \n \tif (mem_cfg_fd < 0){\n \t\tmem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0600);\n-\t\tif (mem_cfg_fd < 0)\n-\t\t\trte_panic(\"Cannot open '%s' for rte_mem_config\\n\", pathname);\n+\t\tif (mem_cfg_fd < 0) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Cannot open '%s' for rte_mem_config\\n\",\n+\t\t\t\tpathname);\n+\t\t\treturn -1;\n+\t\t}\n \t}\n \n \tretval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));\n \tif (retval < 0){\n \t\tclose(mem_cfg_fd);\n-\t\trte_panic(\"Cannot resize '%s' for rte_mem_config\\n\", pathname);\n+\t\tmem_cfg_id = -1;\n+\t\tRTE_LOG(ERR, EAL, \"Cannot resize '%s' for rte_mem_config\\n\",\n+\t\t\tpathname);\n+\t\treturn -1;\n \t}\n \n \tretval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);\n \tif (retval < 0){\n \t\tclose(mem_cfg_fd);\n-\t\trte_exit(EXIT_FAILURE, \"Cannot create lock on '%s'. Is another primary \"\n+\t\tmem_cfg_fd = -1;\n+\t\tRTE_LOG(ERR, EAL, \"Cannot create lock on '%s'. Is another primary \"\n \t\t\t\t\"process running?\\n\", pathname);\n+\t\treturn -1;\n \t}\n \n \trte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),\n \t\t\t\tPROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);\n \n \tif (rte_mem_cfg_addr == MAP_FAILED){\n-\t\trte_panic(\"Cannot mmap memory for rte_config\\n\");\n+\t\tRTE_LOG(ERR, EAL, \"Cannot mmap memory for rte_config\\n\");\n+\t\treturn -1;\n \t}\n \tmemcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));\n \trte_config.mem_config = rte_mem_cfg_addr;\n+\n+\treturn 0;\n }\n \n /* attach to an existing shared memory config */\n-static void\n+static int\n rte_eal_config_attach(void)\n {\n \tvoid *rte_mem_cfg_addr;\n \tconst char *pathname = eal_runtime_config_path();\n \n \tif (internal_config.no_shconf)\n-\t\treturn;\n+\t\treturn 0;\n \n \tif (mem_cfg_fd < 0){\n \t\tmem_cfg_fd = open(pathname, O_RDWR);\n-\t\tif (mem_cfg_fd < 0)\n-\t\t\trte_panic(\"Cannot open '%s' for rte_mem_config\\n\", pathname);\n+\t\tif (mem_cfg_fd < 0) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Cannot open '%s' for rte_mem_config\\n\",\n+\t\t\t\tpathname);\n+\t\t\treturn -1;\n+\t\t}\n \t}\n \n \trte_mem_cfg_addr = mmap(NULL, sizeof(*rte_config.mem_config),\n \t\t\t\tPROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);\n \tclose(mem_cfg_fd);\n-\tif (rte_mem_cfg_addr == MAP_FAILED)\n-\t\trte_panic(\"Cannot mmap memory for rte_config\\n\");\n+\tif (rte_mem_cfg_addr == MAP_FAILED) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot mmap memory for rte_config! error %i (%s)\\n\",\n+\t\t\terrno, strerror(errno));\n+\t\treturn -1;\n+\t}\n \n \trte_config.mem_config = rte_mem_cfg_addr;\n+\n+\treturn 0;\n }\n \n /* Detect if we are a primary or a secondary process */\n@@ -306,23 +325,29 @@ enum rte_proc_type_t\n }\n \n /* Sets up rte_config structure with the pointer to shared memory config.*/\n-static void\n+static int\n rte_config_init(void)\n {\n \trte_config.process_type = internal_config.process_type;\n \n \tswitch (rte_config.process_type){\n \tcase RTE_PROC_PRIMARY:\n-\t\trte_eal_config_create();\n+\t\tif (rte_eal_config_create() < 0)\n+\t\t\treturn -1;\n \t\tbreak;\n \tcase RTE_PROC_SECONDARY:\n-\t\trte_eal_config_attach();\n+\t\tif (rte_eal_config_attach() < 0)\n+\t\t\treturn -1;\n \t\trte_eal_mcfg_wait_complete(rte_config.mem_config);\n \t\tbreak;\n \tcase RTE_PROC_AUTO:\n \tcase RTE_PROC_INVALID:\n-\t\trte_panic(\"Invalid process type\\n\");\n+\t\tRTE_LOG(ERR, EAL, \"Invalid process type %d\\n\",\n+\t\t\trte_config.process_type);\n+\t\treturn -1;\n \t}\n+\n+\treturn 0;\n }\n \n /* display usage */\ndiff --git a/lib/librte_eal/linux/eal/eal.c b/lib/librte_eal/linux/eal/eal.c\nindex 1613996..1ec264f 100644\n--- a/lib/librte_eal/linux/eal/eal.c\n+++ b/lib/librte_eal/linux/eal/eal.c\n@@ -300,7 +300,7 @@ enum rte_iova_mode\n * We also don't lock the whole file, so that in future we can use read-locks\n * on other parts, e.g. memzones, to detect if there are running secondary\n * processes. */\n-static void\n+static int\n rte_eal_config_create(void)\n {\n \tvoid *rte_mem_cfg_addr;\n@@ -309,7 +309,7 @@ enum rte_iova_mode\n \tconst char *pathname = eal_runtime_config_path();\n \n \tif (internal_config.no_shconf)\n-\t\treturn;\n+\t\treturn 0;\n \n \t/* map the config before hugepage address so that we don't waste a page */\n \tif (internal_config.base_virtaddr != 0)\n@@ -321,28 +321,37 @@ enum rte_iova_mode\n \n \tif (mem_cfg_fd < 0){\n \t\tmem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0600);\n-\t\tif (mem_cfg_fd < 0)\n-\t\t\trte_panic(\"Cannot open '%s' for rte_mem_config\\n\", pathname);\n+\t\tif (mem_cfg_fd < 0) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Cannot open '%s' for rte_mem_config\\n\",\n+\t\t\t\tpathname);\n+\t\t\treturn -1;\n+\t\t}\n \t}\n \n \tretval = ftruncate(mem_cfg_fd, sizeof(*rte_config.mem_config));\n \tif (retval < 0){\n \t\tclose(mem_cfg_fd);\n-\t\trte_panic(\"Cannot resize '%s' for rte_mem_config\\n\", pathname);\n+\t\tmem_cfg_fd = -1;\n+\t\tRTE_LOG(ERR, EAL, \"Cannot resize '%s' for rte_mem_config\\n\",\n+\t\t\tpathname);\n+\t\treturn -1;\n \t}\n \n \tretval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);\n \tif (retval < 0){\n \t\tclose(mem_cfg_fd);\n-\t\trte_exit(EXIT_FAILURE, \"Cannot create lock on '%s'. Is another primary \"\n-\t\t\t\t\"process running?\\n\", pathname);\n+\t\tmem_cfg_fd = -1;\n+\t\tRTE_LOG(ERR, EAL, \"Cannot create lock on '%s'. Is another primary \"\n+\t\t\t\"process running?\\n\", pathname);\n+\t\treturn -1;\n \t}\n \n \trte_mem_cfg_addr = mmap(rte_mem_cfg_addr, sizeof(*rte_config.mem_config),\n \t\t\t\tPROT_READ | PROT_WRITE, MAP_SHARED, mem_cfg_fd, 0);\n \n \tif (rte_mem_cfg_addr == MAP_FAILED){\n-\t\trte_panic(\"Cannot mmap memory for rte_config\\n\");\n+\t\tRTE_LOG(ERR, EAL, \"Cannot mmap memory for rte_config\\n\");\n+\t\treturn -1;\n \t}\n \tmemcpy(rte_mem_cfg_addr, &early_mem_config, sizeof(early_mem_config));\n \trte_config.mem_config = rte_mem_cfg_addr;\n@@ -353,10 +362,11 @@ enum rte_iova_mode\n \n \trte_config.mem_config->dma_maskbits = 0;\n \n+\treturn 0;\n }\n \n /* attach to an existing shared memory config */\n-static void\n+static int\n rte_eal_config_attach(void)\n {\n \tstruct rte_mem_config *mem_config;\n@@ -364,33 +374,40 @@ enum rte_iova_mode\n \tconst char *pathname = eal_runtime_config_path();\n \n \tif (internal_config.no_shconf)\n-\t\treturn;\n+\t\treturn 0;\n \n \tif (mem_cfg_fd < 0){\n \t\tmem_cfg_fd = open(pathname, O_RDWR);\n-\t\tif (mem_cfg_fd < 0)\n-\t\t\trte_panic(\"Cannot open '%s' for rte_mem_config\\n\", pathname);\n+\t\tif (mem_cfg_fd < 0) {\n+\t\t\tRTE_LOG(ERR, EAL, \"Cannot open '%s' for rte_mem_config\\n\",\n+\t\t\t\tpathname);\n+\t\t\treturn -1;\n+\t\t}\n \t}\n \n \t/* map it as read-only first */\n \tmem_config = (struct rte_mem_config *) mmap(NULL, sizeof(*mem_config),\n \t\t\tPROT_READ, MAP_SHARED, mem_cfg_fd, 0);\n-\tif (mem_config == MAP_FAILED)\n-\t\trte_panic(\"Cannot mmap memory for rte_config! error %i (%s)\\n\",\n-\t\t\t errno, strerror(errno));\n+\tif (mem_config == MAP_FAILED) {\n+\t\tRTE_LOG(ERR, EAL, \"Cannot mmap memory for rte_config! error %i (%s)\\n\",\n+\t\t\terrno, strerror(errno));\n+\t\treturn -1;\n+\t}\n \n \trte_config.mem_config = mem_config;\n+\n+\treturn 0;\n }\n \n /* reattach the shared config at exact memory location primary process has it */\n-static void\n+static int\n rte_eal_config_reattach(void)\n {\n \tstruct rte_mem_config *mem_config;\n \tvoid *rte_mem_cfg_addr;\n \n \tif (internal_config.no_shconf)\n-\t\treturn;\n+\t\treturn 0;\n \n \t/* save the address primary process has mapped shared config to */\n \trte_mem_cfg_addr = (void *) (uintptr_t) rte_config.mem_config->mem_cfg_addr;\n@@ -403,18 +420,22 @@ enum rte_iova_mode\n \t\t\tsizeof(*mem_config), PROT_READ | PROT_WRITE, MAP_SHARED,\n \t\t\tmem_cfg_fd, 0);\n \tif (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) {\n-\t\tif (mem_config != MAP_FAILED)\n+\t\tif (mem_config != MAP_FAILED) {\n \t\t\t/* errno is stale, don't use */\n-\t\t\trte_panic(\"Cannot mmap memory for rte_config at [%p], got [%p]\"\n-\t\t\t\t \" - please use '--base-virtaddr' option\\n\",\n-\t\t\t\t rte_mem_cfg_addr, mem_config);\n-\t\telse\n-\t\t\trte_panic(\"Cannot mmap memory for rte_config! error %i (%s)\\n\",\n-\t\t\t\t errno, strerror(errno));\n+\t\t\tRTE_LOG(ERR, EAL, \"Cannot mmap memory for rte_config at [%p], got [%p]\"\n+\t\t\t\t\" - please use '--base-virtaddr' option\\n\",\n+\t\t\t\trte_mem_cfg_addr, mem_config);\n+\t\t\treturn -1;\n+\t\t}\n+\t\tRTE_LOG(ERR, EAL, \"Cannot mmap memory for rte_config! error %i (%s)\\n\",\n+\t\t\terrno, strerror(errno));\n+\t\treturn -1;\n \t}\n \tclose(mem_cfg_fd);\n \n \trte_config.mem_config = mem_config;\n+\n+\treturn 0;\n }\n \n /* Detect if we are a primary or a secondary process */\n@@ -461,26 +482,33 @@ enum rte_proc_type_t\n }\n \n /* Sets up rte_config structure with the pointer to shared memory config.*/\n-static void\n+static int\n rte_config_init(void)\n {\n \trte_config.process_type = internal_config.process_type;\n \n \tswitch (rte_config.process_type){\n \tcase RTE_PROC_PRIMARY:\n-\t\trte_eal_config_create();\n+\t\tif (rte_eal_config_create() < 0)\n+\t\t\treturn -1;\n \t\teal_update_mem_config();\n \t\tbreak;\n \tcase RTE_PROC_SECONDARY:\n-\t\trte_eal_config_attach();\n+\t\tif (rte_eal_config_attach() < 0)\n+\t\t\treturn -1;\n \t\trte_eal_mcfg_wait_complete(rte_config.mem_config);\n-\t\trte_eal_config_reattach();\n+\t\tif (rte_eal_config_reattach() < 0)\n+\t\t\treturn -1;\n \t\teal_update_internal_config();\n \t\tbreak;\n \tcase RTE_PROC_AUTO:\n \tcase RTE_PROC_INVALID:\n-\t\trte_panic(\"Invalid process type\\n\");\n+\t\tRTE_LOG(ERR, EAL, \"Invalid process type %d\\n\",\n+\t\t\trte_config.process_type);\n+\t\treturn -1;\n \t}\n+\n+\treturn 0;\n }\n \n /* Unlocks hugepage directories that were locked by eal_hugepage_info_init */\n@@ -998,7 +1026,10 @@ static void rte_eal_init_alert(const char *msg)\n \t\treturn -1;\n \t}\n \n-\trte_config_init();\n+\tif (rte_config_init() < 0) {\n+\t\trte_eal_init_alert(\"Cannot init config\");\n+\t\treturn -1;\n+\t}\n \n \tif (rte_eal_intr_init() < 0) {\n \t\trte_eal_init_alert(\"Cannot init interrupt-handling thread\");\n", "prefixes": [ "v4" ] }{ "id": 54356, "url": "