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 06985A0524 for ; Sun, 2 May 2021 04:33:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BC41D4113C; Sun, 2 May 2021 04:33:45 +0200 (CEST) Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by mails.dpdk.org (Postfix) with ESMTP id 8E1CB4110B; Sun, 2 May 2021 04:33:44 +0200 (CEST) Received: by mail-lj1-f173.google.com with SMTP id p12so2786118ljg.1; Sat, 01 May 2021 19:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HObbVr9jgvknTt2fY6BcYddgNt9hTercuLIdk6hNN7Y=; b=X06i5q7UG/J9kxTNEr2/BWWkdxHe7Wq8EbmSuJ3/RUDL1l3Gerwqde74483X74rNa3 J7VhG9g7Nm0jiAcW7J/SwO1Pj8DJKSwdGP1JXXry/p5ZAqK2PvmDF2KfGIzcieDV0pzQ vnSrZIjQKTBdipfulI/E1BXNWyl6R02BGnb8CIuJj9uXt83Zsr2z8lLCdYH2XvbsOzoz dcU+h2Xp/wZHmlsHmolFkr87fQM7f6uJb8MwQxTBA+rSTTTunaMl4XXbRLvYqWOYD4Xw tyWMR9ctgEdc5cIdAeUASn8mLsYFdrs5CrI2XqIubcRjZKfyCcksYB5dh0zKy9cufru/ RKKw== 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=HObbVr9jgvknTt2fY6BcYddgNt9hTercuLIdk6hNN7Y=; b=nbYRtSlmTcZbFz1ec8CCGxo9yL4uzgZvOFYilYDUCOksg0vzwmr8VABkVUxNU0yALq PkFerHb4N5F21Hsnn1UlzUM8ekBbX9xZQkgdYtDoRo5Q8b9w1mLdMy62PF2F8eJ/4Z54 /+Ts7V6zVsFwHuDBwpLooHjYiUUCthmBOdssSoUpBYEIc+Pn7KA3E+VjnpQcqr89pw02 4l2x7d65ji4JqvXJjCn6mlq11+qgJbAc6m1gQ3WLx6rb02oqG3Ql8meFuERbTCiE9nM6 rVUDO/19sKRgcTgGSID4BP/PO8TLWNlILNnuEsPGM2iQTmMIFC0TwsdnhsEAq/I2LoBE AN7A== X-Gm-Message-State: AOAM5332FaaMzJmcW73nGRUvUYzrCLmkOVR+BGfFO9J31W90DwpCN+HZ HNdaNeghs09zklkZ7u+U4SHwG0PkebN0PA== X-Google-Smtp-Source: ABdhPJy42cYLzXdW/EO+NVz2PcbeYEaagEMXS976jdMxxfKSVdNoGfsb2cwh0B3/ZyLqPkJOVB3eng== X-Received: by 2002:a2e:1409:: with SMTP id u9mr8644128ljd.155.1619922823897; Sat, 01 May 2021 19:33:43 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id w26sm716970lfn.82.2021.05.01.19.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 19:33:43 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , stable@dpdk.org, Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam , Harman Kalra Date: Sun, 2 May 2021 05:33:33 +0300 Message-Id: <20210502023333.30351-3-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210502023333.30351-1-dmitry.kozliuk@gmail.com> References: <20210502023333.30351-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH 3/3] eal/windows: cleanup interrupt resources 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" Interrupt manager in Windows EAL allocates on IOCP and starts a control thread that runs indefinitely. At DPDK cleanup this thread was not stopped and IOCP handle was not closed. Gracefully stop interrupt-handling in rte_eal_cleanup(). The thread already closes IOCP handle before exiting. Fixes: 5c016fc0205a ("eal/windows: add interrupt thread skeleton") Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk --- lib/eal/windows/eal.c | 1 + lib/eal/windows/eal_interrupts.c | 26 ++++++++++++++++++++++++-- lib/eal/windows/eal_windows.h | 5 +++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index 28c787c0b0..25afc42f8e 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -258,6 +258,7 @@ rte_eal_cleanup(void) { struct internal_config *internal_conf = eal_get_internal_configuration(); + eal_intr_thread_cancel(); /* after this point, any DPDK pointers will become dangling */ rte_eal_memory_detach(); eal_cleanup_config(internal_conf); diff --git a/lib/eal/windows/eal_interrupts.c b/lib/eal/windows/eal_interrupts.c index f24ed6e54e..bb0585cb34 100644 --- a/lib/eal/windows/eal_interrupts.c +++ b/lib/eal/windows/eal_interrupts.c @@ -7,6 +7,8 @@ #include "eal_private.h" #include "eal_windows.h" +#define IOCP_KEY_SHUTDOWN UINT32_MAX + static pthread_t intr_thread; static HANDLE intr_iocp; @@ -34,12 +36,14 @@ eal_intr_thread_handle_init(void) static void * eal_intr_thread_main(LPVOID arg __rte_unused) { + bool finished = false; + if (eal_intr_thread_handle_init() < 0) { RTE_LOG(ERR, EAL, "Cannot open interrupt thread handle\n"); goto cleanup; } - while (1) { + while (!finished) { OVERLAPPED_ENTRY events[16]; ULONG event_count, i; BOOL result; @@ -61,8 +65,13 @@ eal_intr_thread_main(LPVOID arg __rte_unused) continue; } - for (i = 0; i < event_count; i++) + for (i = 0; i < event_count; i++) { + if (events[i].lpCompletionKey == IOCP_KEY_SHUTDOWN) { + finished = true; + break; + } eal_intr_process(&events[i]); + } } CloseHandle(intr_thread_handle); @@ -125,6 +134,19 @@ eal_intr_thread_schedule(void (*func)(void *arg), void *arg) return 0; } +void +eal_intr_thread_cancel(void) +{ + if (!PostQueuedCompletionStatus( + intr_iocp, 0, IOCP_KEY_SHUTDOWN, NULL)) { + RTE_LOG_WIN32_ERR("PostQueuedCompletionStatus()"); + RTE_LOG(ERR, EAL, "Cannot cancel interrupt thread\n"); + return; + } + + WaitForSingleObject(intr_thread_handle, INFINITE); +} + int rte_intr_callback_register( __rte_unused const struct rte_intr_handle *intr_handle, diff --git a/lib/eal/windows/eal_windows.h b/lib/eal/windows/eal_windows.h index 478accc1b9..7cc811485d 100644 --- a/lib/eal/windows/eal_windows.h +++ b/lib/eal/windows/eal_windows.h @@ -67,6 +67,11 @@ unsigned int eal_socket_numa_node(unsigned int socket_id); */ int eal_intr_thread_schedule(void (*func)(void *arg), void *arg); +/** + * Request interrupt thread to stop and wait its termination. + */ +void eal_intr_thread_cancel(void); + /** * Open virt2phys driver interface device. * -- 2.29.3