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 DABF6A0524; Sun, 2 May 2021 04:33:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 945D941110; Sun, 2 May 2021 04:33:44 +0200 (CEST) Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) by mails.dpdk.org (Postfix) with ESMTP id 9F59540692; Sun, 2 May 2021 04:33:43 +0200 (CEST) Received: by mail-lf1-f52.google.com with SMTP id 124so2997206lff.5; Sat, 01 May 2021 19:33:43 -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=OIkV9lF5P4FL0Qog325tf+flJAw1LR3JAkiHJ8u2jeI=; b=MrWk/nqp2NPjTUWB38mp9JacRmBi1ygp3CMhfQNraBmt940+6/TgWxuqIG6vbL5SDx 5ZS+ynMxBjOQ7ihfaUogjyYhqQNcko31OEljfe7dH6u7CAP6IL46sYqMNvsoZJKenz/8 v9wu4tj7yMpWVKSecvjZif2wr7+y29dAhE4fWk5BCjY96eiTsPPiRL6spe83s3cYrYLF X9+Bv0PZgF/h5oAxOMOERkFo89bFePShrPK+yBy7OZIUplmb7CdRVOA15DQDTHzFSGcD cJJA1pOlSsJCNF+jUnSinlUH0i2kZL+aa6KSomygKaNmDTZ7C7D3420+jlKqX12zENxf 6P+Q== 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=OIkV9lF5P4FL0Qog325tf+flJAw1LR3JAkiHJ8u2jeI=; b=ay7SZUByn2oZ6B8JibXYIgotyP8Fbt5F1GB9i8tHTFM2VI0l/UtqvF2K4QYa7OMY3s TBGX8NbgZHMQw48r7hLqX7RmSINJytN4XWwzG9dwcwECpWK0cAim4tJLxs3DvagwP+BU eGXzrIwaElZk9Q+mHnq1a3sXBAr3oldhmjBUPizPQV3TV1VuSQFuSh6qYSAfZ4zkHtgQ ZaZCcpmRFvm/tSijtKCzoXS9IepmcgWAFVfOymddCzxMjvsYsBzCZ526z6h9pJx/2bY2 Coe6du5eozRHw4On9gMwZitDxJ++NNFi7nqgq1k70LCrrZUn1xIVaj75QwBqQa7+AX0w J5fw== X-Gm-Message-State: AOAM531ohL5LSPYclQK2BgX2qR2MfXIkeFTCWn0+0i/2m0YwMl+DcBH3 jBKePgl1Fi/Ben/Le/BVHGm6JoJCgpuNAg== X-Google-Smtp-Source: ABdhPJyg8x3cee63iCO9vf7epQ3P6toQpZ3QaatIMcD+KQt3NwrkyUMGquuDnurw5+qbiikTKxfBSg== X-Received: by 2002:a19:c218:: with SMTP id l24mr8738559lfc.529.1619922823018; 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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 19:33:42 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , stable@dpdk.org, Harman Kalra , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Sun, 2 May 2021 05:33:32 +0300 Message-Id: <20210502023333.30351-2-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-dev] [PATCH 2/3] eal/windows: fix interrupt thread handle leakage 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 Sender: "dev" Each time a work was scheduled in the interrupt thread, usually an alarm, a handle was opened but not closed. Opening a handle is a system call, which harms alarm precision. Instead of opening and closing a handle each time, open it when interrupt thread starts and close it when the thread finishes. Fixes: 5c016fc0205a ("eal/windows: add interrupt thread skeleton") Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk --- lib/eal/windows/eal_interrupts.c | 34 +++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/eal/windows/eal_interrupts.c b/lib/eal/windows/eal_interrupts.c index 9cde02b003..f24ed6e54e 100644 --- a/lib/eal/windows/eal_interrupts.c +++ b/lib/eal/windows/eal_interrupts.c @@ -10,6 +10,7 @@ static pthread_t intr_thread; static HANDLE intr_iocp; +static HANDLE intr_thread_handle; static void eal_intr_process(const OVERLAPPED_ENTRY *event) @@ -17,9 +18,27 @@ eal_intr_process(const OVERLAPPED_ENTRY *event) RTE_SET_USED(event); } +static int +eal_intr_thread_handle_init(void) +{ + DWORD thread_id = GetCurrentThreadId(); + + intr_thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, thread_id); + if (intr_thread_handle == NULL) { + RTE_LOG_WIN32_ERR("OpenThread(%lu)", thread_id); + return -1; + } + return 0; +} + static void * eal_intr_thread_main(LPVOID arg __rte_unused) { + if (eal_intr_thread_handle_init() < 0) { + RTE_LOG(ERR, EAL, "Cannot open interrupt thread handle\n"); + goto cleanup; + } + while (1) { OVERLAPPED_ENTRY events[16]; ULONG event_count, i; @@ -46,6 +65,10 @@ eal_intr_thread_main(LPVOID arg __rte_unused) eal_intr_process(&events[i]); } + CloseHandle(intr_thread_handle); + intr_thread_handle = NULL; + +cleanup: intr_thread = 0; CloseHandle(intr_iocp); @@ -93,15 +116,8 @@ rte_intr_rx_ctl(__rte_unused struct rte_intr_handle *intr_handle, int eal_intr_thread_schedule(void (*func)(void *arg), void *arg) { - HANDLE handle; - - handle = OpenThread(THREAD_ALL_ACCESS, FALSE, intr_thread); - if (handle == NULL) { - RTE_LOG_WIN32_ERR("OpenThread(%llu)", intr_thread); - return -ENOENT; - } - - if (!QueueUserAPC((PAPCFUNC)(ULONG_PTR)func, handle, (ULONG_PTR)arg)) { + if (!QueueUserAPC((PAPCFUNC)(ULONG_PTR)func, + intr_thread_handle, (ULONG_PTR)arg)) { RTE_LOG_WIN32_ERR("QueueUserAPC()"); return -EINVAL; } -- 2.29.3