From patchwork Tue Jul 10 10:44:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Stojaczyk X-Patchwork-Id: 42694 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 65F781B484; Tue, 10 Jul 2018 12:46:42 +0200 (CEST) Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com [209.85.215.42]) by dpdk.org (Postfix) with ESMTP id 849481B47C; Tue, 10 Jul 2018 12:46:40 +0200 (CEST) Received: by mail-lf0-f42.google.com with SMTP id f18-v6so1775317lfc.2; Tue, 10 Jul 2018 03:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AcO3oDIsvA9BRy9ZNjuKpPvw3/NwcgZ6y4MJH3+Eo2c=; b=l62u/zN+PuohLsvC1o145glUFoIs74twINm4HgH43FZIJptTOFeGhFfY77xBUTyyzb P5hVjtKb5X+2Nzwe8JvdW0kFeNNcynIEb+qtNLs7IWlFFYTwzy8AhaULPeyDPYBU+7Xx KfAX7tR4OckvEB3CtUNBSZ4YITQr2s6hGWwy1xyYjnwZGwvfWZRzqmfXUp1NZTeCuOAb QtGZ3cejq13hhR9pxKRMAYECf+/uiOgZjbwwqPWmtGWcpehBTTAvgxJ2ky0WXfTBoBmG rgJLY9/Jm940GUE423YfO6i7UTx5s7wn0eR9dfUVz6Ir0RPby3oiJMDYQUSbIRmtNX2W qlHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AcO3oDIsvA9BRy9ZNjuKpPvw3/NwcgZ6y4MJH3+Eo2c=; b=AmuB0Qu3+NiL8ixEl6/aNhb3iymH76xiuJLX9WfJ6ts6QJSliWGUoeYpl1ln0g8pAZ 0F1UowGbY5mGKXmoAJqzDEpyg1O9VXaRuvxJsp3Zi3xDsWB9fVbNxXRSv2iIq9ckpNNW 8bI/lkCn065pAx10MkU+lGrfvMC8/mVG9p8zrKbcuIDod2QcDuT7ARpYBesSss46NsBr V5//97Hpu5GgvcZdpHjjd7NAaYIbi/MfU9mLsrrsUnEWIFzbm47hUWTLsGin+PinmyrD U7WLqLbOmKZ7yN6qM2NXDBqbEX7ZEKIMRa9+J2AymKpKsMtS3CFsrhhyje0Gqd1UcMht pPXQ== X-Gm-Message-State: APt69E2M6BWAZy3Ui7lXQSwPxJLW6w9Jg5tmDMDhkCnd60fO8deufJhr JJHoRwyfYZyFDocIrD9C7h3MiQ== X-Google-Smtp-Source: AAOMgpdwx9etvBn6xDHJRcy8EjWusbpsnzinz6KxuUy2fbi5APSosQs6vzRzFtU+w0SnUzpkdwhbEg== X-Received: by 2002:a19:e9d7:: with SMTP id j84-v6mr2527437lfk.115.1531219599169; Tue, 10 Jul 2018 03:46:39 -0700 (PDT) Received: from localhost.localdomain (89-68-114-161.dynamic.chello.pl. [89.68.114.161]) by smtp.gmail.com with ESMTPSA id q4-v6sm4591320lfj.81.2018.07.10.03.46.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 03:46:38 -0700 (PDT) From: Dariusz Stojaczyk To: dev@dpdk.org, Anatoly Burakov , Olivier Matz , stable@dpdk.org Cc: Dariusz Stojaczyk Date: Tue, 10 Jul 2018 12:44:45 +0200 Message-Id: <20180710104447.16756-1-darek.stojaczyk@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <1528461427-164113-1-git-send-email-dariuszx.stojaczyk@intel.com> References: <1528461427-164113-1-git-send-email-dariuszx.stojaczyk@intel.com> Subject: [dpdk-dev] [PATCH v2 1/3] eal/thread: ignore rte_thread_setname() failure in ctrl thread X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Dariusz Stojaczyk The error is not fatal and we can physically continue creating the thread. It simply won't have a name. If rte_thread_setname() fails, we will just print a debug log now. EAL does the same for lcore threads. Signed-off-by: Dariusz Stojaczyk Acked-by: Anatoly Burakov Reviewed-by: Olivier Matz --- lib/librte_eal/common/eal_common_thread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c index 42398630a..8110ac2ae 100644 --- a/lib/librte_eal/common/eal_common_thread.c +++ b/lib/librte_eal/common/eal_common_thread.c @@ -191,7 +191,8 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name, if (name != NULL) { ret = rte_thread_setname(*thread, name); if (ret < 0) - goto fail; + RTE_LOG(DEBUG, EAL, + "Cannot set name for ctrl thread\n"); } cpu_found = 0; From patchwork Tue Jul 10 10:44:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Stojaczyk X-Patchwork-Id: 42695 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BF3C11B49E; Tue, 10 Jul 2018 12:46:44 +0200 (CEST) Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by dpdk.org (Postfix) with ESMTP id 392321B47B; Tue, 10 Jul 2018 12:46:42 +0200 (CEST) Received: by mail-lf0-f66.google.com with SMTP id a134-v6so17866098lfe.6; Tue, 10 Jul 2018 03:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P8Ckipd6erVWgRPE+w8rvSKOG0nv1Qtx3d+uEotxyJ0=; b=OEUcQLkwpXKVVVpSca764fPIqoR91pZQIOQFr71gEfnvQLuRig54jCrMDQnOvxnGtQ 3wTDAPhG6yKIyur3Y9FUKvLBgJ0oJKWXdVOFYNF49PpKUIOWIFCaKcSpr8RvPFyjceol YLShgpRMTHFVnfXqklIl5uP18CtAzJIkiHB2Lncr/ejfqzW5YuF6s3yj5xf4JmN5eu/4 EH0CWhtuD/XUS8zDo5cwQGwSWzh8WhpPPqTLqouS98zvYX/7OFA3kILl6T3Lfl//FCZi 8VYs5Ej/Vu+YZ6hvtosZIodlsTl3E1q9j/OqRUUGqQetsvyWjA9O3QF50d3W4IFXgPGS Qpgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P8Ckipd6erVWgRPE+w8rvSKOG0nv1Qtx3d+uEotxyJ0=; b=sw7qj7KfYx8NHI3zLsVTixtnJ9u8DqixjtgdB4mxv0y13HCpKDRyKUFR0aI3DXRYag 7mx7p2dMXDl6rUX2tbiA/B+7D7JUKWxDdz8CQmEwckNCWl07gKC3/iLfr83JA1LNtf5j 8AXo/qxKlLUIedDVscX2/uL7TwOhFG7IPtVpmek6Tn5zhYx1qo35cy+fjz0HEatWtKTt NSBAG0yrfrO40DM8vHKJvR7wl5loxqObkBo8X2uEFFW2tCpivu+W/KgJ7LY66OkXQauP LWOp2LYeCJmosL0vWLZGhsjnX5kOGC4lMRsNZNV0QmXClfnH2TUGRJjZ6nNWUoDAu/0D LAIg== X-Gm-Message-State: APt69E3TQpUcvp+x6oMJxdBy7jFkjYygyTxB81t7juf7LQYmP+b6nasW 98MXkoynbpPp8K0YFr/pmWZYCPSo X-Google-Smtp-Source: AAOMgpdqtRkUpoSXq6LwG3BAK0aEddCIRUZoffAqd07t1upewo+qGFwL4kUX0WA2k16m3VVrz3tJOQ== X-Received: by 2002:a19:8e5c:: with SMTP id q89-v6mr2327298lfd.35.1531219601683; Tue, 10 Jul 2018 03:46:41 -0700 (PDT) Received: from localhost.localdomain (89-68-114-161.dynamic.chello.pl. [89.68.114.161]) by smtp.gmail.com with ESMTPSA id q4-v6sm4591320lfj.81.2018.07.10.03.46.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 03:46:41 -0700 (PDT) From: Dariusz Stojaczyk To: dev@dpdk.org, Anatoly Burakov , Olivier Matz , stable@dpdk.org Cc: Dariusz Stojaczyk , thomas.monjalon@6wind.com Date: Tue, 10 Jul 2018 12:44:46 +0200 Message-Id: <20180710104447.16756-2-darek.stojaczyk@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180710104447.16756-1-darek.stojaczyk@gmail.com> References: <1528461427-164113-1-git-send-email-dariuszx.stojaczyk@intel.com> <20180710104447.16756-1-darek.stojaczyk@gmail.com> Subject: [dpdk-dev] [PATCH v2 2/3] eal/thread: fix return codes for rte_thread_setname() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Dariusz Stojaczyk The doc says this function returns negative errno on error, but it currently returns either -1 or positive errno. It was incorrectly assumed that pthread_setname_np() returns negative error numbers. It always returns positive ones, so this patch negates its return value before returning. Fixes: 3901ed99c2f8 ("eal: fix thread naming on FreeBSD") Cc: thomas.monjalon@6wind.com Cc: stable@dpdk.org Signed-off-by: Dariusz Stojaczyk Acked-by: Anatoly Burakov Reviewed-by: Olivier Matz --- Changes from v1: * split this patch into two parts lib/librte_eal/linuxapp/eal/eal_thread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_thread.c b/lib/librte_eal/linuxapp/eal/eal_thread.c index f652ff988..b496fc711 100644 --- a/lib/librte_eal/linuxapp/eal/eal_thread.c +++ b/lib/librte_eal/linuxapp/eal/eal_thread.c @@ -176,7 +176,7 @@ int rte_sys_gettid(void) int rte_thread_setname(pthread_t id, const char *name) { - int ret = -1; + int ret = ENOSYS; #if defined(__GLIBC__) && defined(__GLIBC_PREREQ) #if __GLIBC_PREREQ(2, 12) ret = pthread_setname_np(id, name); @@ -184,5 +184,5 @@ int rte_thread_setname(pthread_t id, const char *name) #endif RTE_SET_USED(id); RTE_SET_USED(name); - return ret; + return -ret; } From patchwork Tue Jul 10 10:44:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dariusz Stojaczyk X-Patchwork-Id: 42696 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 90FAC1B4B5; Tue, 10 Jul 2018 12:46:46 +0200 (CEST) Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id 0D3221B4AD; Tue, 10 Jul 2018 12:46:45 +0200 (CEST) Received: by mail-lj1-f193.google.com with SMTP id p6-v6so16372596ljc.5; Tue, 10 Jul 2018 03:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hz+h3FVfPHxn4DGPtnGWU2a/Fh+Ght1JoIunA9HiXgI=; b=gEjRuV3j6hG87KpYNRnmVJVTXy+ajHeb9GyVGMkx6wPP2AF5TQXKylspcgVqWY5iMj WrSDj8VuAIpYQMJ1GZi1g9dgkgx2z1C8h5igC+M5YBUEieWajYfK7/Kc8NtiWIbIF8Dl SrbGrMWK6eUfRdmWzrhbwEglY1oXWpyEqQS1hE0WkrpqCQk/wMCNwdxSXmtOO46nLRxM lcEEgSw//rpHkDqTgxtygoqD9uWgNNW7KA1XK4StGDBd4j9kXFrnyCEVmOkEV5bVL8eJ l7CP1HDpbHP+qoegDlhNTLSlPRe0cFyXDk21QxtytqFUr/9l4tVQpoNgca0OTuxmu24X +luA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hz+h3FVfPHxn4DGPtnGWU2a/Fh+Ght1JoIunA9HiXgI=; b=JxR4UUzlWkrcYU16uwGbM4q/7NnykFh28f+8bKH6uB6HXu18kvSDuZWs+F7Y1klSHr 0LM0nkOGenbKRauWKozNQkLZKLAQQN6fhOeDN924KYZWxcYMEtAgBn0aHEIC6yxBK455 vGoxXIEP9CBmJRtHTWDjAUHYDno74LRDfznioVhrOqMKIUEE46vPDmbo4Z41tAGkRYtN GJZRshUS62qrunCq7jNbHZwMtf6tR28n996htWNfYfpWgWWlTZTKiT585BhQ8K1r0p5g hfSstbo6MLh3vwDTHCC619cVG4qSYKSY+AJdquzPd2cLXo0RiGhWNkxYcX6Sh0nJ+DzB v7uQ== X-Gm-Message-State: APt69E2aUq5Db3X4Wc3k5nvZsOZUq4mkK4HZwnG750Es8rPQeMgE+oPC BklOlEoZ5aBact8QQOOcZoL1WAAJ X-Google-Smtp-Source: AAOMgpcdk9hA2MonL2VYgB8IDtDMxqrmx0DMq8R1juRgzk/QRwSrVmRJB/oKgPQ6Hl8CRryxhpZjkg== X-Received: by 2002:a2e:590e:: with SMTP id n14-v6mr14524035ljb.128.1531219604480; Tue, 10 Jul 2018 03:46:44 -0700 (PDT) Received: from localhost.localdomain (89-68-114-161.dynamic.chello.pl. [89.68.114.161]) by smtp.gmail.com with ESMTPSA id q4-v6sm4591320lfj.81.2018.07.10.03.46.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jul 2018 03:46:43 -0700 (PDT) From: Dariusz Stojaczyk To: dev@dpdk.org, Anatoly Burakov , Olivier Matz , stable@dpdk.org Cc: Dariusz Stojaczyk Date: Tue, 10 Jul 2018 12:44:47 +0200 Message-Id: <20180710104447.16756-3-darek.stojaczyk@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180710104447.16756-1-darek.stojaczyk@gmail.com> References: <1528461427-164113-1-git-send-email-dariuszx.stojaczyk@intel.com> <20180710104447.16756-1-darek.stojaczyk@gmail.com> Subject: [dpdk-dev] [PATCH v2 3/3] eal/thread: fix return codes for rte_ctrl_thread_create() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Dariusz Stojaczyk This function returned positive error numbers instead of negative ones as desbribed in the doc. What's worse, multiple of its callers only check for (rc < 0) to detect failure. It was incorrectly assumed that pthread_create and pthread_setaffinity_np return negative errnos. They always returns positive ones, so this patch negates their return values before returning. Fixes: 9e5afc72c909 ("eal: add function to create control threads") Cc: olivier.matz@6wind.com Cc: stable@dpdk.org Signed-off-by: Dariusz Stojaczyk Acked-by: Anatoly Burakov Reviewed-by: Olivier Matz --- lib/librte_eal/common/eal_common_thread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/eal_common_thread.c b/lib/librte_eal/common/eal_common_thread.c index 8110ac2ae..48ef4d6de 100644 --- a/lib/librte_eal/common/eal_common_thread.c +++ b/lib/librte_eal/common/eal_common_thread.c @@ -175,7 +175,7 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name, params = malloc(sizeof(*params)); if (!params) - return -1; + return -ENOMEM; params->start_routine = start_routine; params->arg = arg; @@ -185,7 +185,7 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name, ret = pthread_create(thread, attr, rte_thread_init, (void *)params); if (ret != 0) { free(params); - return ret; + return -ret; } if (name != NULL) { @@ -228,5 +228,5 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name, } pthread_cancel(*thread); pthread_join(*thread, NULL); - return ret; + return -ret; }