rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Benno Lossin" <lossin@kernel.org>
To: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
	"Alexandre Courbot" <acourbot@nvidia.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	nouveau@lists.freedesktop.org
Subject: Re: [PATCH v2 2/4] rust: add `Alignment` type
Date: Mon, 04 Aug 2025 17:11:30 +0200	[thread overview]
Message-ID: <DBTQN3RW1H1S.1G8KB3ZD8A58F@kernel.org> (raw)
In-Reply-To: <CANiq72miQSuEEzKZsOhHKDah1kP+8PYcmODGqwtcaRwAggF-+g@mail.gmail.com>

On Mon Aug 4, 2025 at 4:17 PM CEST, Miguel Ojeda wrote:
> On Mon, Aug 4, 2025 at 1:45 PM Alexandre Courbot <acourbot@nvidia.com> wrote:
>> +        if !self.0.is_power_of_two() {
>> +            // SAFETY: per the invariants, `self.0` is always a power of two so this block will
>> +            // never be reached.
>> +            unsafe { core::hint::unreachable_unchecked() }
>> +        }
>
> I guess this one is here to help optimize users after they inline the
> cal? Is there a particular case you noticed? i.e. it may be worth
> mentioning it.

I suggested this in the previous version [1]. For example, it optimizes
division to only be a left shift.

[1]: https://lore.kernel.org/all/DBL1ZGZCSJF3.29HNS9BSN89C6@kernel.org

---
Cheers,
Benno

  reply	other threads:[~2025-08-04 15:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-04 11:45 [PATCH v2 0/4] rust: add `Alignment` type Alexandre Courbot
2025-08-04 11:45 ` [PATCH v2 1/4] rust: add `CheckedAdd` trait Alexandre Courbot
2025-08-04 14:37   ` Daniel Almeida
2025-08-05 12:59     ` Alexandre Courbot
2025-08-04 11:45 ` [PATCH v2 2/4] rust: add `Alignment` type Alexandre Courbot
2025-08-04 14:17   ` Miguel Ojeda
2025-08-04 15:11     ` Benno Lossin [this message]
2025-08-05 13:13     ` Alexandre Courbot
2025-08-05 16:20       ` Benno Lossin
2025-08-04 15:47   ` Daniel Almeida
2025-08-05 13:18     ` Alexandre Courbot
2025-08-04 11:45 ` [PATCH v2 3/4] gpu: nova-core: use Alignment for alignment-related operations Alexandre Courbot
2025-08-04 11:45 ` [PATCH v2 4/4] gpu: nova-core: use `checked_ilog2` to emulate `fls` Alexandre Courbot
2025-08-04 14:16 ` [PATCH v2 0/4] rust: add `Alignment` type Miguel Ojeda
2025-08-05 13:26   ` Alexandre Courbot
2025-08-05 19:26     ` John Hubbard

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=DBTQN3RW1H1S.1G8KB3ZD8A58F@kernel.org \
    --to=lossin@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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;
as well as URLs for NNTP newsgroup(s).