From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A5CB1A0C47 for ; Tue, 10 Aug 2021 17:42:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A051F40686; Tue, 10 Aug 2021 17:42:44 +0200 (CEST) Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by mails.dpdk.org (Postfix) with ESMTP id 133574014F for ; Tue, 10 Aug 2021 17:42:43 +0200 (CEST) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPS id DE2083F10B for ; Tue, 10 Aug 2021 15:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628610162; bh=9w8INNgSRaE1tiiJgzzewVG+OC00NlScu33dzUYl+aE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=wZ4PeNPz3Vtp6YF7csYCluCy0ORJpAAbFihIsRKvhQVG2DGKGNw4k6vL5OQXzn8TX GjOjzW1BDTINieJQu8oVVnM76BFp0v9Rc2emvr+fkxKS6Z8VXRxEP1ul0BxrdhyN3T 0ze96HrUPOnKi2xbreoLyEiAWTxoJbSNm/wpGGnCystudLjUQ1z4j+3EthKd7Q+qCN +X1Rpi7/q875PRc/2kG9zZXLc0ZCQGwXIl8JbWkIaBgBPkEJrKnFqPWO4trjiXKXcP q+IbYfd0/arRg1v02cjpmagFW6wBrX1/39GLZ8oHpO1PUyd2EJrBoHPYPG69cybRq4 CTtcMbBnYDh6w== Received: by mail-ej1-f70.google.com with SMTP id gg35-20020a17090689a3b0290580ff45a075so135170ejc.20 for ; Tue, 10 Aug 2021 08:42:42 -0700 (PDT) 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=9w8INNgSRaE1tiiJgzzewVG+OC00NlScu33dzUYl+aE=; b=ULqATulMku09mvJ7RMVMM9MZ2D0ZlVzyMSrd+7M7FXRPH9tdXohBqPLXxbcL0SFrrR 2/qSiYp1PSs4VnypN11f6Kc42uG5lbG2r3tiN9Uas5I/hnnJriW6bUbitdnE8mPlXMvN zmIx6dwK4l0Pz+fI9H6r/RZZrKrCtdz5Aa4CmcG1F6DFTyretegtcz9q2Fu9AzxCyTjK PP6CVp1yhIrh5NBQioHegd7UbWH9QFHPt9ObRugKx69MR5iLhmN0jIFbZkcIUfwA6EHY 2Owf6AkwaTJvwDTg+Adffn0CnL5aoqV3YXMD2DOzEv/FKdTz1uCNMwErYvkp3th3KwVN 8vMg== X-Gm-Message-State: AOAM530GabXCRlqZZeCU9i8qJnYg+4Nf8DGTZQ07TepBNKnuvJRnIIht +E32FQSUsM0YffcFAiDedHMwLWI4vFQAW4RSiKpnkJ+tY2Pjmj1AFGvZ8/mHFGkrq1zfup3zKqE j6ogQou3zhSGYZTV2/TlKIAap X-Received: by 2002:a17:907:20f2:: with SMTP id rh18mr28474335ejb.136.1628610162651; Tue, 10 Aug 2021 08:42:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYwUvNdE95+LHu5YzMH9b7ZLPDiMVuJ3Os9SnCH2dFYK7CbTjxfTIRsO4QtH2U9eOkUZcgnA== X-Received: by 2002:a17:907:20f2:: with SMTP id rh18mr28474312ejb.136.1628610162441; Tue, 10 Aug 2021 08:42:42 -0700 (PDT) Received: from Keschdeichel.fritz.box ([2001:67c:1560:8007::aac:c4ad]) by smtp.gmail.com with ESMTPSA id ck3sm9729443edb.80.2021.08.10.08.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Aug 2021 08:42:42 -0700 (PDT) From: christian.ehrhardt@canonical.com To: David Marchand Cc: Owen Hilyard , Maxime Coquelin , dpdk stable Date: Tue, 10 Aug 2021 17:39:25 +0200 Message-Id: <20210810154022.749358-45-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810154022.749358-1-christian.ehrhardt@canonical.com> References: <20210810154022.749358-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'ipc: stop mp control thread on cleanup' has been queued to stable release 19.11.10 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.10 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 08/12/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/cpaelzer/dpdk-stable-queue This queued commit can be viewed at: https://github.com/cpaelzer/dpdk-stable-queue/commit/b39b348769f1fe968957001523d57d973ee0eb3c Thanks. Christian Ehrhardt --- >From b39b348769f1fe968957001523d57d973ee0eb3c Mon Sep 17 00:00:00 2001 From: David Marchand Date: Wed, 7 Jul 2021 13:02:29 +0200 Subject: [PATCH] ipc: stop mp control thread on cleanup [ upstream commit e7885281ded1dbda63dcf3f6eb3640131113a6eb ] When calling rte_eal_cleanup, the mp channel cleanup routine only sets mp_fd to -1 leaving the rte_mp_handle control thread running. This control thread can spew warnings on reading on an invalid fd. This is especially noticed with ASAN enabled. To handle this situation, set mp_fd to -1 to signal the control thread it should exit, but since this thread might be sleeping on the socket, cancel the thread too. Fixes: 85d6815fa6d0 ("eal: close multi-process socket during cleanup") Reported-by: Owen Hilyard Signed-off-by: David Marchand Reviewed-by: Maxime Coquelin --- lib/librte_eal/common/eal_common_proc.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index 922569f3f5..ac2ddb01a5 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -34,6 +34,7 @@ #include "eal_internal_cfg.h" static int mp_fd = -1; +static pthread_t mp_handle_tid; static char mp_filter[PATH_MAX]; /* Filter for secondary process sockets */ static char mp_dir_path[PATH_MAX]; /* The directory path for all mp sockets */ static pthread_mutex_t mp_mutex_action = PTHREAD_MUTEX_INITIALIZER; @@ -376,7 +377,7 @@ mp_handle(void *arg __rte_unused) struct mp_msg_internal msg; struct sockaddr_un sa; - while (1) { + while (mp_fd >= 0) { if (read_msg(&msg, &sa) == 0) process_msg(&msg, &sa); } @@ -560,14 +561,11 @@ open_socket_fd(void) } static void -close_socket_fd(void) +close_socket_fd(int fd) { char path[PATH_MAX]; - if (mp_fd < 0) - return; - - close(mp_fd); + close(fd); create_socket_path(peer_name, path, sizeof(path)); unlink(path); } @@ -577,7 +575,6 @@ rte_mp_channel_init(void) { char path[PATH_MAX]; int dir_fd; - pthread_t mp_handle_tid; /* in no shared files mode, we do not have secondary processes support, * so no need to initialize IPC. @@ -636,7 +633,16 @@ rte_mp_channel_init(void) void rte_mp_channel_cleanup(void) { - close_socket_fd(); + int fd; + + if (mp_fd < 0) + return; + + fd = mp_fd; + mp_fd = -1; + pthread_cancel(mp_handle_tid); + pthread_join(mp_handle_tid, NULL); + close_socket_fd(fd); } /** -- 2.32.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-08-10 15:11:14.776332726 +0200 +++ 0045-ipc-stop-mp-control-thread-on-cleanup.patch 2021-08-10 15:11:13.010638042 +0200 @@ -1 +1 @@ -From e7885281ded1dbda63dcf3f6eb3640131113a6eb Mon Sep 17 00:00:00 2001 +From b39b348769f1fe968957001523d57d973ee0eb3c Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit e7885281ded1dbda63dcf3f6eb3640131113a6eb ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -22 +23 @@ - lib/eal/common/eal_common_proc.c | 22 ++++++++++++++-------- + lib/librte_eal/common/eal_common_proc.c | 22 ++++++++++++++-------- @@ -25,5 +26,5 @@ -diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c -index dc4a2efa82..ebd0f6673b 100644 ---- a/lib/eal/common/eal_common_proc.c -+++ b/lib/eal/common/eal_common_proc.c -@@ -35,6 +35,7 @@ +diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c +index 922569f3f5..ac2ddb01a5 100644 +--- a/lib/librte_eal/common/eal_common_proc.c ++++ b/lib/librte_eal/common/eal_common_proc.c +@@ -34,6 +34,7 @@ @@ -37 +38 @@ -@@ -383,7 +384,7 @@ mp_handle(void *arg __rte_unused) +@@ -376,7 +377,7 @@ mp_handle(void *arg __rte_unused) @@ -46 +47 @@ -@@ -567,14 +568,11 @@ open_socket_fd(void) +@@ -560,14 +561,11 @@ open_socket_fd(void) @@ -63 +64 @@ -@@ -584,7 +582,6 @@ rte_mp_channel_init(void) +@@ -577,7 +575,6 @@ rte_mp_channel_init(void) @@ -68,2 +68,0 @@ - const struct internal_config *internal_conf = - eal_get_internal_configuration(); @@ -71 +70,3 @@ -@@ -645,7 +642,16 @@ rte_mp_channel_init(void) + /* in no shared files mode, we do not have secondary processes support, + * so no need to initialize IPC. +@@ -636,7 +633,16 @@ rte_mp_channel_init(void)