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 196E1A0C4A for ; Wed, 7 Jul 2021 13:03:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A20D41373; Wed, 7 Jul 2021 13:03:04 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id C839C406B4 for ; Wed, 7 Jul 2021 13:03:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625655781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MCgAuZAO1sX9OUcFeouaTY7Y3K04JpVvQP//xIq9Inw=; b=IBiRDmdDaC2lCmWn++PnJbiFf6N0HOPdxOqgH6Tdk1v63vfzhrCZnODNJby5AT8Jx6ah3I FuiVZ4VZZrvv/Ox9tR90BW5gkXK/DNZJhWP66JweA8pzbSl8D7UG7x1C6MVgFj1AFwIxvW p+z699yWfWmgjDGvTG0s3LFveC+QOYc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-rKDyCUW-MY656s-UbLbU0g-1; Wed, 07 Jul 2021 07:02:59 -0400 X-MC-Unique: rKDyCUW-MY656s-UbLbU0g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 344B6800050; Wed, 7 Jul 2021 11:02:58 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5679419C45; Wed, 7 Jul 2021 11:02:56 +0000 (UTC) From: David Marchand To: dev@dpdk.org, anatoly.burakov@intel.com Cc: ohilyard@iol.unh.edu, stable@dpdk.org, Qi Zhang Date: Wed, 7 Jul 2021 13:02:29 +0200 Message-Id: <20210707110230.8695-1-david.marchand@redhat.com> In-Reply-To: <20210614091213.3953-1-david.marchand@redhat.com> References: <20210614091213.3953-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-stable] [PATCH v2] ipc: stop mp control thread on cleanup 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" 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") Cc: stable@dpdk.org Reported-by: Owen Hilyard Signed-off-by: David Marchand --- Changes since v1: - no functional change, but left close_socket_fd() helper to keep symmetry with rte_mp_channel_init()/open_socket_fd(), --- lib/eal/common/eal_common_proc.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) 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 @@ #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; @@ -383,7 +384,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); } @@ -567,14 +568,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); } @@ -584,7 +582,6 @@ rte_mp_channel_init(void) { char path[PATH_MAX]; int dir_fd; - pthread_t mp_handle_tid; const struct internal_config *internal_conf = eal_get_internal_configuration(); @@ -645,7 +642,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.23.0