From: Leon Romanovsky <leon@kernel.org>
To: Dezhen Lu <dinadegttyarenko6@gmail.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: tests: CUDA DMA-BUF resources leave exported descriptors open
Date: Mon, 9 Nov 2026 14:13:34 +0200 [thread overview]
Message-ID: <20261109121334.GE8635@unreal> (raw)
In-Reply-To: <CC55B377-CDCB-4293-8644-602B54B28B18@gmail.com>
On Wed, Nov 04, 2026 at 08:48:09PM +0100, Dezhen Lu wrote:
> Hello,
>
> At rdma-core master a70151dfec390eb5f7fc5b266f51d601da2a7778,
> the CUDA DMA-BUF test resources obtain an FD from
> cuMemGetHandleForAddressRange but do not close it after registration.
> This affects DmabufCudaRes, MRExDmabufCudaRes,
> MRExDmabufDmaHCudaRes, and Mlx5DmabufCudaRes. It occurs on successful
> registration and on failures or skips after the FD is obtained. The
> integer FD passed to the pyverbs MR constructor is caller-owned.
>
> The following uses a real process FD and a mocked constructor to
> exercise the first resource method without requiring a CUDA GPU or RDMA
> device. Run it from a checkout with an in-place pyverbs build:
>
> ```sh
> PYTHONPATH=build/python:tests python3 - <<'PY'
> import errno
> import os
> import sys
> from types import SimpleNamespace
> from unittest.mock import patch
>
> sys.path.append(sys.path.pop(0)) # Prefer the built pyverbs over the source directory.
> import tests.test_cuda_dmabuf as test
>
> fd = os.open('/dev/null', os.O_RDONLY)
> res = SimpleNamespace(pd=object(), msg_size=64, mr_access=1,
> dmabuf_cuda_init=lambda: fd)
> try:
> with patch.object(test, 'DmaBufMR', return_value=object()):
> test.DmabufCudaRes.create_mr(res)
> try:
> os.fstat(fd)
> except OSError as exc:
> if exc.errno != errno.EBADF:
> raise
> print('descriptor closed')
> else:
> print('descriptor still open')
> finally:
> try:
> os.close(fd)
> except OSError as exc:
> if exc.errno != errno.EBADF:
> raise
> PY
> ```
>
> Observed: descriptor still open. Expected: descriptor closed after
> registration returns, including on error. A proposed fix closes it in a
> finally block around registration and, for the DMAHandle path, around
> handle creation as well. On Linux the RDMA DMA-BUF registration path
> acquires its own buffer reference.
Please open PR against rdma-core with your fix for both test reports.
Thanks
prev parent reply other threads:[~2026-11-09 12:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 19:48 tests: CUDA DMA-BUF resources leave exported descriptors open Dezhen Lu
2026-11-09 12:13 ` Leon Romanovsky [this message]
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=20261109121334.GE8635@unreal \
--to=leon@kernel.org \
--cc=dinadegttyarenko6@gmail.com \
--cc=linux-rdma@vger.kernel.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