From: Edward Srouji <edwards@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
"Yishai Hadas" <yishaih@nvidia.com>,
Yishai Hadas <yishaih@mellanox.com>
Cc: <linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Edward Srouji" <edwards@nvidia.com>,
Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH rdma-next v2 1/3] RDMA/mlx5: Respect pgsz_bitmap when reducing the DEVX UMEM page size
Date: Wed, 11 Nov 2026 15:57:02 +0200 [thread overview]
Message-ID: <20261111-devx-umem-mailbox-overflow-v2-1-1e7ca8237b58@nvidia.com> (raw)
In-Reply-To: <20261111-devx-umem-mailbox-overflow-v2-0-1e7ca8237b58@nvidia.com>
devx_umem_find_best_pgsize() starts from the largest usable page size
allowed by the user's pgsz_bitmap and halves it until the umem starts
on a page boundary and its length is a multiple of the page size. The
halving ignores pgsz_bitmap, so the umem can be created with a page
size userspace did not allow, although the bitmap is meant to reflect
the HW limits of the intended use of the umem.
Step down to the next smaller size in pgsz_bitmap instead, and fail
the registration if none is left. The default bitmap includes every
power-of-two page size from 4K up, so the result is unchanged when
userspace does not pass one.
The Sashiko AI reviewer found this while reviewing another DEVX UMEM
patch.
Fixes: 7610ab57de56 ("RDMA/mlx5: Allow larger pages in DevX umem")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/linux-rdma/sashiko-outbox-205134@kernel.org/
Signed-off-by: Edward Srouji <edwards@nvidia.com>
---
drivers/infiniband/hw/mlx5/devx.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c
index fc6f793dcc6584e6a22b40c57e2df8f24579eb14..6c34f2c2a91d0be26352100c243f24789feab3db 100644
--- a/drivers/infiniband/hw/mlx5/devx.c
+++ b/drivers/infiniband/hw/mlx5/devx.c
@@ -2320,8 +2320,12 @@ static unsigned int devx_umem_find_best_pgsize(struct ib_umem *umem,
*/
while ((ib_umem_dma_offset(umem, page_size) != 0 ||
(umem->length % page_size) != 0) &&
- page_size > PAGE_SIZE)
- page_size /= 2;
+ page_size > PAGE_SIZE) {
+ pgsz_bitmap &= page_size - 1;
+ if (!pgsz_bitmap)
+ return 0;
+ page_size = rounddown_pow_of_two(pgsz_bitmap);
+ }
return page_size;
}
--
2.49.0
next prev parent reply other threads:[~2026-11-11 13:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 13:57 [PATCH rdma-next v2 0/3] RDMA: Fix DEVX UMEM mailbox size overflow Edward Srouji
2026-11-11 13:57 ` Edward Srouji [this message]
2026-11-11 13:57 ` [PATCH rdma-next v2 2/3] RDMA/mlx5: Fix DEVX UMEM mailbox size truncation Edward Srouji
2026-11-11 13:57 ` [PATCH rdma-next v2 3/3] RDMA/core: Don't warn on oversized bundle allocations Edward Srouji
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=20261111-devx-umem-mailbox-overflow-v2-1-1e7ca8237b58@nvidia.com \
--to=edwards@nvidia.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=yishaih@mellanox.com \
--cc=yishaih@nvidia.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
all inboxes | Powered by JetHome®