[PATCH v2 2/3] interrupts: warn on leaked event FDs
Anatoly Burakov
anatoly.burakov at intel.com
Fri Oct 23 15:07:43 CEST 2026
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. 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 at redhat.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
lib/eal/common/eal_common_interrupts.c | 5 +++++
lib/eal/include/rte_interrupts.h | 7 ++++++-
lib/eal/linux/eal_interrupts.c | 2 ++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/lib/eal/common/eal_common_interrupts.c b/lib/eal/common/eal_common_interrupts.c
index 6368ef17714..41fe4286558 100644
--- a/lib/eal/common/eal_common_interrupts.c
+++ b/lib/eal/common/eal_common_interrupts.c
@@ -193,6 +193,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 d04c0c7b15f..3aeac9092ae 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.
@@ -620,12 +621,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 bdee1dd9777..17fe443982b 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -1628,6 +1628,8 @@ rte_intr_efd_disable(struct rte_intr_handle *intr_handle)
for (i = 0; i < (uint32_t)rte_intr_nb_efd_get(intr_handle); i++)
close(rte_intr_efds_index_get(intr_handle, i));
}
+ for (i = 0; i < (uint32_t)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.52.0
More information about the dev
mailing list