DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: stephen@networkplumber.org, hkalra@marvell.com,
	anatoly.burakov@intel.com
Subject: [PATCH v2 12/12] interrupts: warn on leaked event FDs
Date: Sat, 24 Oct 2026 15:21:37 +0200	[thread overview]
Message-ID: <20261024132138.7239-13-david.marchand@redhat.com> (raw)
In-Reply-To: <20261024132138.7239-1-david.marchand@redhat.com>

From: Anatoly Burakov <anatoly.burakov@intel.com>

Extend the leak warning in rte_intr_instance_free() to the event FD
array, in the same way as the handle FD and device FD.

rte_intr_efd_disable() used to close the eventfds it owns but left
the stale descriptors in the array, and never cleared the entry that
merely references the handle FD in the non-MSI-X case.
For all types but VDEV, reset all entries in use to -1 so a properly
disabled handle is not reported.

Drivers filling the event FD array themselves are expected to reset
the entries once the descriptors are closed or no longer referenced.

Suggested-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changes since Anatoly v4:
- added check on type != VDEV when disabling,

---
 lib/eal/common/eal_common_interrupts.c | 5 +++++
 lib/eal/include/rte_interrupts.h       | 7 ++++++-
 lib/eal/linux/eal_interrupts.c         | 9 ++++++---
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/lib/eal/common/eal_common_interrupts.c b/lib/eal/common/eal_common_interrupts.c
index 1208a2597d..f3eee636df 100644
--- a/lib/eal/common/eal_common_interrupts.c
+++ b/lib/eal/common/eal_common_interrupts.c
@@ -167,6 +167,11 @@ void rte_intr_instance_free(struct rte_intr_handle *intr_handle)
 	if (rte_intr_dev_fd_get(intr_handle) >= 0)
 		EAL_LOG(NOTICE, "Some interrupt handle is leaking a device FD: %d",
 			rte_intr_dev_fd_get(intr_handle));
+	for (int i = 0; i < intr_handle->nb_intr; i++) {
+		if (intr_handle->efds[i] >= 0)
+			EAL_LOG(NOTICE, "Some interrupt handle is leaking an event FD: %d (index %d)",
+				intr_handle->efds[i], i);
+	}
 	if (RTE_INTR_INSTANCE_USES_RTE_MEMORY(intr_handle->alloc_flags)) {
 		rte_free(intr_handle->efds);
 		rte_free(intr_handle->elist);
diff --git a/lib/eal/include/rte_interrupts.h b/lib/eal/include/rte_interrupts.h
index bb06180bea..85b5546dee 100644
--- a/lib/eal/include/rte_interrupts.h
+++ b/lib/eal/include/rte_interrupts.h
@@ -389,6 +389,7 @@ rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd);
  * @internal
  * It disables the packet I/O interrupt event.
  * It deletes registered eventfds and closes the open fds.
+ * All event fd entries in use are reset to -1.
  *
  * @param intr_handle
  *   Pointer to the interrupt handle.
@@ -605,12 +606,16 @@ rte_intr_efd_counter_size_get(const struct rte_intr_handle *intr_handle);
  * @internal
  * Set the event fd array index with the given fd.
  *
+ * Entries still holding a valid fd when the instance is freed are reported
+ * as leaks, so callers managing the array themselves must reset entries
+ * to -1 once the fd is closed or no longer referenced.
+ *
  * @param intr_handle
  *  pointer to the interrupt handle.
  * @param index
  *  efds array index to be set
  * @param fd
- *  event fd
+ *  event fd, or -1 to clear the entry
  *
  * @return
  *  - On success, zero.
diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index 73f23c314b..dfe1660dd0 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -1626,17 +1626,20 @@ RTE_EXPORT_INTERNAL_SYMBOL(rte_intr_efd_disable)
 void
 rte_intr_efd_disable(struct rte_intr_handle *intr_handle)
 {
-	uint32_t i;
-
 	rte_intr_free_epoll_fd(intr_handle);
 	/* Only eventfds created by rte_intr_efd_enable() for MSI-X are owned
 	 * by the handle. In other modes the entries reference fds owned by
 	 * the device or the driver and must not be closed here.
 	 */
 	if (rte_intr_type_get(intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX) {
-		for (i = 0; i < (uint32_t)rte_intr_nb_efd_get(intr_handle); i++)
+		for (int i = 0; i < rte_intr_nb_efd_get(intr_handle); i++)
 			close(rte_intr_efds_index_get(intr_handle, i));
 	}
+	/* VDEV is responsible for efds, see rte_intr_efd_enable(). */
+	if (rte_intr_type_get(intr_handle) != RTE_INTR_HANDLE_VDEV) {
+		for (int i = 0; i < rte_intr_nb_efd_get(intr_handle); i++)
+			rte_intr_efds_index_set(intr_handle, i, -1);
+	}
 	rte_intr_nb_efd_set(intr_handle, 0);
 	rte_intr_max_intr_set(intr_handle, 0);
 }
-- 
2.54.0


  parent reply	other threads:[~2026-10-24 13:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21  9:23 [PATCH 0/9] Interrupt fixes for leaks and warnings David Marchand
2026-10-21  9:23 ` [PATCH 1/9] eal/linux: fix FD leak in alarm subsystem David Marchand
2026-10-21  9:23 ` [PATCH 2/9] eal/linux: reset FD in interrupt handle for uevent David Marchand
2026-10-21  9:23 ` [PATCH 3/9] interrupts: do not duplicate interrupt handles David Marchand
2026-10-21  9:23 ` [PATCH 4/9] bus/pci: reset VFIO device FD after release David Marchand
2026-10-21  9:23 ` [PATCH 5/9] net/mana: reset FD in interrupt handle David Marchand
2026-10-21  9:23 ` [PATCH 6/9] net/memif: fix some interrupt FD leaks David Marchand
2026-10-21  9:23 ` [PATCH 7/9] net/memif: reset FD in interrupt handle David Marchand
2026-10-21  9:23 ` [PATCH 8/9] net/sxe2: " David Marchand
2026-10-21  9:23 ` [PATCH 9/9] raw/ifpga: " David Marchand
2026-10-24 13:21 ` [PATCH v2 00/12] Interrupt fixes for leaks and warnings David Marchand
2026-10-24 13:21   ` [PATCH v2 01/12] eal/linux: fix FD leak in alarm subsystem David Marchand
2026-10-24 13:21   ` [PATCH v2 02/12] eal/linux: reset FD in interrupt handle for uevent David Marchand
2026-10-24 14:07     ` Burakov, Anatoly
2026-10-24 13:21   ` [PATCH v2 03/12] interrupts: do not duplicate interrupt handles David Marchand
2026-10-24 14:11     ` Burakov, Anatoly
2026-10-26 15:39       ` David Marchand
2026-10-24 13:21   ` [PATCH v2 04/12] bus/pci: reset VFIO device FD after release David Marchand
2026-10-24 14:11     ` Burakov, Anatoly
2026-10-24 13:21   ` [PATCH v2 05/12] net/mana: reset FD in interrupt handle David Marchand
2026-10-24 13:21   ` [PATCH v2 06/12] net/memif: fix some interrupt FD leaks David Marchand
2026-10-24 13:21   ` [PATCH v2 07/12] net/memif: reset FD in interrupt handle David Marchand
2026-10-24 13:21   ` [PATCH v2 08/12] net/sxe2: " David Marchand
2026-10-24 13:21   ` [PATCH v2 09/12] raw/ifpga: " David Marchand
2026-10-24 13:21   ` [PATCH v2 10/12] eal/linux: fix closing of event FDs not owned by EAL David Marchand
2026-10-24 13:21   ` [PATCH v2 11/12] eal/linux: fix eventfd leaks when enabling interrupts David Marchand
2026-10-24 13:21   ` David Marchand [this message]
2026-10-27 17:16   ` [PATCH v2 00/12] Interrupt fixes for leaks and warnings David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261024132138.7239-13-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=hkalra@marvell.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox