From: Andreas Hindborg <a.hindborg@kernel.org>
To: "Benno Lossin" <lossin@kernel.org>
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>,
"Alice Ryhl" <aliceryhl@google.com>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>,
"Nicolas Schier" <nicolas.schier@linux.dev>,
"Trevor Gross" <tmgross@umich.edu>,
"Adam Bratschi-Kaye" <ark.email@gmail.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kbuild@vger.kernel.org, "Petr Pavlu" <petr.pavlu@suse.com>,
"Sami Tolvanen" <samitolvanen@google.com>,
"Daniel Gomez" <da.gomez@samsung.com>,
"Simona Vetter" <simona.vetter@ffwll.ch>,
"Greg KH" <gregkh@linuxfoundation.org>,
"Fiona Behrens" <me@kloenk.dev>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
linux-modules@vger.kernel.org
Subject: Re: [PATCH v13 2/6] rust: introduce module_param module
Date: Wed, 02 Jul 2025 09:56:50 +0200 [thread overview]
Message-ID: <87tt3vvxdp.fsf@kernel.org> (raw)
In-Reply-To: <DB0U12HAEVZ6.JKFPI2UQHDRY@kernel.org> (Benno Lossin's message of "Tue, 01 Jul 2025 17:43:29 +0200")
"Benno Lossin" <lossin@kernel.org> writes:
> On Tue Jul 1, 2025 at 4:14 PM CEST, Andreas Hindborg wrote:
>> "Benno Lossin" <lossin@kernel.org> writes:
>>> On Tue Jul 1, 2025 at 10:43 AM CEST, Andreas Hindborg wrote:
>>>> No, I am OK for now with configfs.
>>>>
>>>> But, progress is still great. How about if we add a copy accessor
>>>> instead for now, I think you proposed that a few million emails ago:
>>>>
>>>> pub fn get(&self) -> T;
>>>>
>>>> or maybe rename:
>>>>
>>>> pub fn copy(&self) -> T;
>>>>
>>>> Then we are fine safety wise for now, right? It is even sensible for
>>>> these `T: Copy` types.
>>>
>>> That is better than getting a reference, but still someone could read at
>>> the same time that a write is happening (though we need some new
>>> abstractions AFAIK?). But I fear that we forget about this issue,
>>> because it'll be some time until we land parameters that are `!Copy` (if
>>> at all...)
>>
>> No, that could not happen when we are not allowing custom parsing or
>> sysfs access. Regarding forgetting, I already added a `NOTE` on `!Copy`,
>> and I would add one on this issue as well.
>
> Ultimately this is something for Miguel to decide. I would support an
> unsafe accessor (we should also make it `-> T`), since there it "can't
> go wrong", any UB is the fault of the user of the API. It also serves as
> a good reminder, since a `NOTE` comment shouldn't be something
> guaranteeing safety (we do have some of these global invariants, but I
> feel like this one is too tribal and doesn't usually come up, so I feel
> like it's more dangerous).
I see no reason for making it unsafe when it is safe?
/// Get a copy of the parameter value.
///
/// # Note
///
/// When this method is called in `const` context, the default
/// parameter value will be returned. During module initialization, the
/// kernel will populate the parameter with the value supplied at module
/// load time or kernel boot time.
// NOTE: When sysfs access to parameters are enabled, we have to pass in a
// held lock guard here.
//
// NOTE: When we begin supporting custom parameter parsing with user
// supplied code, this method must be synchronized.
pub const fn copy(&self) -> T {
// SAFETY: As we only support read only parameters with no sysfs
// exposure, the kernel will not touch the parameter data after module
// initialization. The kernel will update the parameters serially, so we
// will not race with other accesses.
unsafe { *self.data.get() }
}
>
> I think we should also move this patchset along, we could also opt for
> no accessor at all :) Then it isn't really useful without the downstream
> accessor function, but that can come after.
I would rather not merge it without an access method. Then it is just
dead code, and we will not notice if we break it.
Best regards,
Andreas Hindborg
next prev parent reply other threads:[~2025-07-02 7:57 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 13:40 [PATCH v13 0/6] rust: extend `module!` macro with integer parameter support Andreas Hindborg
2025-06-12 13:40 ` [PATCH v13 1/6] rust: str: add radix prefixed integer parsing functions Andreas Hindborg
2025-06-18 20:38 ` Benno Lossin
2025-06-19 11:12 ` Andreas Hindborg
2025-06-19 12:17 ` Benno Lossin
2025-06-19 12:41 ` Andreas Hindborg
2025-06-12 13:40 ` [PATCH v13 2/6] rust: introduce module_param module Andreas Hindborg
2025-06-18 20:59 ` Benno Lossin
2025-06-19 12:20 ` Andreas Hindborg
2025-06-19 12:55 ` Benno Lossin
2025-06-20 10:31 ` Andreas Hindborg
2025-06-19 13:15 ` Benno Lossin
2025-06-20 11:29 ` Andreas Hindborg
2025-06-20 11:52 ` Andreas Hindborg
2025-06-20 12:28 ` Benno Lossin
2025-06-23 9:44 ` Andreas Hindborg
2025-06-23 11:48 ` Benno Lossin
2025-06-23 12:37 ` Miguel Ojeda
2025-06-23 13:55 ` Benno Lossin
2025-06-23 14:31 ` Andreas Hindborg
2025-06-23 15:20 ` Benno Lossin
2025-06-24 11:57 ` Andreas Hindborg
2025-06-27 7:57 ` Andreas Hindborg
2025-06-27 8:23 ` Benno Lossin
2025-06-30 11:18 ` Andreas Hindborg
2025-06-30 12:27 ` Benno Lossin
2025-06-30 13:15 ` Andreas Hindborg
2025-06-30 19:02 ` Benno Lossin
2025-07-01 8:43 ` Andreas Hindborg
2025-07-01 9:05 ` Benno Lossin
2025-07-01 14:14 ` Andreas Hindborg
2025-07-01 15:43 ` Benno Lossin
2025-07-01 16:27 ` Miguel Ojeda
2025-07-01 16:54 ` Benno Lossin
2025-07-02 8:30 ` Andreas Hindborg
2025-07-02 8:26 ` Andreas Hindborg
2025-07-02 10:01 ` Benno Lossin
2025-07-02 7:56 ` Andreas Hindborg [this message]
2025-06-23 9:47 ` Andreas Hindborg
2025-06-12 13:40 ` [PATCH v13 3/6] rust: module: use a reference in macros::module::module Andreas Hindborg
2025-06-18 20:07 ` Benno Lossin
2025-06-12 13:40 ` [PATCH v13 4/6] rust: module: update the module macro with module parameter support Andreas Hindborg
2025-06-18 21:07 ` Benno Lossin
2025-06-19 12:31 ` Andreas Hindborg
2025-06-12 13:40 ` [PATCH v13 5/6] rust: samples: add a module parameter to the rust_minimal sample Andreas Hindborg
2025-06-18 19:48 ` Benno Lossin
2025-06-30 11:30 ` Danilo Krummrich
2025-06-30 12:12 ` Andreas Hindborg
2025-06-30 12:18 ` Danilo Krummrich
2025-06-30 12:23 ` Danilo Krummrich
2025-06-30 12:31 ` Benno Lossin
2025-06-12 13:40 ` [PATCH v13 6/6] modules: add rust modules files to MAINTAINERS Andreas Hindborg
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=87tt3vvxdp.fsf@kernel.org \
--to=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=ark.email@gmail.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=da.gomez@samsung.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=masahiroy@kernel.org \
--cc=mcgrof@kernel.org \
--cc=me@kloenk.dev \
--cc=nathan@kernel.org \
--cc=nicolas.schier@linux.dev \
--cc=ojeda@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
--cc=simona.vetter@ffwll.ch \
--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).