get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/38914/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 38914,
    "url": "https://patches.dpdk.org/api/patches/38914/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1524663944-30376-10-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": "<1524663944-30376-10-git-send-email-arnon@qwilt.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1524663944-30376-10-git-send-email-arnon@qwilt.com",
    "date": "2018-04-25T13:45:43",
    "name": "[dpdk-dev,v8,09/10] eal: replace rte_panic instances in init sequence",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "276d563173879f0545735614a92edc2bbd32d6b4",
    "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/1524663944-30376-10-git-send-email-arnon@qwilt.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/38914/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/38914/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 2D63A7D0B;\n\tWed, 25 Apr 2018 15:46:23 +0200 (CEST)",
            "from mta.qwilt.com (mta.qwilt.com [52.9.191.255])\n\tby dpdk.org (Postfix) with ESMTP id 2CC5E7CC9\n\tfor <dev@dpdk.org>; Wed, 25 Apr 2018 15:46:16 +0200 (CEST)",
            "from localhost (localhost [127.0.0.1])\n\tby mta.qwilt.com (Postfix) with ESMTP id 632D680B53F;\n\tWed, 25 Apr 2018 13:46:16 +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 WqPJHbDTDCH3; Wed, 25 Apr 2018 13:46:15 +0000 (UTC)",
            "from rd01.it.qwilt.com.qwilt.com (80.179.204.39.cable.012.net.il\n\t[80.179.204.39])\n\tby mta.qwilt.com (Postfix) with ESMTPSA id 8CF9E80C24C;\n\tWed, 25 Apr 2018 13:46:13 +0000 (UTC)"
        ],
        "X-Virus-Scanned": "amavisd-new at qwilt.com",
        "From": "Arnon Warshavsky <arnon@qwilt.com>",
        "To": "thomas@monjalon.net, anatoly.burakov@intel.com, wenzhuo.lu@intel.com,\n\tdeclan.doherty@intel.com, jerin.jacob@caviumnetworks.com,\n\tbruce.richardson@intel.com, ferruh.yigit@intel.com",
        "Cc": "dev@dpdk.org,\n\tarnon@qwilt.com",
        "Date": "Wed, 25 Apr 2018 16:45:43 +0300",
        "Message-Id": "<1524663944-30376-10-git-send-email-arnon@qwilt.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1524663944-30376-1-git-send-email-arnon@qwilt.com>",
        "References": "<1524608213-2080-1-git-send-email-arnon@qwilt.com>\n\t<1524663944-30376-1-git-send-email-arnon@qwilt.com>",
        "Subject": "[dpdk-dev] [PATCH v8 09/10] eal: replace rte_panic instances in\n\tinit sequence",
        "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://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": "<https://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": "Change some local functions return type from void to int.\nThis change does not break ABI as the functions are internal.\nPanic thrown from threads was not handled in this patch\n\nSigned-off-by: Arnon Warshavsky <arnon@qwilt.com>\n---\n lib/librte_eal/bsdapp/eal/eal.c   |  69 +++++++++++++++++++-------\n lib/librte_eal/linuxapp/eal/eal.c | 101 ++++++++++++++++++++++++++------------\n 2 files changed, 119 insertions(+), 51 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c\nindex 10d8dc0..3110f53 100644\n--- a/lib/librte_eal/bsdapp/eal/eal.c\n+++ b/lib/librte_eal/bsdapp/eal/eal.c\n@@ -151,7 +151,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@@ -160,60 +160,81 @@ 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, 0660);\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(CRIT, EAL, \"%s(): Cannot open '%s' for rte_mem_config\\n\",\n+\t\t\t\t\t__func__, pathname);\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(CRIT, EAL, \"%s(): Cannot resize '%s' for rte_mem_config\\n\",\n+\t\t\t\t__func__, pathname);\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(CRIT, EAL, \"%s(): Cannot create lock on '%s'. Is another primary process running?\\n\",\n+\t\t\t\t__func__, 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(CRIT, EAL, \"%s(): Cannot mmap memory for rte_config\\n\",\n+\t\t\t\t__func__);\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(CRIT, EAL, \"%s(): Cannot open '%s' for rte_mem_config\\n\",\n+\t\t\t\t\t__func__, pathname);\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\tmem_cfg_fd = -1;\n+\t\tRTE_LOG(CRIT, EAL, \"%s(): Cannot mmap memory for rte_config\\n\",\n+\t\t\t\t__func__);\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@@ -237,23 +258,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())\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())\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+\tdefault:\n+\t\tRTE_LOG(CRIT, EAL, \"%s(): Invalid process type %d\\n\",\n+\t\t\t\t__func__, rte_config.process_type);\n+\t\treturn -1;\n \t}\n+\treturn 0;\n }\n \n /* display usage */\n@@ -552,7 +579,11 @@ 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(\"Failed to init configuration\");\n+\t\trte_errno = EFAULT;\n+\t\treturn -1;\n+\t}\n \n \t/* Put mp channel init before bus scan so that we can init the vdev\n \t * bus through mp channel in the secondary process before the bus scan.\ndiff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c\nindex 200e879..c0d704b 100644\n--- a/lib/librte_eal/linuxapp/eal/eal.c\n+++ b/lib/librte_eal/linuxapp/eal/eal.c\n@@ -160,7 +160,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@@ -169,7 +169,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@@ -179,30 +179,42 @@ enum rte_iova_mode\n \telse\n \t\trte_mem_cfg_addr = NULL;\n \n-\tif (mem_cfg_fd < 0){\n+\tif (mem_cfg_fd < 0) {\n \t\tmem_cfg_fd = open(pathname, O_RDWR | O_CREAT, 0660);\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(CRIT, EAL, \"%s(): Cannot open '%s' for rte_mem_config\\n\",\n+\t\t\t\t__func__, pathname);\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+\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(CRIT, EAL, \"%s(): Cannot resize '%s' for rte_mem_config\\n\",\n+\t\t\t\t__func__, pathname);\n+\t\treturn -1;\n \t}\n \n \tretval = fcntl(mem_cfg_fd, F_SETLK, &wr_lock);\n-\tif (retval < 0){\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(CRIT, EAL, \"%s(): Cannot create lock on '%s'.Is another primary process running?\\n\",\n+\t\t\t__func__, 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+\tif (rte_mem_cfg_addr == MAP_FAILED) {\n+\t\tRTE_LOG(CRIT, EAL, \"%s(): Cannot mmap memory for rte_config\\n\",\n+\t\t\t__func__);\n+\t\tclose(mem_cfg_fd);\n+\t\tmem_cfg_fd = -1;\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@@ -211,10 +223,11 @@ enum rte_iova_mode\n \t * processes could later map the config into this exact location */\n \trte_config.mem_config->mem_cfg_addr = (uintptr_t) 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 \tstruct rte_mem_config *mem_config;\n@@ -222,33 +235,42 @@ 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+\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(CRIT, EAL, \"%s(): Cannot open '%s' for rte_mem_config\\n\",\n+\t\t\t\t\t\t__func__, pathname);\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\tclose(mem_cfg_fd);\n+\t\tmem_cfg_fd = -1;\n+\t\tRTE_LOG(CRIT, EAL, \"%s(): Cannot mmap memory for rte_config! error %i (%s)\\n\",\n+\t\t\t\t__func__, errno, 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@@ -263,16 +285,20 @@ enum rte_iova_mode\n \tif (mem_config == MAP_FAILED || mem_config != rte_mem_cfg_addr) {\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\t\tRTE_LOG(CRIT, EAL, \"%s(): Cannot mmap memory for rte_config at [%p], got [%p] - please use '--base-virtaddr' option\\n\",\n+\t\t\t\t\t__func__, 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(CRIT, EAL, \"%s(): Cannot mmap memory for rte_config! error %i (%s)\\n\",\n+\t\t\t\t\t__func__, errno, strerror(errno));\n+\t\tclose(mem_cfg_fd);\n+\t\tmem_cfg_fd = -1;\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@@ -296,24 +322,32 @@ 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())\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())\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())\n+\t\t\treturn -1;\n \t\tbreak;\n \tcase RTE_PROC_AUTO:\n \tcase RTE_PROC_INVALID:\n-\t\trte_panic(\"Invalid process type\\n\");\n+\tdefault:\n+\t\tRTE_LOG(CRIT, EAL, \"%s(): Invalid process type %d\\n\",\n+\t\t\t\t__func__, rte_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@@ -833,6 +867,9 @@ static void rte_eal_init_alert(const char *msg)\n \n \trte_srand(rte_rdtsc());\n \n+\tif (rte_config_init() != 0)\n+\t\treturn -1;\n+\n \tif (rte_eal_log_init(logid, internal_config.syslog_facility) < 0) {\n \t\trte_eal_init_alert(\"Cannot init logging.\");\n \t\trte_errno = ENOMEM;\n",
    "prefixes": [
        "dpdk-dev",
        "v8",
        "09/10"
    ]
}