From patchwork Sat Nov 13 17:22:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 104280 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 50889A0032; Sat, 13 Nov 2021 18:23:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DEDC410FA; Sat, 13 Nov 2021 18:23:03 +0100 (CET) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by mails.dpdk.org (Postfix) with ESMTP id 09CD34013F for ; Sat, 13 Nov 2021 18:23:02 +0100 (CET) Received: by mail-pf1-f180.google.com with SMTP id n26so6587241pff.3 for ; Sat, 13 Nov 2021 09:23:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oiWywhA3WofE4yHKF3rzYgZO+5QXk1lx/khQFCnptBk=; b=Ob+Y965IrfCVmT59+AWP48d7+i7jy+ZMpybYol04JJfYj01s761P0vhU5Ajohn3cDn oFwIaY+bYCJD+vOXxw56yiaLE6OZgOFwaTo73EIADOYPLsKRqdLaEPX7h+E8eT60L/aa Gh9+EYdopfXRD4yBCPCJT8DQqDpPoHtzNCQ/5GD854dIiP3YseYuoP8hmOZco3fxdvxZ VOAByPzqRLpoJ+uEzHiEEO2/hFc2vrajNscD0SXji0OQMsrOQQVIsVAFeNSr4c1ThE+e Sqo1Stn6A7+RIbcvOYenk9l45aQEjSaJnM8delTTBwH9D4P8eMNcGKZiuwNblaY0SJVt amRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oiWywhA3WofE4yHKF3rzYgZO+5QXk1lx/khQFCnptBk=; b=KRbfxY56cl6jL9oHpzRr97TKAwSxSd5LNPmWXHb+RjuUtnu+LCmZHBiJvG+vmtzbyX cq6LSKBsITI2D9XOduQ2xRNsCsd2r5MFY4faMNLgKS6+THVa4X9lZppYJXipBh1+P+NI 6BH7rABW7as6qGvfbiTiCtFKfOGkhHSuJrtWjHzevrLxtUIn2W7TqJ/zgDOHLPc8FSZ4 j2YusNIXyq9kvKtkNc+jZ/df6ZPo93DBBQ47riA/aJOMUMBAh9lUAzPLKkB+2FZI0QCI tpLtcWTnv1U340fUBEPY5H9kGK+jDR2JhJc84FuO+vb97uuH+ISgYfsEVpoDQk4xZgsj zDkA== X-Gm-Message-State: AOAM530lzY/qn/o+O2dA0vpF1NoN827CYPylDRQgUrIB+ie1P5/V2geT J4Pky5HyclDXr+InviITTYUmPN7eQx73gw== X-Google-Smtp-Source: ABdhPJwZD/PFMWGHB6QhizEHCX8xTymCwOKStM+TvbLPLK/7/I9wzcogU+pK8florSTYgHk7vLxhCg== X-Received: by 2002:a63:e214:: with SMTP id q20mr15693118pgh.431.1636824180778; Sat, 13 Nov 2021 09:23:00 -0800 (PST) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id u19sm9658370pfl.185.2021.11.13.09.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Nov 2021 09:23:00 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v6 1/5] eal: close log in eal_cleanup Date: Sat, 13 Nov 2021 09:22:53 -0800 Message-Id: <20211113172257.6543-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211113172257.6543-1-stephen@networkplumber.org> References: <20200428235827.15383-1-stephen@networkplumber.org> <20211113172257.6543-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When application calls rte_eal_cleanup on shutdown, the DPDK log should be closed and cleaned up. This helps reduce false reports from tools like ASAN and valgrind that track memory leaks. Signed-off-by: Stephen Hemminger --- lib/eal/common/eal_common_log.c | 13 +++++++++++++ lib/eal/common/eal_private.h | 7 +++++++ lib/eal/linux/eal.c | 1 + lib/eal/linux/eal_log.c | 8 ++++++++ 4 files changed, 29 insertions(+) diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c index 1be35f539727..cbd0b851f216 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/eal/common/eal_common_log.c @@ -18,6 +18,7 @@ #include #include "eal_log.h" +#include "eal_private.h" struct rte_log_dynamic_type { const char *name; @@ -535,3 +536,15 @@ eal_log_set_default(FILE *default_log) "Debug dataplane logs available - lower performance\n"); #endif } + +/* + * Called by eal_cleanup + */ +void +rte_eal_log_cleanup(void) +{ + if (default_log_stream) { + fclose(default_log_stream); + default_log_stream = NULL; + } +} diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 36bcc0b5a492..2fbad534b938 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -152,6 +152,13 @@ int rte_eal_tailqs_init(void); */ int rte_eal_intr_init(void); +/** + * Close the default log stream + * + * This function is private to EAL. + */ +void rte_eal_log_cleanup(void); + /** * Init alarm mechanism. This is to allow a callback be called after * specific time. diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 60b49248388e..b67030b2792e 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1370,6 +1370,7 @@ rte_eal_cleanup(void) rte_trace_save(); eal_trace_fini(); eal_cleanup_config(internal_conf); + rte_eal_log_cleanup(); return 0; } diff --git a/lib/eal/linux/eal_log.c b/lib/eal/linux/eal_log.c index c0aa1007c4df..5a795ac9ebe3 100644 --- a/lib/eal/linux/eal_log.c +++ b/lib/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, }; /* From patchwork Sat Nov 13 17:22:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 104281 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B598CA0032; Sat, 13 Nov 2021 18:23:13 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1352741142; Sat, 13 Nov 2021 18:23:07 +0100 (CET) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id 3F2F64113E for ; Sat, 13 Nov 2021 18:23:03 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id j6-20020a17090a588600b001a78a5ce46aso9670464pji.0 for ; Sat, 13 Nov 2021 09:23:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VYpX6bLx1EhWZsQ9qfNftUoy9mDG929BoSttXJ4o5Mg=; b=e8+nPjP7smHDAYprT7XQl6F2FYo/5X4X5wSW+yCSU8erpwBpaireoPsY5qfLW5fAQz jxE1zjR0xd+vn3vYHK1MkS+Jnw7scj1F3rWzrGJ0SNkUdsqujylb1nuXE8VFjMhg8s/w SmyuketZlypqZM0xu663rVu1PLTwPFrulEjLNh0c7IS/K8orDcTs4R1K9ySRceX2rZni xXK1WGpPJRzLKKGgnN91UYu/K7+wKbnIz1XdaqX5Oad4zUy1dBtyBc2cdUgJCRxHgbLl Cr8/Erqlo2/raNOz/hZMvQinDuKZPBJ87PjY0+Dlm6Q4tbE82snS1GVHz/beXVbiLaIZ caXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VYpX6bLx1EhWZsQ9qfNftUoy9mDG929BoSttXJ4o5Mg=; b=vQBf0q/cR+O6DfSv5W39oXsEZ2f3uMIKNFcyyPo48S1gswEoGG8DZ+sIu+ca0gMyDe gsTBglgJMp5hXz2KDlEWBJWlOfQwWhrpuelVTuDEeHD/ZOiRgr7isZ3BNhlUjEam9Tev H/9yi+IGS0c1ZrmdPqh+jtBHB1hJEUlvdaUdXNVXEzlJZc5OxDKQAOmZE9xGFFrO/vWv 1pUNfD8Lnjmr/t1gHsspO4R8BpaPncsnMQoVSOzNwqIX2nWn1gqfg3Al43tnwVpG1D1o Cu4Zmnt+0sgWIth4BH2FKfWG3CrS36bAvIfOdAM87DgzYraFRQ0+2X3ukOvCjWUmpYDF hQ+Q== X-Gm-Message-State: AOAM531wbCPW/ntxE9Id7TBWwhx3DcH5HqfKfVrVxE6W6AyehQjSMURX sk4wgXUXa3Eb1RA0I2ApDquuAZnP54Rm1g== X-Google-Smtp-Source: ABdhPJz8o7EJTSWD5+trMRd5uzOjlVtQNcmGo+A7foA6lOdA/rD8XQUPlmf86fNDoajtF1pj/FHQAw== X-Received: by 2002:a17:902:8302:b0:143:6e5f:a4a0 with SMTP id bd2-20020a170902830200b001436e5fa4a0mr18945647plb.20.1636824182127; Sat, 13 Nov 2021 09:23:02 -0800 (PST) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id u19sm9658370pfl.185.2021.11.13.09.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Nov 2021 09:23:01 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , qi.z.zhang@intel.com, Anatoly Burakov Subject: [PATCH v6 2/5] eal: mp: end the multiprocess thread during cleanup Date: Sat, 13 Nov 2021 09:22:54 -0800 Message-Id: <20211113172257.6543-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211113172257.6543-1-stephen@networkplumber.org> References: <20200428235827.15383-1-stephen@networkplumber.org> <20211113172257.6543-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Signed-off-by: Stephen Hemminger Acked-by: Anatoly Burakov --- lib/eal/common/eal_common_proc.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c index ebd0f6673b8b..b33d58ea0a0f 100644 --- a/lib/eal/common/eal_common_proc.c +++ b/lib/eal/common/eal_common_proc.c @@ -282,8 +282,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; } @@ -311,7 +320,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 @@ -385,8 +394,13 @@ mp_handle(void *arg __rte_unused) struct sockaddr_un sa; while (mp_fd >= 0) { - if (read_msg(&msg, &sa) == 0) - process_msg(&msg, &sa); + int ret; + + ret = read_msg(&msg, &sa); + if (ret <= 0) + break; + + process_msg(&msg, &sa); } return NULL; From patchwork Sat Nov 13 17:22:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 104282 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D12F1A0032; Sat, 13 Nov 2021 18:23:18 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0EFF341149; Sat, 13 Nov 2021 18:23:08 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id 89AC841141 for ; Sat, 13 Nov 2021 18:23:04 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id v19so255588plo.7 for ; Sat, 13 Nov 2021 09:23:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LFmIZE7PTeeOd/K5OXdlFGqPuZyewlALvDbiE5eDT7Y=; b=MunNPYgYG6ePQsKAum/z3P0u2bYPEe7/LJHoKbeaVRfqZoYLU63AzHQEoLkX5nJ0eT kfOhuNVSO6bW328bPJE+Y5WBwMDnCrwGBNx1R7gt9ItVQdWKw9XuwT7tgAstHjOxitbc 5Owhus1k+1kR3Gl/5olIXC/GrN6keTzucW8Tz0kz5gsnel2RUfi/V5U6fC9ldy+vy1+F LqIr7IoVd9eTIcvn7lHXhjC/ThqTgks1j42TmtDB8WhLSMcZE5ProRTg4qvdHzzNwqT2 /b3hdi2uX9JoOld67KRQL1+AY5ite4mRzXvFLn3Fn4RUdL4rmII1iyyYedNmN7Xrkgg+ Pa4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LFmIZE7PTeeOd/K5OXdlFGqPuZyewlALvDbiE5eDT7Y=; b=Ax8+P6CIRS5Yp2IYgGIJ2j79+KEoljhkbn5TG0EhQcNZ5TT+VzSY87cXtnLVDVw9cV ZhpLniIBqIPKmjnbgpAy/xkAiSfrGZLjXu/IxKWEJAULI7MBGb0p14WZQMhJBJQDiKS8 9fbw4rxFMzJ1xicrA95i6JfBWkYcphtkTObn6UnPS0RpQnhaHNqD1Ygb4o2BCLRGiRxd IizkLd1Mbh/sGbBzWEKol2fqCBCEedB41AZJzQ+x3m3b3SvBevJzLJYkX9XOlyUbAItr NG/KICx5fuT/UZaoXdl3/IxPpcA5a3miruNS8PM0IYfApKvxmlOCxuGsooYUxxoSwMVq wL4w== X-Gm-Message-State: AOAM531krzLu3xDYmML/Txot+s3tj14GeZzCturcTnNPG7t38FHoloz3 wVPv5QrKuSM1ETPMnick/6qYkv/keJxqjw== X-Google-Smtp-Source: ABdhPJzzsN1yDG1oz1uJajyEGP6+NHJW2TNOJiEBYIaKNODZnOM2fHUR3lrTrmdqm7599JAUH1p6lg== X-Received: by 2002:a17:90a:c394:: with SMTP id h20mr29631050pjt.136.1636824183373; Sat, 13 Nov 2021 09:23:03 -0800 (PST) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id u19sm9658370pfl.185.2021.11.13.09.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Nov 2021 09:23:02 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , anatoly.burakov@intel.com, stable@dpdk.org Subject: [PATCH v6 3/5] eal: vfio: cleanup the mp sync handle Date: Sat, 13 Nov 2021 09:22:55 -0800 Message-Id: <20211113172257.6543-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211113172257.6543-1-stephen@networkplumber.org> References: <20200428235827.15383-1-stephen@networkplumber.org> <20211113172257.6543-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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/eal/linux/eal.c | 4 ++++ lib/eal/linux/eal_vfio.h | 1 + lib/eal/linux/eal_vfio_mp_sync.c | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index b67030b2792e..ad8f130b509d 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1362,7 +1362,11 @@ rte_eal_cleanup(void) if (rte_eal_process_type() == RTE_PROC_PRIMARY) rte_memseg_walk(mark_freeable, NULL); + rte_service_finalize(); +#ifdef VFIO_PRESENT + vfio_mp_sync_cleanup(); +#endif rte_mp_channel_cleanup(); /* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach(); diff --git a/lib/eal/linux/eal_vfio.h b/lib/eal/linux/eal_vfio.h index 6ebaca6a0cbf..921ee595388c 100644 --- a/lib/eal/linux/eal_vfio.h +++ b/lib/eal/linux/eal_vfio.h @@ -133,6 +133,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/eal/linux/eal_vfio_mp_sync.c b/lib/eal/linux/eal_vfio_mp_sync.c index a2accfab3a38..d12bbaee648b 100644 --- a/lib/eal/linux/eal_vfio_mp_sync.c +++ b/lib/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 Sat Nov 13 17:22:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 104283 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 48B02A0032; Sat, 13 Nov 2021 18:23:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1F29B41152; Sat, 13 Nov 2021 18:23:09 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id EDF4141141 for ; Sat, 13 Nov 2021 18:23:05 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id t21so10973017plr.6 for ; Sat, 13 Nov 2021 09:23:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iXB1LawRGPVXn8R02W+aV0pR1MKqhc8JED0X0sX0iDM=; b=fulBCFGFAGTUeZHWqwRw1YRl0Eoq9k5gu6GxGS7lpTxvNV6HD6Zo5ZuhbRSnAa10At K8hjDjzR6ZHI8UrTz1NvVQcoSxJGhmQfn9YyEL/4+HSAVc+HsSVmyO85h4b3DcGHjPuO Lj1Rq2hP4nHeLE1pYVVNgxzdvGliZ8mU6hKzdxBkY9nZsbRMNzm3nD37vGewtHYSutqi NmUo8k0G380e+bC86kdFnbrX5gR9z9huMZtBL59hOpk3RL6Q5qtoaEpQjFPdvyea7sT5 WtwmD/zqQqUajJM8L6rmZ7Au7WUbeaLDG+qkLp2sIB9hoLUlm278GUESUPvqlnHcQQja zkcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iXB1LawRGPVXn8R02W+aV0pR1MKqhc8JED0X0sX0iDM=; b=HB9bDrIuR6vla/GZlO4dW9ggqnhJt4a6134FpOrzyoFLgopnaJxrtWSH1+J2gUrZVi Cq41lVpb1qi/mpgEMAtEez1b4LmsCgunTiyFLxV6zacvmuB9bx5gOSRvgzhQk5GFxP4y BDqqUT0aXVRPbwz3IzWsjf69wDM+ZDg5m38MMLbMKfpox9hyLAXbvgJuP9qu2Kv9N72r YEME/WOMW/nbLVKtirHSWrSyJ9qnPLVY6mA43O8XbhU+6DeebrRZ7S7N5dVCi4pwd70k E5ELR+5q2lMmBAUlA9B8jFGKkB+gdJaZwhObrbsGgo/MwZQr/2GqAKcWz/14d8mfnTZY Ru7A== X-Gm-Message-State: AOAM533H+lLFY9/tvsoHh5VfyHuoTfSSQ/dc+L31AGZ/MUxLv/RcrOZ6 61yNt6sbzFUmRVo11Dcone6FICvp12nLGQ== X-Google-Smtp-Source: ABdhPJwLbnXC18HOrCpoOYXOD6wwwVn1xGYkfN4dmb8s7v5J1xc/7sMkaQiWHeSiRGySM0zPCodilQ== X-Received: by 2002:a17:90b:1643:: with SMTP id il3mr46900815pjb.182.1636824184652; Sat, 13 Nov 2021 09:23:04 -0800 (PST) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id u19sm9658370pfl.185.2021.11.13.09.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Nov 2021 09:23:04 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v6 4/5] eal: hotplug: cleanup multiprocess resources Date: Sat, 13 Nov 2021 09:22:56 -0800 Message-Id: <20211113172257.6543-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211113172257.6543-1-stephen@networkplumber.org> References: <20200428235827.15383-1-stephen@networkplumber.org> <20211113172257.6543-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When rte_eal_cleanup is called, hotplug should unregister the resources associated with the multi-process server. Signed-off-by: Stephen Hemminger --- lib/eal/common/hotplug_mp.c | 5 +++++ lib/eal/common/hotplug_mp.h | 6 ++++++ lib/eal/linux/eal.c | 1 + 3 files changed, 12 insertions(+) diff --git a/lib/eal/common/hotplug_mp.c b/lib/eal/common/hotplug_mp.c index bf55056f59c0..bde0de196ef5 100644 --- a/lib/eal/common/hotplug_mp.c +++ b/lib/eal/common/hotplug_mp.c @@ -462,3 +462,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/eal/common/hotplug_mp.h b/lib/eal/common/hotplug_mp.h index 8fcf9b52e24c..4848446c852d 100644 --- a/lib/eal/common/hotplug_mp.h +++ b/lib/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/eal/linux/eal.c b/lib/eal/linux/eal.c index ad8f130b509d..1a13a3474e38 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1370,6 +1370,7 @@ rte_eal_cleanup(void) rte_mp_channel_cleanup(); /* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach(); + eal_mp_dev_hotplug_cleanup(); rte_eal_alarm_cleanup(); rte_trace_save(); eal_trace_fini(); From patchwork Sat Nov 13 17:22:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 104284 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4AA86A0032; Sat, 13 Nov 2021 18:23:32 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 664F34115D; Sat, 13 Nov 2021 18:23:10 +0100 (CET) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mails.dpdk.org (Postfix) with ESMTP id 38B8041145 for ; Sat, 13 Nov 2021 18:23:07 +0100 (CET) Received: by mail-pl1-f171.google.com with SMTP id b13so11033778plg.2 for ; Sat, 13 Nov 2021 09:23:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EiVoq14vivz39nJuffyHDJYXlJHr8jlxYwdLxvhyMes=; b=MnQ+obc7/KVycWoCimhMFN4hTBPScJiXlqetNso01KJVkjDY5Id91Dj96Ihsf+5PFk 2la9gs6jmtHNBV4yzaDX0EAYvvHJmsjfreOUrgUjRK9ilno1TJBnnB+c5WOO2+gIv8AT 2UoXOlE4yLYDsVKaVh8VCpgrktuNgLcrHybwM4WHtvYyHVGyu5S50MpndRhpZ7lbK18p mJMAzK7P91UlA4CjN327oAeYeBRiw7BH6gx0mBRhrcF/Hc12shhl9JnjNce4RmTMmUpA y3Xl2yfxwFwyTbW6X2BcUmvbXJeKq1clL2/hwyMApK8Xnus7TXAoXdIP8VMjiylG1SKW 3rsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EiVoq14vivz39nJuffyHDJYXlJHr8jlxYwdLxvhyMes=; b=5vG8T5vFKUoHW3j73SzQUt2PdyE6N7NVkDn6N6PWosgSMz9HXJkjyFyyFc19B4xNH8 Eaqy4+1c1T0gTw0u6O6x+yyQEL194uLAfvJyNznO4YMjj24/sXBkA/icR3vMrgrH8TBt tPZ5ces3WrCqsYjN0QENbMK/isy8hGMOov/BNry+sMgzQjMti+r3vxY6Qdl/TVejvHzA yHBp8u2bKPVdEw9AKhzbN2OV9KoXZwWV8pKdg9I0QWxPtKTACaQ9d3ZKecUGV6u/IdK0 NCAKfPH1lGYlkuoBZNqXYCvvnrvxSbbhX8DLqKl0QxKiw12TPuHnZghQ7nG80YixddL8 S33Q== X-Gm-Message-State: AOAM530x0/K0XGNHVply/6ItG5EHQZsW25MCaUiDewYkJNFgHfc3E7fy kK+CX22+HQZtXh38Tf8VJsf8kJenxVaIbw== X-Google-Smtp-Source: ABdhPJz2oWZJ+MwIwlXai7AkM5+SaB/dYYA6VFyaK4ffURa4UkFoxJsD91tGFac0Al6mE4An0BdWvw== X-Received: by 2002:a17:90b:34b:: with SMTP id fh11mr46705583pjb.14.1636824186046; Sat, 13 Nov 2021 09:23:06 -0800 (PST) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id u19sm9658370pfl.185.2021.11.13.09.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Nov 2021 09:23:05 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Anatoly Burakov , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Subject: [PATCH v6 5/5] eal: malloc: cleanup mp resources Date: Sat, 13 Nov 2021 09:22:57 -0800 Message-Id: <20211113172257.6543-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211113172257.6543-1-stephen@networkplumber.org> References: <20200428235827.15383-1-stephen@networkplumber.org> <20211113172257.6543-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The mp action resources in malloc should be cleaned up via rte_eal_cleanup. Signed-off-by: Stephen Hemminger Acked-by: Anatoly Burakov --- lib/eal/common/malloc_heap.c | 6 ++++++ lib/eal/common/malloc_heap.h | 3 +++ lib/eal/common/malloc_mp.c | 12 ++++++++++++ lib/eal/common/malloc_mp.h | 3 +++ lib/eal/linux/eal.c | 1 + lib/eal/windows/eal_mp.c | 7 +++++++ 6 files changed, 32 insertions(+) diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index 55aad2711b39..666f770fbf6d 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -1403,3 +1403,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/eal/common/malloc_heap.h b/lib/eal/common/malloc_heap.h index 3a29d024b4ca..3b2fbc0aa059 100644 --- a/lib/eal/common/malloc_heap.h +++ b/lib/eal/common/malloc_heap.h @@ -85,4 +85,7 @@ malloc_socket_to_heap_id(unsigned int socket_id); int rte_eal_malloc_heap_init(void); +void +rte_eal_malloc_heap_cleanup(void); + #endif /* MALLOC_HEAP_H_ */ diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c index 2e597a17a2f2..5f6f275b7859 100644 --- a/lib/eal/common/malloc_mp.c +++ b/lib/eal/common/malloc_mp.c @@ -806,3 +806,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/eal/common/malloc_mp.h b/lib/eal/common/malloc_mp.h index 0095062b72f2..c806f7beafe0 100644 --- a/lib/eal/common/malloc_mp.h +++ b/lib/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/eal/linux/eal.c b/lib/eal/linux/eal.c index 1a13a3474e38..ea663fe02b93 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1371,6 +1371,7 @@ rte_eal_cleanup(void) /* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach(); eal_mp_dev_hotplug_cleanup(); + rte_eal_malloc_heap_cleanup(); rte_eal_alarm_cleanup(); rte_trace_save(); eal_trace_fini(); diff --git a/lib/eal/windows/eal_mp.c b/lib/eal/windows/eal_mp.c index f2fa9366f668..76413f49a393 100644 --- a/lib/eal/windows/eal_mp.c +++ b/lib/eal/windows/eal_mp.c @@ -87,6 +87,13 @@ register_mp_requests(void) return 0; } +void +unregister_mp_requests(void) +{ + /* Non-stub function succeeds if multi-process is not supported. */ + EAL_LOG_STUB(); +} + int request_to_primary(struct malloc_mp_req *req) {