From: Benno Lossin <benno.lossin@proton.me>
To: Andreas Hindborg <a.hindborg@kernel.org>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
"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>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Joel Becker" <jlbec@evilplan.org>,
"Christoph Hellwig" <hch@lst.de>,
"Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>, "Will Deacon" <will@kernel.org>,
"Waiman Long" <longman@redhat.com>,
"Fiona Behrens" <me@kloenk.dev>,
"Charalampos Mitrodimas" <charmitro@posteo.net>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] rust: configfs: introduce rust support for configfs
Date: Mon, 17 Feb 2025 23:04:39 +0000 [thread overview]
Message-ID: <354dbebd-b211-4e8f-a181-8fbacb0e89c8@proton.me> (raw)
In-Reply-To: <87bjv0u5j0.fsf@kernel.org>
On 17.02.25 13:20, Andreas Hindborg wrote:
> "Benno Lossin" <benno.lossin@proton.me> writes:
>> On 17.02.25 12:08, Andreas Hindborg wrote:
>>>>> +
>>>>> +/// A `configfs` subsystem.
>>>>> +///
>>>>> +/// This is the top level entrypoint for a `configfs` hierarchy. To register
>>>>> +/// with configfs, embed a field of this type into your kernel module struct.
>>>>> +#[pin_data(PinnedDrop)]
>>>>> +pub struct Subsystem<Data> {
>>>>
>>>> Usually, we don't have multi-character generics, any specific reason
>>>> that you chose `Data` here over `T` or `D`?
>>>
>>> Yes, I find it more descriptive. The patch set went through quite a bit
>>> of evolution, and the generics got a bit complicated in earlier
>>> iterations, which necessitated more descriptive generic type parameter
>>> names. It's not so bad in this version after I restricted the pointer
>>> type to just `Arc`, but I still think that using a word rather a single
>>> letter makes the code easier to comprehend at first pass.
>>
>> Makes sense. I'm not opposed to it, but I am a bit cautious, because one
>> disadvantage with using multi-character names for generics is that one
>> cannot easily see if a type is a generic or not. Maybe that is not as
>> important as I think it could be, but to me it seems useful.
>
> If you use an editor with semantic highlighting, you can style the
> generic identifiers. I am currently trying out Helix, and that is
> unfortunately on of the features it is missing. Can't have it all I
> guess.
That is true, but there are a lot of places where Rust code is put that
aren't my editor (git diffs/commit messages, mails, lore.kernel.org,
github) and there it'll become more difficult to read (also people might
not have their editor configured to highlight them).
So I think we should at least consider it more.
>>>>> + // SAFETY: We are expanding `configfs_attrs`.
>>>>> + static [< $data:upper _ $name:upper _ATTR >]:
>>>>> + $crate::configfs::Attribute<$attr, $data, $data> =
>>>>> + unsafe {
>>>>> + $crate::configfs::Attribute::new(c_str!(::core::stringify!($name)))
>>>>> + };
>>>>> + }
>>>>> + )*
>>>>> +
>>>>> +
>>>>> + const N: usize = $cnt + 1usize;
>>>>
>>>> Why do we need an additional copy? To have a zero entry at the end for C
>>>> to know it's the end of the list? If so, a comment here would be very
>>>> helpful.
>>>
>>> Yes, we need space for a null terminator. I'll add a comment.
>>>
>>> We actually have a static check to make sure that we not missing this.
>>
>> Where is this static check?
>
> In `Attribute::add`:
>
> if I >= N - 1 {
> kernel::build_error!("Invalid attribute index");
> }
Ahh I see, would be also nice to have a comment there explaining why the
check is `>= N - 1`.
---
Cheers,
Benno
next prev parent reply other threads:[~2025-02-17 23:04 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 14:41 [PATCH v2 0/3] rust: configfs abstractions Andreas Hindborg
2025-02-07 14:41 ` [PATCH v2 1/3] rust: sync: change `<Arc<T> as ForeignOwnable>::PointedTo` to `T` Andreas Hindborg
2025-02-17 0:21 ` Benno Lossin
2025-02-17 2:03 ` Tamir Duberstein
2025-02-17 7:34 ` Andreas Hindborg
2025-02-07 14:41 ` [PATCH v2 2/3] rust: configfs: introduce rust support for configfs Andreas Hindborg
2025-02-08 21:26 ` Charalampos Mitrodimas
2025-02-10 10:36 ` Andreas Hindborg
2025-02-16 16:12 ` Charalampos Mitrodimas
2025-02-17 7:36 ` Andreas Hindborg
2025-02-17 2:17 ` Benno Lossin
2025-02-17 11:08 ` Andreas Hindborg
2025-02-17 11:40 ` Benno Lossin
2025-02-17 12:20 ` Andreas Hindborg
2025-02-17 23:04 ` Benno Lossin [this message]
2025-02-18 8:40 ` Andreas Hindborg
2025-02-18 12:17 ` Andreas Hindborg
2025-02-18 12:41 ` Benno Lossin
2025-02-18 13:00 ` Danilo Krummrich
2025-02-18 13:10 ` Andreas Hindborg
2025-02-07 14:41 ` [PATCH v2 3/3] MAINTAINERS: add entry for configfs Rust abstractions Andreas Hindborg
-- strict thread matches above, loose matches on Subject: below --
2025-02-21 18:44 [PATCH v2 2/3] rust: configfs: introduce rust support for configfs MICHAEL TURNER
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=354dbebd-b211-4e8f-a181-8fbacb0e89c8@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=charmitro@posteo.net \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=hch@lst.de \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=me@kloenk.dev \
--cc=mingo@redhat.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=will@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;
as well as URLs for NNTP newsgroup(s).