From patchwork Tue Apr 28 23:14:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69470 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 C0582A00BE; Wed, 29 Apr 2020 01:14:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9287C1D63E; Wed, 29 Apr 2020 01:14:29 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id A66A71D62C for ; Wed, 29 Apr 2020 01:14:26 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id r14so142030pfg.2 for ; Tue, 28 Apr 2020 16:14:26 -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=ly2vdLIY8STcYSrGHWZteL8D1u99js7jHHLKIZdSHuI=; b=x598tCidydSQuE6SVwpow0nyIp9W5toi6TKOsubhb/UQmfZQKXgptiymy86frqyeo+ EOPpvCWdZi7T1JrvJA4XTDHWOwQte7i1t2juCAavkh4Aq+GwR/CmLxeoiVLnKXydpp3W g8AC7VY0eDimxaJ9wfRNftsfj+7qiThIOWf586rc2JOj/T8V0OyrzMVpKf0jKrWJ375n vutPqFnDx7Oc0G80CVNJz4GoeAzlfoUiCbotmBNhbAIFIfnl2LnGTzXkO/ie7OrRGp/W MWcmdp639m8viDpoi5BFL2t9hupJAE0fyzRVVCKda/9OC5e9uaHbjgw8bgHXLJ/IPAkU D6Wg== 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=ly2vdLIY8STcYSrGHWZteL8D1u99js7jHHLKIZdSHuI=; b=l1+jL5cGsRJzKXeUuGNcXAM2QaXSB2ygzsqJJjT8rvrMIkp1Y+dcjYlAJqOKXCtKPp FHEd4HG4ivmjFRG1iI5oWV8lb/RurGK85pjdvfbW7c1LztrcRWNj005WCQ46gTwmXyeB FDiejVcH70RsX0StaL+5cGLOZn1kuFoWs91+GKNphEeQi8nAiu0UKDWpdURm9cLgxsEC PGksfq0Ca/N/JlrnMOHoFmYYat1ev5I77d4c7Pp4uvp5jQqIPPA+7rpoak3t+eiJY7o+ e7dlxdV+rCOsfbN3hhYeQOPrU8ITIXnuu3vhZGRrbebo+saMg72NZCfDWUpsHaBa/3xg p4AA== X-Gm-Message-State: AGi0Pua3RBvPwKMAH4YuNi/O28TQK+/4s+9HhifxLmgZy4wb2SoIq1Uw z3NU6uhow6BaVU8lIv2NNcND4CMHoMudGQ== X-Google-Smtp-Source: APiQypL5f+YAlu9xLqT9VK6PAUAQX6hLtrdm/PoMh1h7LY0qi6fQl605GufyCnSc6K8ikhdIRu/xWA== X-Received: by 2002:a63:b952:: with SMTP id v18mr30526496pgo.179.1588115665371; Tue, 28 Apr 2020 16:14:25 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l64sm3230454pjb.44.2020.04.28.16.14.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:14:24 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 28 Apr 2020 16:14:08 -0700 Message-Id: <20200428231415.17985-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428231415.17985-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428231415.17985-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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..c407cb3c0edb 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(__attribute__((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:14:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69471 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 D3621A00BE; Wed, 29 Apr 2020 01:14:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ECDF31D645; Wed, 29 Apr 2020 01:14:32 +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 CB7B41D63C for ; Wed, 29 Apr 2020 01:14:28 +0200 (CEST) Received: by mail-pj1-f66.google.com with SMTP id hi11so172527pjb.3 for ; Tue, 28 Apr 2020 16:14:28 -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=IvPx+P1BNuUg3uTojmrfsF4XzRPGx/aM68i0zaXmb4bFoF8a8w8YryRMgDg5zUN/uV KxJ7I3vI+bI9sm31U2DE9/wjedVsQmsHSIVInFpNwylu0IJ8dJQCShgNcOWbcJkAMVBv poKrTAoWIWdhVDJfpzuzp+2CTlJ1qxwt0ciMQrEvVGUMKX9xlqe8SDpveuR7qdpK87jU BlWKArJDJOLtF9B8s4brKc7BME9MUfQVtTt433n/6u/e4AnpCTiRWLCHeNJ9kCPAlSnd NA5VocuEn5LF4v4POZVVYDOFu9ZacaPb6gn/ajZC/ddIDEpliTO6fB0iIxQlAzJbdOzT zf2A== 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=KhmjY+yR1eeLD49XnZanlCKOly31/xvhZ8FpUNGZmfybpWipT1I+9kB5YG3CWtMb2S Uz3UYDQQQXYyAg4yK3s1tUCim/0ZW1AEBuKtZ3j0ALwi4zsCVY4/FdPu/vXcsz18CsyS 9RhPndVdWbKP0AiMfVH4fXDL82OWzo4Jk1/aH6bA+A9FmwARLV9/allTq8aO03Eh0Yp1 RH0jhTuaDyMKWtyguQ0IJhPDj0Yx5Z49cK/bhd1Q014VMX4tzec9/gA0pScA6iH0Nepj qWUJj1wC1uYfxQksMdv5SPUWAeA94XLQhULbgJSaMIMijAX91yPETz5vXNY5evtc0cTb 0qAw== X-Gm-Message-State: AGi0Pua3/giHXZDxeX6HLO6If8LLx5gyoESDOBGk4aQM2pjJBbqIYxYW Xm1XqREdEkLAGaFL2Uwhi4wDCfpJszYGJA== X-Google-Smtp-Source: APiQypJoL0BmDPk6W0ByAx+I+5Avyx7RuwGS3rKgA+EMRHh0NRfpHOI4mbWmg8k7s3VqbCZv9348pA== X-Received: by 2002:a17:90a:3f8e:: with SMTP id m14mr7306927pjc.92.1588115667348; Tue, 28 Apr 2020 16:14:27 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l64sm3230454pjb.44.2020.04.28.16.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:14:26 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , olivier.matz@6wind.com Date: Tue, 28 Apr 2020 16:14:09 -0700 Message-Id: <20200428231415.17985-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428231415.17985-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428231415.17985-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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:14:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69472 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 E96A3A00BE; Wed, 29 Apr 2020 01:14:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 88AD01D64C; Wed, 29 Apr 2020 01:14:34 +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 6E2E11D642 for ; Wed, 29 Apr 2020 01:14:30 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id v63so120671pfb.10 for ; Tue, 28 Apr 2020 16:14:30 -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=y+iD3491/av99ODcmeHrbgBQhy/hOi7pHlUfCzJKOI4=; b=XKzeYsxGcZCq+aBn6Uxck7wzLSEwBCbXyCbBA8zQR4nuo9k0S32zkjbIo+M7cKZftK Dk3S7iV97+ZwzbXSk6hiil2RU8nTGrxPmJXKCgF4exGoleKlP1d/3sk5y7CF/DtKLGiC z/A67MdroTkjWmIrXA2vCTEA868NkFrN+E2lDqOSNYf6nZSU6y00hpkWbgHk7Ow+Y2jW KwUToUtq1Ad2eL2HCraIBDa2Z9e+TS8WAVcW6whOnDBwOFcqw1Q7w5nLdgYcJN/Ya7DA +N8nF/v93dTa3Xnzazzqdi4DeZYCiyM9CmjcHK/hquNa/6OLb3Z/IK8x8q3x3hMcgEcY p9SA== 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=y+iD3491/av99ODcmeHrbgBQhy/hOi7pHlUfCzJKOI4=; b=CqhERNENMNXorzZxl3CMJ/QwRtGkziAp5puAbVm7MZhU5RWKz9v2MVM540BmV4y2Wl a6uluHMJ9lpyPys/fBHhcfGs0XS5JkmayRAxOx0o78goDSFBfbMvtt2vbtmaaHnrSkcg cUwtPrGZMyQxodoIgO+SAhTciApWhs+/4KYLuRl+3osHiG/fP4AYcYOmHAkbGAOT2GvU NR1LJVVtAlWK+IHGlK0xKYfORTAl/KdqF9Gsr3j+PEVJa/p3mYdJAGzsWteTtG7CmEbr XQIhx3FCTRQaYgvJOzUy57VBGKfCNNl4UFfh5ZehnctRFqUAEI4BRrBaUvUR0SsjjOet wGkg== X-Gm-Message-State: AGi0PuY0fX2+J5UfeXIqqbtXN4gtEjNTyUcBRxMRu5iX8zff2gE7tjo1 D2MD8L2kPxS//268H0W3XcL7CEQf5sVeAw== X-Google-Smtp-Source: APiQypKiHSEhym8L0QKfvgtUWERSpEBi2JJ4TtEDH3XnVnqXZwXrJzLQUXKbvZuvHQFVPW2CtgLzBw== X-Received: by 2002:aa7:9ab3:: with SMTP id x19mr31354648pfi.141.1588115668944; Tue, 28 Apr 2020 16:14:28 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l64sm3230454pjb.44.2020.04.28.16.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:14:28 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , olivier.matz@6wind.com, Bruce Richardson Date: Tue, 28 Apr 2020 16:14:10 -0700 Message-Id: <20200428231415.17985-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428231415.17985-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428231415.17985-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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..1602f5c65293 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:14:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69473 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 6917EA00BE; Wed, 29 Apr 2020 01:15:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A68CD1D650; Wed, 29 Apr 2020 01:14:36 +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 E6E831D642 for ; Wed, 29 Apr 2020 01:14:31 +0200 (CEST) Received: by mail-pj1-f68.google.com with SMTP id h12so1613059pjz.1 for ; Tue, 28 Apr 2020 16:14:31 -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=zhMrU/E/gsuP1m0dSlzv41LMMR8gLtrI9oH6ij6x/wBvQm4fNrgQwUvcxchqtbMXXA +T8pvDxmMuQ3nfLA6TfhIk/qoxCVMtfbbY0kM5u6POlVxI69G31WHEtC9Te9679qt3Fn IRTSl/fi/Em2WCxMfHZexWfpT4Pw//w34npe3gxy0Z9a9tPVjxgcFsnUXFpKwepBe+Ht 1Oo1ubwoUdBlUa4IP2QqdCwicHD5Eqk1u8XtTNa1oZjoMTq+XipMOwYaZAs+wkuspdfk dS4CvcWvX3KkZ/dbjmk+cw2S2aJ0NlCqZ/1Dfos43U0QHg3qTCKZkY4HeuyuKZgIaucI j34Q== 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=WbWH2gCN6Bk8zOIR+LYAmBdYwJvYTg3IEhPJX4hdUQEbrCMbx3FOvxdZyNoPd0cjKu LFWB9w3bx1WgHg8+FkmLaMcLgCv5qYu0Sz0dmC9hj1y1ORFStCTNs3GZFDSjfs7HUUmd uuSVj4ovjVbYBjb1JVdL9F7AbohzZVA3nPjBmTliG7EfgYzuUfOnVLZm9FLx1lLlCESq C0c4X2ljU7tIc9N46umA8Qz7X2FjQvUa9puE2JkO8cITpNsuI8CmeYZFmwSsSrfRUWgh iIFS8nhwWE/G/bxNCShVwRY3Mr04DEr4k1qBMCO76PmPTlItRznNMIdN3/UheI3ILPj3 9shw== X-Gm-Message-State: AGi0PuZlnYc6LPUS8e7H3LYc9Sga9tMFyXaIOx7hJcsgcleYHdKWtzQq zS+0TNZCRoOMf9z4zBITupOKjSlkAtkn5A== X-Google-Smtp-Source: APiQypI1F9FObHZ39AoJmDPtBsDnKvCd61kZ3iUTy1gWA5H/t7E5rsYZMKzyrUZ4Zn0lyLQdgcGfJA== X-Received: by 2002:a17:902:8a88:: with SMTP id p8mr30906179plo.134.1588115670702; Tue, 28 Apr 2020 16:14:30 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l64sm3230454pjb.44.2020.04.28.16.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:14:29 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Aaron Conole Date: Tue, 28 Apr 2020 16:14:11 -0700 Message-Id: <20200428231415.17985-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428231415.17985-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428231415.17985-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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:14:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69474 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 07BC1A00BE; Wed, 29 Apr 2020 01:15:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 46BCF1D656; Wed, 29 Apr 2020 01:14:42 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id D697E1D649 for ; Wed, 29 Apr 2020 01:14:33 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id s10so101397plr.1 for ; Tue, 28 Apr 2020 16:14:33 -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=J5AJSzCXLIW89peeqjeHdS54l4B0YrYLw8y3kwTW2/S1nhkIiUyFuJBHD0u34ikjOt H274C2lpzRXGQtyCgwPDvhH6AIJC7+vojkQXXJ7aZwQTuCsnHfE06nhDL2EeIawxYIn+ try5y8ce/PslpAug2J3SN7QaXOESSOvY/qXxM6qVqfFZLaC6L54StKDwpK+MVXsDjGW5 77CmMFGDXt5tsQ1PmSrKAOmL3W8IiVcJ957mDkzFW9qDCq8CEx0jdLRR5KwpNwKPXuPk CY8rukp0KS3tHOo8LGy+FYa26V2qCkna8FmMCDrGs0ivW9mhhn9WyO90May7xykYlMem TzrQ== 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=F6RnCE4ByCpps+VyhQexlbOW8AZmHFZDwyu87NowZAPGiZqj0sHQHfwv9plMe43ShF LIIRXFqZA8ItTu1cyXRpmalJhSKs9OXi2dwnUwztKMW9hPGxOH4e5l6HJogCbKLgWHgf i5HED7Tkj+/04DSUF7ZWRGymOED6f7NgU8yAt2hklklts5VqqWFkoFPYIt5NZOR7ZofG bFl4coqlagz7xSh3F9rNPZtjnelFiYsQNb14DZY+aNrpcfMKXpcJQOSGFG2DNE/giPvN SZAgu+CpiSkdCY6rW3WrxkvQv5cxaNaE4OiGtDr9U0wCfPzIi7G/jhe9XKaddo6N0fFP T7rg== X-Gm-Message-State: AGi0PuZ9UjjHkYbiPI/RA/RyeOclVYaTwyOC7l9e6eLosi8TKzea8bQ7 7UXcV0WHvjk35C9tYkMX00mN1yrFgjeY8g== X-Google-Smtp-Source: APiQypIiQIf9tPvi/CeC+pqbEq0m3850qKvE9tahCmhW5HKuhoQLOdQm9/yK4vpFA+HWDc9bGicnHg== X-Received: by 2002:a17:902:8e87:: with SMTP id bg7mr22707762plb.91.1588115672555; Tue, 28 Apr 2020 16:14:32 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l64sm3230454pjb.44.2020.04.28.16.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:14:31 -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:14:12 -0700 Message-Id: <20200428231415.17985-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428231415.17985-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428231415.17985-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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:14:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69475 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 DC1B5A00BE; Wed, 29 Apr 2020 01:15:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ED74B1D660; Wed, 29 Apr 2020 01:14:43 +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 923AA1D650 for ; Wed, 29 Apr 2020 01:14:35 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id 145so113395pfw.13 for ; Tue, 28 Apr 2020 16:14:35 -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=Levtrux+nLR43R6v2s9eDu8I8q3AiRQstQg/pMGXGzBWKVEOKW0oYMlaFql9oA0IRw AQCFNfhgMVedoJ7JOqOaJ34982SBD3MlzehWjhm1DdjtOgwLk8A2YW1d3LO+A3VT92Jh hkgwdy6a1e9pOb0BCN+4E76dJCYFXMbdBK5pJJImzDs3RLwFNKHl8NMzzvmsc+HXaGgz drRryFhtICRn5FdRqiIvvFx3RPv6FJkQVogL638Mp1v+VaARiH2upgllvd7evcHFUBcN tGIcS4HQbolKKZb3cspV/3l3HWGICoiYBQfIgxWEAz5gTus3izWQntB4n4DKu+cf0jTa GZaA== 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=EfoPzUBlOg5UXX3pHfTrgXf+0J6/rUOljcXM8Q9YpXfPDxQE0c9EIO+qCGAQbTHNMp ljzOm554cemHUKDNZjI/Yk+obRTbUtoxN+C7/Xj+7hfSgrGfKGo6Q/D8zjcqaD4TZSrS bIkxgjg7mgpYJ/dqi+HaoEdtrCnwur8BGCTbWYbe9cYjcPOgtHcv8GZuepVkL6CM60gY Ms07jjeByMIJNaVUoraGaJ7w6Hb5SZonQniLZnKMFxLGBTQBvoofBYO3sYM4YwQL57W0 qBkoxNrBs+JEP29UebR5Q6H2V3vHk3uSRUVPdBfLLB3koMQ4I3Kemb48epyfuHsE8ZFB ZIfw== X-Gm-Message-State: AGi0PuYh+LQ9Kr+aXCMvAo/nD8O7tMs9SUklq5IZOcU42DPSAQ90dXKz 9Wamj+Z204++uGpCniGiKVauFyImmeHcEQ== X-Google-Smtp-Source: APiQypJ6wzuKcez/Gl8gXNXU2Ozf0Dp1Vc1bbgNCI4v2ivPUbP1GUlfF/4i2mi5LwjX0ulIoCcEyFA== X-Received: by 2002:a63:63c1:: with SMTP id x184mr15678844pgb.116.1588115674254; Tue, 28 Apr 2020 16:14:34 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l64sm3230454pjb.44.2020.04.28.16.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:14:33 -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:14:13 -0700 Message-Id: <20200428231415.17985-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428231415.17985-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428231415.17985-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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:14:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69476 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 95325A00BE; Wed, 29 Apr 2020 01:15:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4B6971D667; Wed, 29 Apr 2020 01:14:45 +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 0AB201D654 for ; Wed, 29 Apr 2020 01:14:37 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id f15so96436plr.3 for ; Tue, 28 Apr 2020 16:14:36 -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=psfu12XDqEnQEEDf+WhEbmFyQeqdhuyTaU1B48BhnNIrjZTyHTOuba2zUFRlwtkugx iew8BqpiCfmgeAoFApfGEPKkfo/o+9O8Ykhds0cMXU+CnfmZGX36np3WwQgTaAJLEQSO 3KlgW/OfhZEWVmsLun9OFIGJXA3s18J/4g9cAaKthpeA/TC0K8b6aFxKYdkR11+xQZsr WKk8nJuqUdIAwUd7+B1dDpIoxq46QADrxp1ji4c67CPgl53dpCTiEK2tAFCt46ocjZve iMP1t2BsLbLMik5rZix2MtjM2Q++DDKiou8/d7lW1dwDNbJVG9mEuLNzk9BGbm8QSAw5 YrKg== 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=YqmMxbaLaArW77Cpwo7894sBm5DSuYldGsHiFOSHXp0PmHyeS7hSClYZLaMZK8FZy2 XPz8cNJkpQ+ts1aT3nS40UheXupelHOP6B3FcL/NkPY6U9jCISHehpvBB55EgZ5ec+Jx btTPwHgGhDeN3rQ925AI84oX0Dm/lowsWVFfyGyA3y0CYuokMT5fo01LYm1Nmgy6etHZ zh/BzGtbVJUSN7gRj6rb4lkJUEcuG488eTb0v9+TJvrdSznwOLNrNXV4X6ywj4DnUw7X 8hneaIet93EirPnaO4BN8Len4VJhgNbC2vHtJL+8G1oI/yf7mQmjDZGp6M+7xMIDijVL MRTQ== X-Gm-Message-State: AGi0PuaalK8iB4yHx0zW/REoF+wjdGpHhb73BPF8BQ+cf7zVYsijj0Ze EN0bk1VZA3+5SLPHlbVhX7VUgFXic/bpXg== X-Google-Smtp-Source: APiQypJWiXebTS565TYYlSy3NeBDx6q1M164DxITElfw0PwAZY9TMNz0Kh2WGnApCIVzDnjbZsZY+A== X-Received: by 2002:a17:902:5983:: with SMTP id p3mr32197894pli.122.1588115675680; Tue, 28 Apr 2020 16:14:35 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l64sm3230454pjb.44.2020.04.28.16.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:14:34 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 28 Apr 2020 16:14:14 -0700 Message-Id: <20200428231415.17985-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428231415.17985-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428231415.17985-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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:14:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69477 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 EFA4DA00BE; Wed, 29 Apr 2020 01:15:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AF1101D66C; Wed, 29 Apr 2020 01:14:46 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id BC4DB1D649 for ; Wed, 29 Apr 2020 01:14:38 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id c21so95713plz.4 for ; Tue, 28 Apr 2020 16:14: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=A0YsfnmAGAC8zy3k9FjyYg5Ott247hG2qGL4g4NcAAA=; b=fkAsILt5aXieO6i29pZZ2K7NRZkdAunuEcHxv0AbRdWVktvOmC7TI1jnA1DWDmvVPh SZotKXjtYljO1FvGN4avLEhFu262cUFHxNz7clxYND9kLM45z7yS6807MjtcdOtLVshH ILiKZ2APGAj0BtWyBykdOqH4Ez7Vs91FdYBf4xoto0M+dGVDcNBeH5aKTehaF4uW1EQf gsvSPKG1Zn45kDVd4tuTVLU7Pdl8YdV5fWpnKIJFLMcqpLCOiOvX8ZlWWCRUgjE4CkbM 8ZXURBDiJD+XhN5Okgu72iv/zSnKTG0M5yH2BDtidxn3vW92NanV82zHU1V2v7GUX+1S jePQ== 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=H9pYpjTznf0G4HUWPLmFJL3uV4gHXq1odmVs+AkQlADYjSsNgj4fomXXKcL+uDEuam e1aNQBJbzyxozNDFrvKbpt2SaiArAoDCppFIAXIB61MkVq7zJkWHe6sbQxTDPt0DZanN 8/UiuNUOu7Lfk0rRIaXVBCMeSxrsTc1vPWrdH35TkWLgYp/sdoV+XSAP5S0P2qZfQubd 2aT0ndGu633eo0in8LRi6tfFJSL9g+/Jz0j3pu+U+NlSU9r6ewukUCiy/uO9eehQArgZ 45BxVAF9PgXkXnLV0g3yU9ZU+8kyQIMBdIJCvexT+Pjr8XvpmwslhN1EfJrX4Ek/V3l3 PerA== X-Gm-Message-State: AGi0PubrN4MJPniupGnMF6TnjmrCplg5Wm5iM5fA0iDXYhXPVLht/vC9 6OTnKxkFQqwfPnMnwiNw6CpM6KEpaFoukA== X-Google-Smtp-Source: APiQypJ4LxrSTmtIhYypX7eIahm9cbbK9lqWd0wyJbAkoLmUaOF0S77nLOghT9iBhWNNt/nunZ79KQ== X-Received: by 2002:a17:902:6b0a:: with SMTP id o10mr30523609plk.32.1588115677450; Tue, 28 Apr 2020 16:14:37 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l64sm3230454pjb.44.2020.04.28.16.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 16:14:36 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Anatoly Burakov Date: Tue, 28 Apr 2020 16:14:15 -0700 Message-Id: <20200428231415.17985-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428231415.17985-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> <20200428231415.17985-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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();