From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 8D623A0C41
	for <public@inbox.dpdk.org>; Tue, 11 May 2021 19:24:22 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 82980410F4;
	Tue, 11 May 2021 19:24:22 +0200 (CEST)
Received: from mga02.intel.com (mga02.intel.com [134.134.136.20])
 by mails.dpdk.org (Postfix) with ESMTP id BF4834003E;
 Tue, 11 May 2021 19:24:19 +0200 (CEST)
IronPort-SDR: Z5jdMo34J8lk+l4AM8M8Srd3f6kJWKe1UTe5kMiqrfqdUw+3/WgRSkgwcOL7Fl8levqgva7/We
 mjVH2UdSh3RQ==
X-IronPort-AV: E=McAfee;i="6200,9189,9981"; a="186636569"
X-IronPort-AV: E=Sophos;i="5.82,291,1613462400"; d="scan'208";a="186636569"
Received: from orsmga008.jf.intel.com ([10.7.209.65])
 by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 11 May 2021 10:24:18 -0700
IronPort-SDR: 1E6SuQr5czhPirsUl+ul4rlcriFYSbiAU7wyF4G8WkQUZdmUjZfnlWfWlhqqxc9bMy8Xy+2Fj5
 gm5wqQRluCiw==
X-IronPort-AV: E=Sophos;i="5.82,291,1613462400"; d="scan'208";a="436766298"
Received: from rmenon-desk.amr.corp.intel.com (HELO [10.166.30.253])
 ([10.166.30.253])
 by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 11 May 2021 10:24:18 -0700
To: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>, dev@dpdk.org
Cc: stable@dpdk.org, Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>, 
 Dmitry Malloy <dmitrym@microsoft.com>,
 Pallavi Kadam <pallavi.kadam@intel.com>, Harman Kalra <hkalra@marvell.com>
References: <20210502023333.30351-1-dmitry.kozliuk@gmail.com>
 <20210502023333.30351-3-dmitry.kozliuk@gmail.com>
From: Ranjit Menon <ranjit.menon@intel.com>
Message-ID: <55c8037c-03d7-3f88-47f3-c0fe9a3ccd4c@intel.com>
Date: Tue, 11 May 2021 10:24:18 -0700
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
 Thunderbird/68.12.1
MIME-Version: 1.0
In-Reply-To: <20210502023333.30351-3-dmitry.kozliuk@gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
Subject: Re: [dpdk-stable] [dpdk-dev] [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 <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org
Sender: "stable" <stable-bounces@dpdk.org>


On 5/1/2021 7:33 PM, Dmitry Kozlyuk wrote:
> 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 <dmitry.kozliuk@gmail.com>
> ---
>   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();
A blank line above this line would be nice.
>   	/* 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.
>    *

Other than nit above,

Acked-by: Ranjit Menon <ranjit.menon@intel.com>