From: sashiko-bot@kernel.org
To: "Zhiping Zhang" <zhipingz@meta.com>
Cc: linux-pci@vger.kernel.org, kvm@vger.kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v13 5/5] RDMA/mlx5: get tph for p2p access when registering dma-buf mr
Date: Fri, 31 Jul 2026 21:48:20 +0000 [thread overview]
Message-ID: <20260731214821.2A9AA1F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260731211601.3033906-6-zhipingz@meta.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] mlx5_st_dealloc_index leaks the idx_data struct when erasing it from the xarray.
--
--- Patch [5]: [PATCH v13 5/5] RDMA/mlx5: get tph for p2p access when registering dma-buf mr ---
commit cb1e1bfb29faeb4a7f3d550176e3590d73486a3e
Author: Zhiping Zhang <zhipingz@meta.com>
RDMA/mlx5: get tph for p2p access when registering dma-buf mr
This commit wires up mlx5_ib to query the exporter's chosen PCIe TLP
Processing Hint (TPH) Steering Tag at MR registration time for peer-to-peer
DMA access. It translates the exporter-provided steering tags into local ST
entries or uses default routing if no hint is available.
> diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
> index 00e13028762ae..fdd7d94bd4aa4 100644
> --- a/drivers/infiniband/hw/mlx5/mr.c
> +++ b/drivers/infiniband/hw/mlx5/mr.c
> @@ -167,6 +168,61 @@ static int get_unchangeable_access_flags(struct mlx5_ib_dev *dev,
> #define MLX5_FRMR_POOLS_KERNEL_KEY_PH_MASK GENMASK_ULL(23, 16)
> #define MLX5_FRMR_POOLS_KERNEL_KEY_ST_INDEX_MASK GENMASK_ULL(15, 0)
>
> +static u8 mlx5_ib_tph_key_ph(u8 ph)
> +{
> + if (ph == MLX5_IB_NO_PH || ph == 0)
> + ph ^= MLX5_IB_NO_PH;
> +
> + return ph;
> +}
> +
> +static int mlx5_ib_get_st_handle_ref(struct mlx5_ib_dev *dev, u16 st_index)
> +{
> + if (st_index == MLX5_MKC_PCIE_TPH_NO_STEERING_TAG_INDEX)
> + return 0;
> +
> + return mlx5_st_get_index(dev->mdev, st_index);
> +}
> +
> +static void mlx5_ib_put_st_index_ref(struct mlx5_ib_dev *dev, u16 st_index)
> +{
> + if (st_index == MLX5_MKC_PCIE_TPH_NO_STEERING_TAG_INDEX)
> + return;
> +
> + mlx5_st_dealloc_index(dev->mdev, st_index);
[Severity: High]
This is a pre-existing issue, but this patch introduces a new, heavily-exercised
reachable path for it.
Does mlx5_st_dealloc_index() leak the mlx5_st_idx_data struct when erasing it
from the xarray?
When a steering tag's reference count drops to zero, the entry is removed via
xa_erase():
drivers/net/ethernet/mellanox/mlx5/core/lib/st.c:mlx5_st_dealloc_index() {
...
if (refcount_dec_and_test(&idx_data->usecount)) {
xa_erase(&st->idx_xa, st_index);
/* We leave PCI config space as was before, no mkey will refer to it */
}
...
}
However, the underlying idx_data pointer is not freed with kfree(idx_data).
Because the next time the same tag is requested, a new struct is allocated via
kzalloc_obj() in mlx5_st_alloc_index_by_tag(), won't repeated allocations and
deallocations lead to an unbounded kernel memory leak?
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260731211601.3033906-1-zhipingz@meta.com?part=5
next prev parent reply other threads:[~2026-07-31 21:48 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 21:15 [PATCH v13 0/5] vfio/dma-buf: add TPH support for peer-to-peer access Zhiping Zhang
2026-07-31 21:15 ` [PATCH v13 1/5] PCI/TPH: treat reserved 0b10 completer encoding as unsupported Zhiping Zhang
2026-07-31 21:38 ` sashiko-bot
2026-09-15 22:19 ` Bjorn Helgaas
2026-09-15 23:14 ` Zhiping Zhang
2026-07-31 21:15 ` [PATCH v13 2/5] PCI/TPH: Add requester/completer type helpers Zhiping Zhang
2026-07-31 21:40 ` sashiko-bot
2026-08-03 1:21 ` fengchengwen
2026-09-15 22:23 ` Bjorn Helgaas
2026-09-15 23:27 ` Zhiping Zhang
2026-07-31 21:15 ` [PATCH v13 3/5] dma-buf: add optional get_pci_tph() callback Zhiping Zhang
2026-07-31 21:37 ` sashiko-bot
2026-07-31 21:15 ` [PATCH v13 4/5] vfio/pci: implement get_pci_tph and DMA_BUF_TPH feature Zhiping Zhang
2026-07-31 21:38 ` sashiko-bot
2026-07-31 21:15 ` [PATCH v13 5/5] RDMA/mlx5: get tph for p2p access when registering dma-buf mr Zhiping Zhang
2026-07-31 21:48 ` sashiko-bot [this message]
2026-07-31 22:59 ` Zhiping Zhang
2026-09-23 19:11 ` Zhiping Zhang
2026-09-24 1:13 ` fengchengwen
2026-09-24 6:24 ` Zhiping Zhang
2026-09-24 23:30 ` Jason Gunthorpe
2026-09-25 6:17 ` Zhiping Zhang
2026-09-28 17:29 ` Jason Gunthorpe
2026-09-28 21:47 ` Zhiping Zhang
2026-09-30 12:13 ` Leon Romanovsky
2026-10-05 21:33 ` Zhiping Zhang
2026-08-14 18:08 ` [PATCH v13 0/5] vfio/dma-buf: add TPH support for peer-to-peer access Zhiping Zhang
2026-09-02 20:53 ` Zhiping Zhang
2026-09-10 21:46 ` [PATCH v13 0/5] vfio/dma-buf: add TPH support for peer-to-peer access - ping Zhiping Zhang
2026-09-11 7:58 ` Christian König
2026-09-14 16:44 ` Zhiping Zhang
2026-09-15 20:49 ` Alex Williamson
2026-09-16 0:17 ` Zhiping Zhang
2026-09-15 11:37 ` Leon Romanovsky
2026-09-15 12:59 ` Christian König
2026-09-15 13:37 ` Leon Romanovsky
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=20260731214821.2A9AA1F00AC4@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhipingz@meta.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