Re: [RFC 3/4] interrupts: mark file descriptors invalid on allocation
David Marchand <[email protected]> Fri, 24 Jul 2026 14:16:43 +0200
| Newsgroups | org.dpdk.dev |
|---|---|
| Message-ID | <CAJFAV8w9iUsP3z_3X0kRKe=zRpS26YBP7WegZ4gQBKJGVRe9FA@mail.gmail.com> |
On Thu, 23 Jul 2026 at 15:19, David Marchand <[email protected]> wrote: > > Initialize fd, dev_fd, and all efds array elements as invalid in > rte_intr_instance_alloc(). > This follows Unix convention, avoiding confusion with fd 0 > which could result from zero-initialization. > > Update the API documentation to reflect this behavior and add a > unit test check to verify the fd is invalid after allocation. > > Remove now-redundant initialization calls that were setting the fd > invalid right after allocation. > > Signed-off-by: David Marchand <[email protected]> > --- > app/test/test_interrupts.c | 5 +++-- > doc/guides/rel_notes/release_26_11.rst | 5 +++++ > drivers/bus/cdx/cdx_vfio.c | 6 ------ > drivers/bus/pci/linux/pci_vfio.c | 11 ----------- > drivers/bus/pci/pci_common_uio.c | 6 ------ > drivers/bus/vmbus/vmbus_common_uio.c | 6 ------ > drivers/net/failsafe/failsafe.c | 3 --- > drivers/net/mana/mana.c | 4 ---- > drivers/net/memif/rte_eth_memif.c | 6 ------ > drivers/net/mlx4/mlx4.c | 3 --- > drivers/net/tap/rte_eth_tap.c | 1 - > lib/eal/common/eal_common_interrupts.c | 6 ++++++ > lib/eal/freebsd/eal_alarm.c | 3 --- > lib/eal/include/rte_interrupts.h | 2 ++ > lib/eal/linux/eal_dev.c | 4 ---- > 15 files changed, 16 insertions(+), 55 deletions(-) > > diff --git a/app/test/test_interrupts.c b/app/test/test_interrupts.c > index 3a5be92cd7..5901cec2fe 100644 > --- a/app/test/test_interrupts.c > +++ b/app/test/test_interrupts.c > @@ -73,11 +73,12 @@ test_interrupt_init(void) > rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE); > if (!intr_handles[i]) > return -1; > + /* Verify fd is initialized to -1 */ > + if (rte_intr_fd_get(intr_handles[i]) != -1) > + return -1; > } > > test_intr_handle = intr_handles[TEST_INTERRUPT_HANDLE_INVALID]; > - if (rte_intr_fd_set(test_intr_handle, -1)) > - return -1; > if (rte_intr_type_set(test_intr_handle, RTE_INTR_HANDLE_UNKNOWN)) > return -1; > An "interesting" failure came from the unit test. The unit test does not set a dev_fd in its simulated interrupt handles. However, Linux implementation in rte_intr_enable(), rte_intr_ack() and rte_intr_disable() enforce that a valid dev_fd is set. So the unit test for RTE_INTR_HANDLE_UIO type was passing so far because the interrupt handler contained a valid 0 dev fd... that was unused in EAL in RTE_INTR_HANDLE_UIO only. None of the other UIO and VFIO types (that do need a dev_fd) are covered by the unit test. On the other hand, actual usage of RTE_INTR_HANDLE_UIO type in the PCI bus driver does set a dev_fd. drivers/bus/pci/linux/pci_uio.c- uio_cfg_fd = open(cfgname, O_RDWR); drivers/bus/pci/linux/pci_uio.c- if (uio_cfg_fd < 0) { drivers/bus/pci/linux/pci_uio.c- PCI_LOG(ERR, "Cannot open %s: %s", cfgname, strerror(errno)); drivers/bus/pci/linux/pci_uio.c- goto error; drivers/bus/pci/linux/pci_uio.c- } drivers/bus/pci/linux/pci_uio.c- drivers/bus/pci/linux/pci_uio.c- if (rte_intr_dev_fd_set(dev->intr_handle, uio_cfg_fd)) drivers/bus/pci/linux/pci_uio.c- goto error; drivers/bus/pci/linux/pci_uio.c- drivers/bus/pci/linux/pci_uio.c- if (dev->kdrv == RTE_PCI_KDRV_IGB_UIO) { drivers/bus/pci/linux/pci_uio.c: if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_UIO)) I'd lean towards removing the funky UIO part of the unit test. Opinion? -- David Marchand