From patchwork Tue Apr 28 23:58:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69488 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7BA6EA00BE; Wed, 29 Apr 2020 01:58:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 006F91D663; Wed, 29 Apr 2020 01:58:41 +0200 (CEST) Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by dpdk.org (Postfix) with ESMTP id 26A181D659 for ; Wed, 29 Apr 2020 01:58:38 +0200 (CEST) Received: by mail-pj1-f67.google.com with SMTP id a32so7573pje.5 for ; Tue, 28 Apr 2020 16:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GVygkQjjID+OmR+ja6uIzpBhMCRTyyoj3mLawY1JK1s=; b=QCfPb6RREYoCieGLKmoWp02ln//g0dNERNk5jK3Byo2iKv1K7AEf9HddAT5UZdfcTz F+rVHcFv9/D/Kvyu0S9NJvMQG6SoUGHjr+xr1ZRN88t/z3FQ2MyLwZ0X037/BtxT6QlH TVb7v889jDcxYMYlGhiMVcN/i3kh4SYhYCLblR5ieOfNVF0U41MqgIqIQFsStbn2O6da yKef8kl5Jc41p2nr/OJXlw3bWXR+SEcOmuQcg5D3Icji/qOCqZd0M6/l2Gx/xkCfIMHf wibxUehIWFVTkx0Ybc0Er12Lh6aT/7SBQ/+7RrFqWwdT2fK7GYjZwHnUAFgMm58+JyuI ukOw== 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:mime-version:content-transfer-encoding; bh=GVygkQjjID+OmR+ja6uIzpBhMCRTyyoj3mLawY1JK1s=; b=Kv9uHkeqzdqAjlkR8zw53Y4raqcqUjH5WsnCqBKFieKJeuV4ZQAwoWjgkjijwbIgB3 fsMCNWmyGgI4igzc/tb4aNB5AOru/ryLl//7vLiDFGvCiao3/W5FN97rqLB3500phi36 PCnbsuljd3upLbith8dvYDEgsmLMwUAeXQ+QaWFz9KcQN9HBTfMWW9v1Lh546vqTmVRJ Dt8NQONZUmImIqxvzEnU+fiy90KZqk6ffBNH4GrZ3OPBDvfHoIa4qQ/wOG17ZJmWgHSv 8RvKZ1gr+Zr2bgNWL/MuAupAy9rPkPBj3hmOOk+l3NhK6NyH+iPR26T4KObef1PkU5XW J5Ug== X-Gm-Message-State: AGi0PuZ3Oc9nDYkb6zEGku+hRvBZH0gfCiJ+TqC5K2DHVlRtIeFnuU42 2ZQfpaxhkz1/nXU32Op4+HZBDfFPB0KnVg== X-Google-Smtp-Source: APiQypJX1oX934xj64aT+M765lxVv4oNNxnC3GEAU0mjJCD7jtJR7EnEq1JKRcrIJxMbwMzO+0Lidg== X-Received: by 2002:a17:90a:d17:: with SMTP id t23mr15040pja.77.1588118316804; Tue, 28 Apr 2020 16:58:36 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h193sm16209471pfe.30.2020.04.28.16.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:58:35 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 28 Apr 2020 16:58:20 -0700 Message-Id: <20200428235827.15383-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428235827.15383-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428235827.15383-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 1/8] eal: log: close on cleanup 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" When application calls rte_eal_cleanup on shutdown, the DPDK log should be closed and cleaned up. Fixes: af75078fece3 ("first public release") Signed-off-by: Stephen Hemminger --- lib/librte_eal/common/eal_common_log.c | 12 ++++++++++++ lib/librte_eal/common/eal_private.h | 13 +++++++++++++ lib/librte_eal/linux/eal.c | 1 + lib/librte_eal/linux/eal_log.c | 14 ++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index d7a5f9b6417a..43de798ae96a 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -479,3 +479,15 @@ eal_log_set_default(FILE *default_log) "Debug dataplane logs available - lower performance\n"); #endif } + +/* + * Called by environment-specific cleanup function. + */ +void +eal_log_cleanup(void) +{ + if (default_log_stream) { + fclose(default_log_stream); + default_log_stream = NULL; + } +} diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index ecf827914fdd..24ddfc6c53f4 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -89,6 +89,12 @@ int rte_eal_memzone_init(void); */ void eal_log_set_default(FILE *default_log); +/** + * Common log cleanup function (private to eal). + * Closes the default log stream. Called from rte_eal_cleanup(). + */ +void eal_log_cleanup(void); + /** * Fill configuration with number of physical and logical processors * @@ -150,6 +156,13 @@ int rte_eal_timer_init(void); */ int rte_eal_log_init(const char *id, int facility); +/** + * Close the default log stream + * + * This function is private to EAL. + */ +void rte_eal_log_cleanup(void); + /** * Save the log regexp for later */ diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index aa72d3650929..73d2c98b012b 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -1337,6 +1337,7 @@ rte_eal_cleanup(void) rte_trace_save(); eal_trace_fini(); eal_cleanup_config(&internal_config); + rte_eal_log_cleanup(); return 0; } diff --git a/lib/librte_eal/linux/eal_log.c b/lib/librte_eal/linux/eal_log.c index 43c8460bfb07..258a16ff2498 100644 --- a/lib/librte_eal/linux/eal_log.c +++ b/lib/librte_eal/linux/eal_log.c @@ -37,8 +37,16 @@ console_log_write(__rte_unused void *c, const char *buf, size_t size) return ret; } +static int +console_log_close(__rte_unused void *c) +{ + closelog(); + return 0; +} + static cookie_io_functions_t console_log_func = { .write = console_log_write, + .close = console_log_close, }; /* @@ -60,3 +68,9 @@ rte_eal_log_init(const char *id, int facility) return 0; } + +void +rte_eal_log_cleanup(void) +{ + eal_log_cleanup(); +} From patchwork Tue Apr 28 23:58:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69489 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 00EB9A00BE; Wed, 29 Apr 2020 01:58:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A4A7A1D66E; Wed, 29 Apr 2020 01:58:42 +0200 (CEST) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by dpdk.org (Postfix) with ESMTP id B10211D661 for ; Wed, 29 Apr 2020 01:58:39 +0200 (CEST) Received: by mail-pj1-f66.google.com with SMTP id 7so1652694pjo.0 for ; Tue, 28 Apr 2020 16:58:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7qwyrh0lTMXNcai1naQp777bSa6cojehYV6tpKV4jWQ=; b=IvgzDNs1ANDH7WLR7UFX/3VzAzAfDhwXIX7MedVjk1eCj1/u1A11Sw6AiGhiwloqds myE4wlsNY42EXQFpEq7RMIedfvicNI03Dy6rEQko8rBIoS1ag7TIi5RKu4/k9JYTJ72w bTfXPxvvrRH7/2mpIol8/HfmIFqbMjRHtdlu7DyLkfl3aHUKIH7pK2OGEoUWkwljXDnn ecp8xOOD1pmLZOq19O+7Rjym/75hM8CWSzgcEECuOLIwzgE290wQRe8zH5m0leJDFHVG Nj/WCIcBMLC89hFPUUEE198SnG471imD4kWzOIw0EONmd8GqStlU9h8vMI0INyWP5ISs 2Vsw== 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:mime-version:content-transfer-encoding; bh=7qwyrh0lTMXNcai1naQp777bSa6cojehYV6tpKV4jWQ=; b=nuWzu7mY9Qv5EZ+DqaAHscSYuOUaMJfOu9t9xEBHrM6EM4PDbrYzyoFtay8zb68NZc X0Ey7J3sTIfPudG4eslfM/FU1zWVwJjN2Q+2jJYqKvwpZ62WfsCtWo4r+WVnjcDmY7QD EbVtz26GSBovgMl1XyWpOpWhgw0CxT/drblCIA3tzjU8SXHunsD7xxLbNLGg96KUEZ7j h13/KmdlKtbYMQqdr/O+itKc31Vt9eqvUvSnOOfG3J0mvk8C2vWBHKdVXkQivMexCalg TuIocGnuQ6JDhOOBpSGrmJfJKMMShQX0Cl1xeAGoy4dddovQEgHAppB2nfmm80DvxZY3 zNRw== X-Gm-Message-State: AGi0PuZjo6RWiKxsbCccHU1+4HIj7ktf4shofYFNPJnJ6YA+eQOdxIbw nTl3buvKVvKS+JBrrErEQtgXp/5Dk1uLLg== X-Google-Smtp-Source: APiQypJC4iUFLfubX9C7ujxH95yvLKsflkb2NMBpgbkmVUc3P9KmMje4Z2YY01ozC+JDhO8Si7ae9g== X-Received: by 2002:a17:90a:1b4c:: with SMTP id q70mr18767pjq.55.1588118318370; Tue, 28 Apr 2020 16:58:38 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h193sm16209471pfe.30.2020.04.28.16.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:58:37 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , olivier.matz@6wind.com Date: Tue, 28 Apr 2020 16:58:21 -0700 Message-Id: <20200428235827.15383-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428235827.15383-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428235827.15383-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 2/8] eal: log: free dynamic state on cleanup 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" When rte_eal_cleanup is called, free all the memory associated with dynamic log levels and types. Fixes: c1b5fa94a46f ("eal: support dynamic log types") Cc: olivier.matz@6wind.com Signed-off-by: Stephen Hemminger --- lib/librte_eal/common/eal_common_log.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index 43de798ae96a..a37cd86f7743 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "eal_private.h" @@ -54,7 +55,7 @@ struct log_cur_msg { }; struct rte_log_dynamic_type { - const char *name; + char *name; uint32_t loglevel; }; @@ -486,8 +487,26 @@ eal_log_set_default(FILE *default_log) void eal_log_cleanup(void) { + struct rte_eal_opt_loglevel *opt_ll, *tmp; + size_t i; + if (default_log_stream) { fclose(default_log_stream); default_log_stream = NULL; } + + TAILQ_FOREACH_SAFE(opt_ll, &opt_loglevel_list, next, tmp) { + if (opt_ll->pattern != NULL) + free(opt_ll->pattern); + else + regfree(&opt_ll->re_match); + free(opt_ll); + } + + for (i = 0; i < rte_logs.dynamic_types_len; i++) + free(rte_logs.dynamic_types[i].name); + + rte_logs.dynamic_types_len = 0; + free(rte_logs.dynamic_types); + rte_logs.dynamic_types = NULL; } From patchwork Tue Apr 28 23:58:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69490 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C87BDA00BE; Wed, 29 Apr 2020 01:59:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3C3B61D67B; Wed, 29 Apr 2020 01:58:46 +0200 (CEST) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by dpdk.org (Postfix) with ESMTP id 6B5CB1D668 for ; Wed, 29 Apr 2020 01:58:41 +0200 (CEST) Received: by mail-pj1-f68.google.com with SMTP id y6so9460pjc.4 for ; Tue, 28 Apr 2020 16:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QNVAZzCTafZKF3vqSmP69/mwraWuPAw1sEN26Z4Qr3E=; b=zAAjXMVCxWuD75es/v2wd1Z16cqPRId0TEXjE8jsN/VhPE5b0W52mYKM2KQzx8ZTa8 +5FvgDSWuWk8ETHpVlCdP1LJRg86p7RuIaluQaTJM7uxWY+tHk5TKDX2udx4/v7nehVK Ff9rFd3Su2I/MISWoytdHeHHgvk7CDsPUCz1znlJ9DAwBhGgN0DlHA+wn434+/P/TeMM dgxIGIsaUld+Bqn9JE/6jEQmNqjd6jhrtN24qsECLsYqCgR4kW0wnbe+WF8OQnQJvRYA W2QpZUkKHcEX/gHTve7bl3LrE/3Cdf73lIEyOAZSLh8MFot4aTeSjHiiaJ2A+vkjnQah eFgw== 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:mime-version:content-transfer-encoding; bh=QNVAZzCTafZKF3vqSmP69/mwraWuPAw1sEN26Z4Qr3E=; b=XWxeehP+XlVeVSvTQ+H1Eph0soiePRo4B0RmQiXuqFO6dJBhcV2Pin0K0fJfPpQ0wr eR5bBy0ebxDgVMJZsPbaHJpYP1M9jXmjw9PXnnlHN6suz2U56Y3ZhmN5GaR7kVxf7tcf 7dQtmPuGJdOoU+cAeS4cK5VjbYYmUutGDDZLO8m4a6e2C27nI4WfccehHYEFztRZsdwz yCU22cRjB91R3YeUEQdAVDPFsi0d6kDecfJxpm36POytAZKzBaK1K1fcxunBNsFrPP3u KH7gqNweJeLvjS/LpzcYOIGD89cIjhUkdmzibIRBOG/riQW5I+dE1HrhStG+aXiM7Rv3 toSw== X-Gm-Message-State: AGi0PubyJLcK0xbNVTyRIXR/0KIcuYgRujJdcHvaNEXuywZGV/rm29eE WhoymcE94pl5F8NNDawu6zDfluBiOjSmLQ== X-Google-Smtp-Source: APiQypK/BSFwbkvQEPNb0aF0oZYPuis4DNDXkGrk72XQA6LJD+wWadTGsP4AsuFOVXzZe0JdyC9eMw== X-Received: by 2002:a17:90a:9f92:: with SMTP id o18mr27850pjp.180.1588118320157; Tue, 28 Apr 2020 16:58:40 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h193sm16209471pfe.30.2020.04.28.16.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:58:39 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , olivier.matz@6wind.com, Bruce Richardson Date: Tue, 28 Apr 2020 16:58:22 -0700 Message-Id: <20200428235827.15383-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428235827.15383-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428235827.15383-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 3/8] eal: alarm: close file on cleanup 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" When rte_eal_cleanup is called, free all the memory associated with dynamic log levels and types. Fixes: c1b5fa94a46f ("eal: support dynamic log types") Cc: olivier.matz@6wind.com Signed-off-by: Stephen Hemminger --- lib/librte_eal/common/eal_private.h | 7 +++++++ lib/librte_eal/freebsd/eal.c | 1 + lib/librte_eal/freebsd/eal_alarm.c | 10 ++++++++++ lib/librte_eal/linux/eal.c | 1 + lib/librte_eal/linux/eal_alarm.c | 11 +++++++++++ 5 files changed, 30 insertions(+) diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 24ddfc6c53f4..71539dae412f 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -201,6 +201,13 @@ int rte_eal_intr_init(void); */ int rte_eal_alarm_init(void); +/** + * Cleanup alarm resources. + * + * This function is private to EAL. + */ +void rte_eal_alarm_cleanup(void); + /** * Function is to check if the kernel module(like, vfio, vfio_iommu_type1, * etc.) loaded. diff --git a/lib/librte_eal/freebsd/eal.c b/lib/librte_eal/freebsd/eal.c index 540b7d38c5b7..582ff0920af4 100644 --- a/lib/librte_eal/freebsd/eal.c +++ b/lib/librte_eal/freebsd/eal.c @@ -973,6 +973,7 @@ int rte_eal_cleanup(void) { rte_service_finalize(); + rte_eal_alarm_cleanup(); rte_mp_channel_cleanup(); rte_trace_save(); eal_trace_fini(); diff --git a/lib/librte_eal/freebsd/eal_alarm.c b/lib/librte_eal/freebsd/eal_alarm.c index c38b2e04f811..b2089d0b53df 100644 --- a/lib/librte_eal/freebsd/eal_alarm.c +++ b/lib/librte_eal/freebsd/eal_alarm.c @@ -61,6 +61,16 @@ rte_eal_alarm_init(void) return 0; } +void +rte_eal_alarm_cleanup(void) +{ + if (intr_handle.fd == -1) + return; + + close(intr_handle.fd); + intr_handle.fd = -1; +} + static inline int timespec_cmp(const struct timespec *now, const struct timespec *at) { diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 73d2c98b012b..7458592f4950 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -1333,6 +1333,7 @@ rte_eal_cleanup(void) if (rte_eal_process_type() == RTE_PROC_PRIMARY) rte_memseg_walk(mark_freeable, NULL); rte_service_finalize(); + rte_eal_alarm_cleanup(); rte_mp_channel_cleanup(); rte_trace_save(); eal_trace_fini(); diff --git a/lib/librte_eal/linux/eal_alarm.c b/lib/librte_eal/linux/eal_alarm.c index 3252c6fa5909..f839626dad7d 100644 --- a/lib/librte_eal/linux/eal_alarm.c +++ b/lib/librte_eal/linux/eal_alarm.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -74,6 +75,16 @@ rte_eal_alarm_init(void) return -1; } +void +rte_eal_alarm_cleanup(void) +{ + if (intr_handle.fd == -1) + return; + + close(intr_handle.fd); + intr_handle.fd = -1; +} + static void eal_alarm_callback(void *arg __rte_unused) { From patchwork Tue Apr 28 23:58:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69491 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C2020A00BE; Wed, 29 Apr 2020 01:59:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AF5EA1D681; Wed, 29 Apr 2020 01:58:47 +0200 (CEST) Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by dpdk.org (Postfix) with ESMTP id 4438A1D676 for ; Wed, 29 Apr 2020 01:58:43 +0200 (CEST) Received: by mail-pj1-f65.google.com with SMTP id y6so9489pjc.4 for ; Tue, 28 Apr 2020 16:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p+GwdMm2UwxS1a1z5F+0+KYPi/v4lFrzxgvROMBkFKE=; b=oz1g4rRgKGYqMbPhzFPxZEmN4N+q/oENCJsmGdkjLZMpBN+QREKW2gFbJbm5qV1/nr JiY1jc/HTNxhsUkF/t2iwfW/s/5nQTFQ/jEB4cBXeeCHQUHewJBWaF6j0CilFqSuRQga PZNXrc3WCIybm3l8JyJba93wJb7IRlPTdOKEcjvCqkixPwt3G1tEHdEr7VLXCoODatfp LyLfByv3v8dvS/U/ajpxINJRwIVjb7XOQOoXOmxdzioXpfGWgNFkGhNatM5yzOEa3uPn 7GmWMHkCnq5thItcwNXsUbdoZ0y6pZMUPbmVl2wuO4CPocr/s+Z8fWgEk+b+/MhscVqa fiog== 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:mime-version:content-transfer-encoding; bh=p+GwdMm2UwxS1a1z5F+0+KYPi/v4lFrzxgvROMBkFKE=; b=HVvckt1rZi/Yr4xxivc6t2txsXvxHPVbYNpbRdqeBDhZ8Ehg+l4aeMBFpvI8G4O+Ex frCk5w8caBQdL9PBuczUNme4jgzor5vGPI3juOJJ0n/xuqwFwTCnQOAy0sYKlAlgXrs0 Kov7vDWinWlbRE1kH516L48Uzks57i157hifTkg1OgICykyo2GqR7krRXd6g4f4Az6+2 8b8mNtXAoT43SARmLdevY5TAukvQz8rukoLXC+tBKQLAuC/y/y+df6sCrg9KvrYUUZVG hwzCubguyu7HTOvuq7PBOIaC5oBL3LuXvrHpvy66qe/J6BunZHWNFj/SxBM6yTobsGzc HCAg== X-Gm-Message-State: AGi0PuY0n816RB6vCH7TozuHbJNGq4CbTbkbHX228Wl8iJge0zPNa7nI /qTKw34+mFT+i9jhN0Ut4dD2kTQ08NP3dQ== X-Google-Smtp-Source: APiQypJPLvbxdc9HyXZIuMS0NwpQUotlg6y4GyuTE3vQ5Afb5KIUtstEzGfGTauMcqGVpTSre3z6Gg== X-Received: by 2002:a17:90a:bc4a:: with SMTP id t10mr45269pjv.104.1588118321928; Tue, 28 Apr 2020 16:58:41 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h193sm16209471pfe.30.2020.04.28.16.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:58:41 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Aaron Conole Date: Tue, 28 Apr 2020 16:58:23 -0700 Message-Id: <20200428235827.15383-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428235827.15383-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428235827.15383-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 4/8] eal: cleanup threads 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" When rte_eal_cleanup is called it should stop all the child threads and close the pipes between threads. Signed-off-by: Stephen Hemminger Acked-by: Aaron Conole --- lib/librte_eal/linux/eal.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 7458592f4950..27b768b15c4a 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -1327,11 +1327,24 @@ mark_freeable(const struct rte_memseg_list *msl, const struct rte_memseg *ms, int rte_eal_cleanup(void) { + int i; + /* if we're in a primary process, we need to mark hugepages as freeable * so that finalization can release them back to the system. */ if (rte_eal_process_type() == RTE_PROC_PRIMARY) rte_memseg_walk(mark_freeable, NULL); + + RTE_LCORE_FOREACH_SLAVE(i) { + pthread_cancel(lcore_config[i].thread_id); + pthread_join(lcore_config[i].thread_id, NULL); + + close(lcore_config[i].pipe_master2slave[0]); + close(lcore_config[i].pipe_master2slave[1]); + close(lcore_config[i].pipe_slave2master[0]); + close(lcore_config[i].pipe_slave2master[1]); + } + rte_service_finalize(); rte_eal_alarm_cleanup(); rte_mp_channel_cleanup(); From patchwork Tue Apr 28 23:58:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69492 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7DC79A00BE; Wed, 29 Apr 2020 01:59:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E3AA61D689; Wed, 29 Apr 2020 01:58:50 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id E0E4F1D676 for ; Wed, 29 Apr 2020 01:58:44 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id f15so136324plr.3 for ; Tue, 28 Apr 2020 16:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yql0Efy+OmCLtVPaFMHWydRJ5AExA7LMI4P8O2x2IOs=; b=vCz+H+/pzetFwU6oBbX+lI3Y1AzKfkVoZ+KPf5moY+GQJlZqdRUOpvc95DYl3m9r2R hocWn108Zrbn9WdXBtVfLAp6Qk77tJUo7/MS+iXxkGT3e7MEvuFwIrL6Bautsh8Vp3Eg abOz/Y4vWWNQV08PVHAZQr/fwETfp5RmF3cNAkPx+QbgopY0V/Lb4e1gBJjUSsLe6LwK quJq0xy4FM9M4aCbdydmGIrnVkaNjGQNAxYlEOzuUQkh5Z9cPo7DWL6sYqdHaj8LjyVc H+/HTq4ETWU6T7QReHTyXfI00oymbTjl081e8So6Uil7sv6ARLaCpxDKjusYZK1JgvdV aL2Q== 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:mime-version:content-transfer-encoding; bh=Yql0Efy+OmCLtVPaFMHWydRJ5AExA7LMI4P8O2x2IOs=; b=EzDve7Qf59g6hXNhJGjIh4h+eJjrNhlhKI3vk0D77IADPU3o2zrAitHmaY6F11m99L +8DAAY0iBT/MqBTqDi4mPdzEk5XvujnI2vkA7eE99ew24D+GPxYyJOz8Q7xGdjW2Zt/J bOomTV11g7e52htZdILXzjupq+6UH4iPOdcj9tGFaGqL2XVlma21H8ibFB5YTPvxURzj KcuE25P+HiAMQPtjuw+Ggh6Fhj/u/8Wh58cF+fIvSPWUDVScbJz75a93GXSEmkrK5x3s UL9XWJKuttAGSJdPpVMp6hFsbXQz0HE9MOIlY9u/UD/7b/xCvFG890iWLmLGI8XFPZtX fRdA== X-Gm-Message-State: AGi0PuY1IHoijk7HiHIOBFCyKGJn++3GSRQSsyFN9aQNN8YOu+iUgQzt h77QWLUdP12iMtUmQdQdcZpVPGrU4Nn0Pg== X-Google-Smtp-Source: APiQypJIAJ4ZVOaani2ze2F9beBtYGEKb7Cffu0hYh+u5cN5b29FnBcYfYxD6NqXQChbq9nl1o2P2w== X-Received: by 2002:a17:90a:224a:: with SMTP id c68mr31650pje.160.1588118323502; Tue, 28 Apr 2020 16:58:43 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h193sm16209471pfe.30.2020.04.28.16.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:58:42 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , qi.z.zhang@intel.com, stable@dpdk.org, Anatoly Burakov Date: Tue, 28 Apr 2020 16:58:24 -0700 Message-Id: <20200428235827.15383-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428235827.15383-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428235827.15383-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 5/8] eal: mp: end the multiprocess thread during cleanup 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" When rte_eal_cleanup is called, all control threads should exit. For the mp thread, this best handled by closing the mp_socket and letting the thread see that. This also fixes potential problems where the mp_socket gets another hard error, and the thread runs away repeating itself by reading the same error. Fixes: 85d6815fa6d0 ("eal: close multi-process socket during cleanup") Cc: qi.z.zhang@intel.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger Acked-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_proc.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index 935e8fefeba8..f369d8bf6dd8 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -276,8 +276,17 @@ read_msg(struct mp_msg_internal *m, struct sockaddr_un *s) msgh.msg_control = control; msgh.msg_controllen = sizeof(control); +retry: msglen = recvmsg(mp_fd, &msgh, 0); + + /* zero length message means socket was closed */ + if (msglen == 0) + return 0; + if (msglen < 0) { + if (errno == EINTR) + goto retry; + RTE_LOG(ERR, EAL, "recvmsg failed, %s\n", strerror(errno)); return -1; } @@ -305,7 +314,7 @@ read_msg(struct mp_msg_internal *m, struct sockaddr_un *s) RTE_LOG(ERR, EAL, "invalid received data length\n"); return -1; } - return 0; + return msglen; } static void @@ -376,10 +385,8 @@ mp_handle(void *arg __rte_unused) struct mp_msg_internal msg; struct sockaddr_un sa; - while (1) { - if (read_msg(&msg, &sa) == 0) - process_msg(&msg, &sa); - } + while (read_msg(&msg, &sa) > 0) + process_msg(&msg, &sa); return NULL; } From patchwork Tue Apr 28 23:58:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69493 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B5125A00BE; Wed, 29 Apr 2020 01:59:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5490C1D699; Wed, 29 Apr 2020 01:58:52 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id 5D8B51D67D for ; Wed, 29 Apr 2020 01:58:46 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id o185so132612pgo.3 for ; Tue, 28 Apr 2020 16:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SRzQAEQ47xfzy39dnBWvcBVnmzaCA5jfKtlPrGxK+7U=; b=zC6DjJE23ykKOTZaRCWqh/qJ2RrGWoDqQNQq8ZUuIR+LiQ4HZsvA2OCLOepp5SII1F H0qtYc3NnkW1O1FCiGlkd0IOe5HN54IEemb/DqhG1LdSRl1IH6BLsaTemymJxdhVz45l hxDPcifwAzDlpvZwRAjVbuRvBMDn7s1Tw/uk1s8rZ/A9VHvG5IxiJkQi5wEEq1DYaKBL fbDY8EaikAczPFUvVad+ULpa7VLe3aydRF2HkJb99TpI+BpOXjTtsur9up6Prc92kLyK C5lB086pMAdQheNois+RricgzbzDJ5iTOQ1b9JI0WfzCsRVgCIGgDbx5KvUFqZw0hJTx cvLQ== 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:mime-version:content-transfer-encoding; bh=SRzQAEQ47xfzy39dnBWvcBVnmzaCA5jfKtlPrGxK+7U=; b=llhQBS7vnFS6ImpaHiGYsflZf5oWD0pQ+n6Ev52orE94FLJbMgAhe4F+3j+Dk/16Dq 5BFoKm3+HvBgc7UU3nwMnnValH140MtOXd8kVwAMxcKYMe3quNkLFFWRL1D6H0wAsVxc irKbANpNeI7VaXm2OA5JknsGQaYTEB4oVN6r8SYIGAyUTnIQnp0cq/ceTEG6iJuc9tm9 E1I9Jmyp0I7p6QtG0q9TmimuT/XA5XO09VPie0XbP4IyYH+ww3ASqK8TPtr8jvGMDiLY PTcn0mzce7wDFVVHeKpF9N+GD7UGnk0Dtdi/aR563Sl11o0qOPKrmV+cy+/MSZhtmkrY kpdg== X-Gm-Message-State: AGi0PuZU+2c0HaEl2bluzPDO5dsylgLr3gROKBYa3nCVg+SBsC8rOMZf J+GUrd1AiQiz6MIVfi1aJ/K4Rx6VoztmVg== X-Google-Smtp-Source: APiQypKZT2dG3rkAQP45pfmXD/OMT+M2X1Tz4XnyBlJJ9SMPBDH0HvdRu/rcr67t8hXI3hDXmkUFfA== X-Received: by 2002:aa7:9f48:: with SMTP id h8mr31923984pfr.147.1588118325108; Tue, 28 Apr 2020 16:58:45 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h193sm16209471pfe.30.2020.04.28.16.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:58:44 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , anatoly.burakov@intel.com, stable@dpdk.org Date: Tue, 28 Apr 2020 16:58:25 -0700 Message-Id: <20200428235827.15383-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428235827.15383-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428235827.15383-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 6/8] eal: vfio: cleanup the mp sync handle 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" When rte_eal_cleanup is called the rte_mp_action for VFIO should be freed. Fixes: edf73dd33072 ("ipc: handle unsupported IPC in action register") Cc: anatoly.burakov@intel.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger Acked-by: Anatoly Burakov --- lib/librte_eal/linux/eal.c | 3 +++ lib/librte_eal/linux/eal_vfio.h | 1 + lib/librte_eal/linux/eal_vfio_mp_sync.c | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 27b768b15c4a..7c56dbf49508 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -1346,6 +1346,9 @@ rte_eal_cleanup(void) } rte_service_finalize(); +#ifdef VFIO_PRESENT + vfio_mp_sync_cleanup(); +#endif rte_eal_alarm_cleanup(); rte_mp_channel_cleanup(); rte_trace_save(); diff --git a/lib/librte_eal/linux/eal_vfio.h b/lib/librte_eal/linux/eal_vfio.h index cb2d35fb1206..bf7408a897a7 100644 --- a/lib/librte_eal/linux/eal_vfio.h +++ b/lib/librte_eal/linux/eal_vfio.h @@ -132,6 +132,7 @@ int vfio_has_supported_extensions(int vfio_container_fd); int vfio_mp_sync_setup(void); +void vfio_mp_sync_cleanup(void); #define EAL_VFIO_MP "eal_vfio_mp_sync" diff --git a/lib/librte_eal/linux/eal_vfio_mp_sync.c b/lib/librte_eal/linux/eal_vfio_mp_sync.c index 5f2a5fc1d94e..b8ae9c65892e 100644 --- a/lib/librte_eal/linux/eal_vfio_mp_sync.c +++ b/lib/librte_eal/linux/eal_vfio_mp_sync.c @@ -120,4 +120,12 @@ vfio_mp_sync_setup(void) return 0; } +void +vfio_mp_sync_cleanup(void) +{ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + + rte_mp_action_unregister(EAL_VFIO_MP); +} #endif From patchwork Tue Apr 28 23:58:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69494 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E1BAEA00BE; Wed, 29 Apr 2020 01:59:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8446F1D6A5; Wed, 29 Apr 2020 01:58:53 +0200 (CEST) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 08D8E1D684 for ; Wed, 29 Apr 2020 01:58:48 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id 18so176504pfv.8 for ; Tue, 28 Apr 2020 16:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S6QD3eLls3M9plGsg+sTUWhIt7li+lqKHf5cEZzmIoA=; b=I4ikXa7Us5GfQ7k/WggUZ3CNBizI2uxmp7Kz6s1VkxXyTHUnIRswXSIuKPvfb4PTUy pNVyiTQq6Xg3Sjf7Qx3YQKBSBcxpl6knsMwkasa/fpYte519hfdqUn6t6ywHAGVwPvVo hvwzo6MhOLjt6IGTrxqtQNjJ0hqwd/7cvND7BItKqq/RUL1kfNCDuAVqbNgs/XVId3zA udHViEBxhs9Cm0gw7bEXschad/2k7ZNMe57oWP8XkqjEWqykseHBg3Y40yRB7mc1NUEj gbZ2pllxVEhER3hBLA1u9htYbya9rRYDdzr0q9w+LWIGxLa5DUmlNkWZ/FcdTEtj1gnX /QUg== 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:mime-version:content-transfer-encoding; bh=S6QD3eLls3M9plGsg+sTUWhIt7li+lqKHf5cEZzmIoA=; b=Lp81lDWbfiOr3gltQ71Ka995B1VxPD8Bi2U6xug/qCGFmssDyeloNJXbO/Rg3kwAt8 XRW4eIVEgTubm98WMSD2LqOa2qf6jo5ifyyFmnYieioBHG6nTNkcaB9wb2odKjF5ZYYM r4+kBykiBNu6tT2wSPyBVD/B7WyVAJDH290/Y7am9tsN0c/GjRo9e5ReqCx2Kzznjd/g EVPYwZ9QYxJrbg5uNWq2RykBdF2APUD4AhRJiJl1joUSZtwhvOUWurJaoek5OVy89cYp 45WjoARGN0Lbcogsk1mhCIcsQguGChQ1DSqfECAjhoBTgVmklzp9PNbrCAGy7Gu+9Z14 t9eg== X-Gm-Message-State: AGi0PuZlj38sNSRZurVqOe48vqkQSlNAELOlFdzPym48fRKuF3MIGYjV /F7fIHdGIpoH0GMWaT+7tCFbTRe4j54Dpw== X-Google-Smtp-Source: APiQypJVLyNodfEu/iWCA4P/zrA7KwUIem2Iq4P8Wb7gMZ8X2FvJ3N2pYZcXBx6xlf85JhzjvnYv/g== X-Received: by 2002:a63:4446:: with SMTP id t6mr8032507pgk.450.1588118326717; Tue, 28 Apr 2020 16:58:46 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h193sm16209471pfe.30.2020.04.28.16.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:58:45 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 28 Apr 2020 16:58:26 -0700 Message-Id: <20200428235827.15383-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428235827.15383-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428235827.15383-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 7/8] eal: hotplug: cleanup multiprocess resources 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" When rte_eal_cleanup is called, hotplug should unregister the resources associated with the multi-process server. Signed-off-by: Stephen Hemminger --- lib/librte_eal/common/hotplug_mp.c | 5 +++++ lib/librte_eal/common/hotplug_mp.h | 6 ++++++ lib/librte_eal/linux/eal.c | 1 + 3 files changed, 12 insertions(+) diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c index ee791903b3b7..a390c01fd41c 100644 --- a/lib/librte_eal/common/hotplug_mp.c +++ b/lib/librte_eal/common/hotplug_mp.c @@ -463,3 +463,8 @@ int eal_mp_dev_hotplug_init(void) return 0; } + +void eal_mp_dev_hotplug_cleanup(void) +{ + rte_mp_action_unregister(EAL_DEV_MP_ACTION_REQUEST); +} diff --git a/lib/librte_eal/common/hotplug_mp.h b/lib/librte_eal/common/hotplug_mp.h index 8fcf9b52e24c..4848446c852d 100644 --- a/lib/librte_eal/common/hotplug_mp.h +++ b/lib/librte_eal/common/hotplug_mp.h @@ -37,6 +37,12 @@ struct eal_dev_mp_req { int eal_mp_dev_hotplug_init(void); +/** + * Unregister all mp action callbacks for hotplug. + */ +void +eal_mp_dev_hotplug_cleanup(void); + /** * This is a synchronous wrapper for secondary process send * request to primary process, this is invoked when an attach diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 7c56dbf49508..ffb0678b864a 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -1350,6 +1350,7 @@ rte_eal_cleanup(void) vfio_mp_sync_cleanup(); #endif rte_eal_alarm_cleanup(); + eal_mp_dev_hotplug_cleanup(); rte_mp_channel_cleanup(); rte_trace_save(); eal_trace_fini(); From patchwork Tue Apr 28 23:58:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69495 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2A454A00BE; Wed, 29 Apr 2020 01:59:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F0E711D6AB; Wed, 29 Apr 2020 01:58:54 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id AFBC01D68E for ; Wed, 29 Apr 2020 01:58:49 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id 18so181002pfx.6 for ; Tue, 28 Apr 2020 16:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A0YsfnmAGAC8zy3k9FjyYg5Ott247hG2qGL4g4NcAAA=; b=TxAE6umqovqJeuqu7194zFntBQGgGdiNKeub2PR+dhesaqoidDGav6F666bKlI3G2B BXwNQrypdtu56jrK9Li4vqbhnte1SSe1PA0nZ+478gzEuYWbghGnFUs2Tnl/J9pHXvnD b+7V4rNn1tV9DTdPNskucur4ldLvrDPrzpD8gE8jiyvGw7Iys4CD7wWAaAmRWwN72gwT tidh3HxUqoK5oc8naQdLr5ugSgeNL0rAivwJKpeY9xE2e6YKIrIY9YSuY4RfPUTyLIao xF6OsKY6ZndcvKVXR5z4b1l4c9I+8OrgVOcW/8omkge2eF4jGqQqivmFRTbsExiW95Tz bCxA== 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:mime-version:content-transfer-encoding; bh=A0YsfnmAGAC8zy3k9FjyYg5Ott247hG2qGL4g4NcAAA=; b=VO+AlwkQormbaufTOLeK0xcFxx434TcMSXyhR7xjR6agF+9ALw3bpuPkSG8StYNLY2 h5YYJMxlky6E8UCN0lcpiOPf9gLoK2keLZ5b0uzbL1YiacAiVy5r/6+bkxHP2zjXfY14 Ym/kJBl957FhIrkyUXO+PwgJE0DAdsaIoU/S2zurSF7YDRtOlm4rJDGu2v2WdD0KjLhd 6bNbbfsuDN5o9bpRxkYvUYxfi0tOSq6PFJUwJFQzkG48flpldlOFaDaNgwT5a13TGhbz k4iygXCiEhemkn3LYKTDupjRtSKIMe8FeBwA+ZfWq84HjnAh2WICQuOnwNIQpEo5MbIw 2Ang== X-Gm-Message-State: AGi0Pub8Z7jnQJuZb9OjMjs0nmPpdOVbP7kya8Ry5LnvldDM2Szi+9eQ QGvd5E8eQVvtV4WSWeSkIx/2YiuGmCu4fw== X-Google-Smtp-Source: APiQypKDQ9+ucwI+3S8eMVZPsmyrjxXvRoa5Th3tM54k3De2CDnxU5BbdyETHrYUO4uoM3hjoFzN2Q== X-Received: by 2002:a63:d546:: with SMTP id v6mr30272168pgi.228.1588118328416; Tue, 28 Apr 2020 16:58:48 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h193sm16209471pfe.30.2020.04.28.16.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:58:47 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Anatoly Burakov Date: Tue, 28 Apr 2020 16:58:27 -0700 Message-Id: <20200428235827.15383-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428235827.15383-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428235827.15383-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 8/8] eal: malloc: cleanup mp resources 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" The mp action resources in malloc should be cleaned up via rte_eal_cleanup. Signed-off-by: Stephen Hemminger Acked-by: Anatoly Burakov --- lib/librte_eal/common/malloc_heap.c | 6 ++++++ lib/librte_eal/common/malloc_heap.h | 3 +++ lib/librte_eal/common/malloc_mp.c | 12 ++++++++++++ lib/librte_eal/common/malloc_mp.h | 3 +++ lib/librte_eal/linux/eal.c | 1 + 5 files changed, 25 insertions(+) diff --git a/lib/librte_eal/common/malloc_heap.c b/lib/librte_eal/common/malloc_heap.c index 842eb9de75a1..13c673f363a9 100644 --- a/lib/librte_eal/common/malloc_heap.c +++ b/lib/librte_eal/common/malloc_heap.c @@ -1362,3 +1362,9 @@ rte_eal_malloc_heap_init(void) /* add all IOVA-contiguous areas to the heap */ return rte_memseg_contig_walk(malloc_add_seg, NULL); } + +void +rte_eal_malloc_heap_cleanup(void) +{ + unregister_mp_requests(); +} diff --git a/lib/librte_eal/common/malloc_heap.h b/lib/librte_eal/common/malloc_heap.h index 772736b53f3c..ffad1b61e246 100644 --- a/lib/librte_eal/common/malloc_heap.h +++ b/lib/librte_eal/common/malloc_heap.h @@ -100,6 +100,9 @@ malloc_socket_to_heap_id(unsigned int socket_id); int rte_eal_malloc_heap_init(void); +void +rte_eal_malloc_heap_cleanup(void); + #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c index 1f212f834993..a9a9e8a45221 100644 --- a/lib/librte_eal/common/malloc_mp.c +++ b/lib/librte_eal/common/malloc_mp.c @@ -749,3 +749,15 @@ register_mp_requests(void) } return 0; } + +void +unregister_mp_requests(void) +{ + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + rte_mp_action_unregister(MP_ACTION_REQUEST); + } else { + rte_mp_action_unregister(MP_ACTION_SYNC); + rte_mp_action_unregister(MP_ACTION_ROLLBACK); + rte_mp_action_unregister(MP_ACTION_RESPONSE); + } +} diff --git a/lib/librte_eal/common/malloc_mp.h b/lib/librte_eal/common/malloc_mp.h index 2b86b76f6848..fb3d18c4e458 100644 --- a/lib/librte_eal/common/malloc_mp.h +++ b/lib/librte_eal/common/malloc_mp.h @@ -63,6 +63,9 @@ struct malloc_mp_req { int register_mp_requests(void); +void +unregister_mp_requests(void); + int request_to_primary(struct malloc_mp_req *req); diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index ffb0678b864a..abd478c9ceb0 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -1351,6 +1351,7 @@ rte_eal_cleanup(void) #endif rte_eal_alarm_cleanup(); eal_mp_dev_hotplug_cleanup(); + rte_eal_malloc_heap_cleanup(); rte_mp_channel_cleanup(); rte_trace_save(); eal_trace_fini();