mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Gary Guo" <gary@garyguo.net>
Cc: "Zhi Wang" <zhiw@nvidia.com>, <rust-for-linux@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <dakr@kernel.org>,
	<jgg@nvidia.com>, <dave.jiang@intel.com>, <saeedm@nvidia.com>,
	<jic23@kernel.org>, <joelagnelf@nvidia.com>,
	<aliceryhl@google.com>, <kwilczynski@kernel.org>,
	<ojeda@kernel.org>, <alex.gaynor@gmail.com>,
	<boqun.feng@gmail.com>, <bjorn3_gh@protonmail.com>,
	<lossin@kernel.org>, <a.hindborg@kernel.org>, <tmgross@umich.edu>,
	<cjia@nvidia.com>, <smitra@nvidia.com>, <ankita@nvidia.com>,
	<aniketa@nvidia.com>, <kwankhede@nvidia.com>,
	<targupta@nvidia.com>, <kjaju@nvidia.com>, <alkumar@nvidia.com>,
	<jhubbard@nvidia.com>, <zhiwang@kernel.org>,
	<daniel.almeida@collabora.com>
Subject: Re: [PATCH v8 1/1] rust: introduce abstractions for fwctl
Date: Mon, 24 Aug 2026 11:59:35 +0900	[thread overview]
Message-ID: <DKWU6FXYZTYB.FY9L7L4OTXCZ@nvidia.com> (raw)
In-Reply-To: <DKP1Z8PZZX83.GZ924NDYZYPB@garyguo.net>

On Sat Aug 15, 2026 at 8:25 AM JST, Gary Guo wrote:
> On Thu Aug 13, 2026 at 4:23 PM BST, Zhi Wang wrote:
>> diff --git a/rust/kernel/fwctl.rs b/rust/kernel/fwctl.rs
>> new file mode 100644
>> index 000000000000..e6a8513a47d0
>> --- /dev/null
>> +++ b/rust/kernel/fwctl.rs
>> @@ -0,0 +1,593 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +
>> +//! Abstractions for the fwctl subsystem.
>> +//!
>> +//! C header: `include/linux/fwctl.h`
>> +
>> +use crate::{
>> +    bindings,
>> +    container_of,
>> +    device,
>> +    prelude::*,
>> +    sync::aref::{
>> +        ARef,
>> +        AlwaysRefCounted, //
>> +    },
>> +    types::Opaque, //
>> +};
>> +use core::{
>> +    alloc::Layout,
>> +    cell::UnsafeCell,
>> +    marker::PhantomData,
>> +    ptr::NonNull,
>> +    slice, //
>> +};
>> +
>> +/// Returns a kmalloc-compatible allocation size for `T`.
>> +const fn kmalloc_aligned_size<T>() -> usize {
>> +    Layout::new::<T>().pad_to_align().size()
>
> What's this function doing?  This is just identical to `size_of::<T>()`.
>
> The layout from a specific type is already padded to its alignment. You only
> need to call `pad_to_align()`, say, if you are computing a layout or increasing
> the alignment of layout.

IIRC this was meant to be a const version of `Kmalloc::aligned_layout`
[1], which although it is equivalent carries the intent better than just
using `size_of`. But here it would maybe be better to just make
`Kmalloc::aligned_layout` const and call it instead.

[1] https://lore.kernel.org/all/DGUZ4A6W87JU.36R2KDR7YGSEX@kernel.org/

  reply	other threads:[~2026-08-24  2:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 15:23 [PATCH v8 0/1] " Zhi Wang
2026-08-13 15:23 ` [PATCH v8 1/1] " Zhi Wang
2026-08-14  1:18   ` Alexandre Courbot
2026-08-14 22:47   ` Jason Gunthorpe
2026-08-14 23:25   ` Gary Guo
2026-08-24  2:59     ` Alexandre Courbot [this message]
2026-08-24 11:06       ` Gary Guo

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=DKWU6FXYZTYB.FY9L7L4OTXCZ@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=alkumar@nvidia.com \
    --cc=aniketa@nvidia.com \
    --cc=ankita@nvidia.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=cjia@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dave.jiang@intel.com \
    --cc=gary@garyguo.net \
    --cc=jgg@nvidia.com \
    --cc=jhubbard@nvidia.com \
    --cc=jic23@kernel.org \
    --cc=joelagnelf@nvidia.com \
    --cc=kjaju@nvidia.com \
    --cc=kwankhede@nvidia.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=smitra@nvidia.com \
    --cc=targupta@nvidia.com \
    --cc=tmgross@umich.edu \
    --cc=zhiw@nvidia.com \
    --cc=zhiwang@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

all inboxes | Powered by JetHome®