From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Yishai Hadas <yishaih@nvidia.com>,
Chengchang Tang <tangchengchang@huawei.com>,
Junxian Huang <huangjunxian6@hisilicon.com>,
Edward Srouji <edwards@nvidia.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev
Subject: Re: [PATCH rdma-next 0/4] RDMA: Use unsigned comparison in CQ cleanup loops
Date: Tue, 22 Sep 2026 09:15:10 -0400 [thread overview]
Message-ID: <179008291023.3238769.13558406499996514040.b4-ty@kernel.org> (raw)
In-Reply-To: <20260915-fix-cq-cleanup-v1-0-e991944cf898@nvidia.com>
On Tue, 15 Sep 2026 18:33:27 +0300, Edward Srouji wrote:
> mlx5, mlx4, mthca and hns all sweep the CQ backwards when cleaning
> completions for a QP that is being destroyed, using the same open-coded
> loop (mlx5 shown):
> while ((int) --prod_index - (int) cq->mcq.cons_index >= 0)
> Both indexes are free running u32 counters, so the comparison has to be
> done modulo 2^32. Casting each operand to int and subtracting does not
> do that: the subtraction overflows once the two indexes straddle 2^31,
> which is undefined behaviour, and a compiler that assumes signed
> overflow cannot occur is free to fold the expression into a plain signed
> comparison that is not wraparound safe.
> This is not a fix. The kernel is built with -fno-strict-overflow, so
> gcc and clang both retain the subtraction, the generated code is
> unaffected, and there is no known user-visible impact. The casts buy
> nothing, though, and the correctness of these loops should not rest on
> a build flag. The series drops the arithmetic instead:
> while (prod_index != cq->mcq.cons_index) {
> --prod_index;
> ...
> No functional change intended.
>
> [...]
Applied, thanks!
[1/4] RDMA/mlx5: Use unsigned comparison in the CQ cleanup loop
https://git.kernel.org/rdma/rdma/c/c6aa5feb521066
[2/4] RDMA/mlx4: Use unsigned comparison in the CQ cleanup loop
https://git.kernel.org/rdma/rdma/c/c5fe428bb23edc
[3/4] RDMA/mthca: Use unsigned comparison in the CQ cleanup loop
https://git.kernel.org/rdma/rdma/c/b934024d3aafb9
[4/4] RDMA/hns: Use unsigned comparison in the CQ cleanup loop
https://git.kernel.org/rdma/rdma/c/ebb65190349537
Best regards,
--
Leon Romanovsky <leon@kernel.org>
prev parent reply other threads:[~2026-09-22 13:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 15:33 Edward Srouji
2026-09-15 15:33 ` [PATCH rdma-next 1/4] RDMA/mlx5: Use unsigned comparison in the CQ cleanup loop Edward Srouji
2026-09-15 15:33 ` [PATCH rdma-next 2/4] RDMA/mlx4: " Edward Srouji
2026-09-15 15:33 ` [PATCH rdma-next 3/4] RDMA/mthca: " Edward Srouji
2026-09-15 15:33 ` [PATCH rdma-next 4/4] RDMA/hns: " Edward Srouji
2026-09-22 13:15 ` 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=179008291023.3238769.13558406499996514040.b4-ty@kernel.org \
--to=leon@kernel.org \
--cc=edwards@nvidia.com \
--cc=huangjunxian6@hisilicon.com \
--cc=jgg@ziepe.ca \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=tangchengchang@huawei.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®