From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ED0B5A04DD; Sat, 4 Jan 2020 02:34:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A30DC1D54A; Sat, 4 Jan 2020 02:34:05 +0100 (CET) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 809AD1D535 for ; Sat, 4 Jan 2020 02:33:59 +0100 (CET) Received: by mail-pg1-f196.google.com with SMTP id k3so24154316pgc.3 for ; Fri, 03 Jan 2020 17:33:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T5LXB1s2UIxR34Xe2jU+wA9i8ygptxAvHQpIZVUagwo=; b=cK66938/ByAJwYxyIApqtg+/aP18KNQaZzKj9rzuNnjoSsTuSQkf7Q+7n6utactIVA /7k9EIlGo1zeVhwmhwMsmn75fdQnANnpmakEyL3fUVRcL8LUUk4psgqsGa3LRJqb1qFF XuF/fzAmruyaNwGD+QQXozrA4qAkDzxqlagVgKdMA63YFKj36tbzpoD4rkjIon6bf92b emc5yX+HT/SH76I0T16nI7TTi57Xsn57vCARyEs7OW4zCoKrPIrn1g2VCDyNOHziiFUA hizal5xPyL9M8BHNAHyXE8lXcfRqAFmXKAnGO0oLgjV8oLYp92d6dOpVCp9AYwhuLn6K cI5g== 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=T5LXB1s2UIxR34Xe2jU+wA9i8ygptxAvHQpIZVUagwo=; b=PD99Jc+ApUlmY7h2wk7lzuU9AaG0pTOdnxNkob1EMR8duH7dI40CObkirQDI3q/JUg kkZZlSONOi5CL1UUa7C/s/fJI0Mkrb0VxHGtQWiL+oawqaQC0Gj5tCP6SkHnTf30UtWG Y2J3y/T5PZ3WdkfogxwLzmRsA9FimfXudeOOv3Y9fJbzp6EKn4YbU6M7IXD85Z9v0QRD YxSNgRlOCDOU0uhtQIV+sQFUai/bzKrdK5rng3KbSHeaM5dJKFIl6ollOP/1YRIkxphe zbjPbdCuIF2N4IVJQfcOKq7eg1ja2AsVnf03PNZKWcVOslnc0WcVNtzAOIotwl0QSb9B g66A== X-Gm-Message-State: APjAAAXTeEdvTpQbxUTib0IbGSxhrgbfuOq5K6vS7oOStKwwxWiP1bUD aLDugFqwin9Vwk0Au/rjqT2icXGVHzA= X-Google-Smtp-Source: APXvYqzxjzcmTnP0eJaixr/giorA1QWAWnHZXRphLNa/Fb+u3wvi61ute3fhsKvV3uH75QQLLza0mw== X-Received: by 2002:a63:534d:: with SMTP id t13mr94905828pgl.89.1578101638256; Fri, 03 Jan 2020 17:33:58 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j6sm16212934pjv.10.2020.01.03.17.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 17:33:57 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 3 Jan 2020 17:33:34 -0800 Message-Id: <20200104013341.19809-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200104013341.19809-1-stephen@networkplumber.org> References: <20200104013341.19809-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 07/14] eal: interrupts close epoll fd on shutdown X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Use pthread callbacks to ensure that the epoll fd is closed when rte_eal_cleanup is called. Signed-off-by: Stephen Hemminger --- lib/librte_eal/linux/eal/eal_interrupts.c | 26 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/linux/eal/eal_interrupts.c b/lib/librte_eal/linux/eal/eal_interrupts.c index fa08ac4171bd..ae4d3ae3ed60 100644 --- a/lib/librte_eal/linux/eal/eal_interrupts.c +++ b/lib/librte_eal/linux/eal/eal_interrupts.c @@ -1032,6 +1032,19 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds) } } + +/** + * Callback at end of intr_thread loop or if thread is cancelled + * that closes the epoll file descriptor + */ +static void +eal_intr_thread_close(void *arg) +{ + int pfd = (int)(unsigned long)arg; + + close(pfd); +} + /** * It builds/rebuilds up the epoll file descriptor with all the * file descriptors being waited on. Then handles the interrupts. @@ -1061,6 +1074,12 @@ eal_intr_thread_main(__rte_unused void *arg) if (pfd < 0) rte_panic("Cannot create epoll instance\n"); + /* close pfd on thread exit or cancel_pop + * see man page for restrictions on this macro. + */ + pthread_cleanup_push(eal_intr_thread_close, + (void *)(unsigned long)pfd); + pipe_event.data.fd = intr_pipe.readfd; /** * add pipe fd into wait list, this pipe is used to @@ -1100,11 +1119,8 @@ eal_intr_thread_main(__rte_unused void *arg) /* serve the interrupt */ eal_intr_handle_interrupts(pfd, numfds); - /** - * when we return, we need to rebuild the - * list of fds to monitor. - */ - close(pfd); + /* close pfd and rebuild the list */ + pthread_cleanup_pop(1); } } -- 2.20.1