DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org, Harman Kalra <hkalra@marvell.com>,
	Cunming Liang <cunming.liang@intel.com>
Subject: [PATCH v3 3/8] eal/linux: fix closing of event FDs not owned by EAL
Date: Fri, 23 Oct 2026 14:39:10 +0100	[thread overview]
Message-ID: <114fb88b2991c0e88b11d46b671d858c9e6cefdd.1792762746.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <e9eba9cd731a90f6e487a76bfe3bee84b1cdc3de.1792762746.git.anatoly.burakov@intel.com>

rte_intr_efd_disable() decides whether to close the event FDs based on
max_intr being greater than nb_efd. This is a side effect of how
rte_intr_efd_enable() fills the handle for VFIO MSI-X, where an extra
slot is reserved for the misc interrupt, and only indirectly identifies
the eventfds that EAL created itself.

Any driver filling the event FD array for a VDEV or EXT handle and
setting max_intr the same way gets its descriptors closed by EAL even
though it owns them. The virtio-user driver does exactly this, so its
callfds are closed by rte_intr_efd_disable() and then closed again by
the driver on uninit.

Check the interrupt handle type instead, so that only the eventfds
created by rte_intr_efd_enable() for VFIO MSI-X are closed.

Fixes: b9e0662a931d ("eal/linux: add interrupt API for drivers")
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/eal/linux/eal_interrupts.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index 4cfaeba7fe0..bdee1dd9777 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -1620,7 +1620,11 @@ rte_intr_efd_disable(struct rte_intr_handle *intr_handle)
 	uint32_t i;
 
 	rte_intr_free_epoll_fd(intr_handle);
-	if (rte_intr_max_intr_get(intr_handle) > rte_intr_nb_efd_get(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++)
 			close(rte_intr_efds_index_get(intr_handle, i));
 	}
-- 
2.52.0


  parent reply	other threads:[~2026-10-23 13:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23  9:36 [PATCH v1 1/1] eal/linux: fix eventfd leaks when enabling interrupts Anatoly Burakov
2026-10-23 11:42 ` David Marchand
2026-10-23 12:25   ` Burakov, Anatoly
2026-10-23 13:07 ` [PATCH v2 1/3] eal/linux: fix closing of event FDs not owned by EAL Anatoly Burakov
2026-10-23 13:07   ` [PATCH v2 2/3] interrupts: warn on leaked event FDs Anatoly Burakov
2026-10-23 13:07   ` [PATCH v2 3/3] eal/linux: fix eventfd leaks when enabling interrupts Anatoly Burakov
2026-10-23 13:39 ` [PATCH v3 1/8] interrupts: fix size of duplicated instance Anatoly Burakov
2026-10-23 13:39   ` [PATCH v3 2/8] interrupts: fix event arrays copy on instance duplication Anatoly Burakov
2026-10-23 13:39   ` Anatoly Burakov [this message]
2026-10-23 13:39   ` [PATCH v3 4/8] eal/linux: fix eventfd leaks when enabling interrupts Anatoly Burakov
2026-10-23 13:39   ` [PATCH v3 5/8] eal/linux: fix leaked FD warnings for interrupt sources Anatoly Burakov
2026-10-23 13:39   ` [PATCH v3 6/8] eal/freebsd: fix interrupt source handle leak Anatoly Burakov
2026-10-23 13:39   ` [PATCH v3 7/8] bus/pci: fix leaked device FD warning on VFIO unmap Anatoly Burakov
2026-10-23 13:49     ` Burakov, Anatoly
2026-10-23 13:39   ` [PATCH v3 8/8] interrupts: warn on leaked event FDs Anatoly Burakov
2026-10-23 13:51 ` [PATCH v4 1/8] interrupts: fix size of duplicated instance Anatoly Burakov
2026-10-23 13:51   ` [PATCH v4 2/8] interrupts: fix event arrays copy on instance duplication Anatoly Burakov
2026-10-23 14:15     ` David Marchand
2026-10-23 14:36       ` Burakov, Anatoly
2026-10-23 14:44         ` David Marchand
2026-10-23 14:55           ` Burakov, Anatoly
2026-10-23 13:51   ` [PATCH v4 3/8] eal/linux: fix closing of event FDs not owned by EAL Anatoly Burakov
2026-10-23 14:17     ` David Marchand
2026-10-23 13:51   ` [PATCH v4 4/8] eal/linux: fix eventfd leaks when enabling interrupts Anatoly Burakov
2026-10-23 14:37     ` David Marchand
2026-10-23 13:51   ` [PATCH v4 5/8] eal/linux: fix leaked FD warnings for interrupt sources Anatoly Burakov
2026-10-23 13:51   ` [PATCH v4 6/8] eal/freebsd: fix interrupt source handle leak Anatoly Burakov
2026-10-23 13:51   ` [PATCH v4 7/8] bus/pci: fix leaked device FD warning on VFIO unmap Anatoly Burakov
2026-10-23 13:51   ` [PATCH v4 8/8] interrupts: warn on leaked event FDs Anatoly Burakov
2026-10-23 14:41     ` David Marchand
2026-10-23 14:48       ` Burakov, Anatoly
2026-10-24  8:56         ` David Marchand
2026-10-24  9:57           ` Burakov, Anatoly

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=114fb88b2991c0e88b11d46b671d858c9e6cefdd.1792762746.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=cunming.liang@intel.com \
    --cc=dev@dpdk.org \
    --cc=hkalra@marvell.com \
    /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