* [PATCH 0/2] pin-init fixes
@ 2025-04-07 20:18 Benno Lossin
2025-04-07 20:18 ` [PATCH 1/2] rust: pin-init: alloc: restrict `impl ZeroableOption` for `Box` to `T: Sized` Benno Lossin
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Benno Lossin @ 2025-04-07 20:18 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich
Cc: rust-for-linux
Sync from the upstream repository [1]. This is the first time I used my
sync script to port the patches, so if you see any issues, please let me
know. You can find the commits in my repo [2].
Just two small patches fixing one issue that got overlooked, since it
was fixed at the same time the series got merged. And the other fixes a
markdown papercut that I found during review of the previous fix.
[1]: https://github.com/Rust-for-Linux/pin-init
[2]: https://github.com/y86-dev/linux/tree/pin-init-sync
Github PRs included in this sync:
* alloc: restrict `impl ZeroableOption` for `Box` to `T: Sized`
https://github.com/Rust-for-Linux/pin-init/pull/32
---
Miguel Ojeda (2):
rust: pin-init: alloc: restrict `impl ZeroableOption` for `Box` to `T:
Sized`
rust: pin-init: use Markdown autolinks in Rust comments
rust/pin-init/examples/pthread_mutex.rs | 2 +-
rust/pin-init/src/alloc.rs | 8 +++-----
rust/pin-init/src/lib.rs | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)
base-commit: a2cc6ff5ec8f91bc463fd3b0c26b61166a07eb11
--
2.48.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] rust: pin-init: alloc: restrict `impl ZeroableOption` for `Box` to `T: Sized`
2025-04-07 20:18 [PATCH 0/2] pin-init fixes Benno Lossin
@ 2025-04-07 20:18 ` Benno Lossin
2025-04-07 20:18 ` [PATCH 2/2] rust: pin-init: use Markdown autolinks in Rust comments Benno Lossin
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Benno Lossin @ 2025-04-07 20:18 UTC (permalink / raw)
To: Benno Lossin, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Fiona Behrens
Cc: stable, rust-for-linux, linux-kernel
From: Miguel Ojeda <ojeda@kernel.org>
Similar to what was done for `Zeroable<NonNull<T>>` in commit
df27cef15360 ("rust: init: fix `Zeroable` implementation for
`Option<NonNull<T>>` and `Option<KBox<T>>`"), the latest Rust
documentation [1] says it guarantees that `transmute::<_,
Option<T>>([0u8; size_of::<T>()])` is sound and produces
`Option::<T>::None` only in some cases. In particular, it says:
`Box<U>` (specifically, only `Box<U, Global>`) when `U: Sized`
Thus restrict the `impl` to `Sized`, and use similar wording as in that
commit too.
Link: https://doc.rust-lang.org/stable/std/option/index.html#representation [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/Rust-for-Linux/pin-init/pull/32/commits/a6007cf555e5946bcbfafe93a6468c329078acd8
Fixes: 9b2299af3b92 ("rust: pin-init: add `std` and `alloc` support from the user-space version")
Cc: stable@vger.kernel.org
[ Adjust mentioned commit to the one from the kernel. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
---
rust/pin-init/src/alloc.rs | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/rust/pin-init/src/alloc.rs b/rust/pin-init/src/alloc.rs
index e16baa3b434e..5017f57442d8 100644
--- a/rust/pin-init/src/alloc.rs
+++ b/rust/pin-init/src/alloc.rs
@@ -17,11 +17,9 @@
pub extern crate alloc;
-// SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee).
-//
-// In this case we are allowed to use `T: ?Sized`, since all zeros is the `None` variant and there
-// is no problem with a VTABLE pointer being null.
-unsafe impl<T: ?Sized> ZeroableOption for Box<T> {}
+// SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee:
+// <https://doc.rust-lang.org/stable/std/option/index.html#representation>).
+unsafe impl<T> ZeroableOption for Box<T> {}
/// Smart pointer that can initialize memory in-place.
pub trait InPlaceInit<T>: Sized {
--
2.48.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] rust: pin-init: use Markdown autolinks in Rust comments
2025-04-07 20:18 [PATCH 0/2] pin-init fixes Benno Lossin
2025-04-07 20:18 ` [PATCH 1/2] rust: pin-init: alloc: restrict `impl ZeroableOption` for `Box` to `T: Sized` Benno Lossin
@ 2025-04-07 20:18 ` Benno Lossin
2025-04-08 19:48 ` [PATCH 0/2] pin-init fixes Miguel Ojeda
2025-04-08 19:59 ` Miguel Ojeda
3 siblings, 0 replies; 7+ messages in thread
From: Benno Lossin @ 2025-04-07 20:18 UTC (permalink / raw)
To: Benno Lossin, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Fiona Behrens
Cc: stable, rust-for-linux, linux-kernel
From: Miguel Ojeda <ojeda@kernel.org>
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst
Thus use Markdown autolinks for a couple links that were missing it.
It also helps to get proper linking in some software like kitty [1].
Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/pin-init/pull/32#discussion_r2023103712 [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/Rust-for-Linux/pin-init/pull/32/commits/dd230d61bf0538281072fbff4bb71efc58f3420c
Fixes: 84837cf6fa54 ("rust: pin-init: change examples to the user-space version")
Cc: stable@vger.kernel.org
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
---
rust/pin-init/examples/pthread_mutex.rs | 2 +-
rust/pin-init/src/lib.rs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/rust/pin-init/examples/pthread_mutex.rs b/rust/pin-init/examples/pthread_mutex.rs
index 9164298c44c0..5ac22f1880d2 100644
--- a/rust/pin-init/examples/pthread_mutex.rs
+++ b/rust/pin-init/examples/pthread_mutex.rs
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
-// inspired by https://github.com/nbdd0121/pin-init/blob/trunk/examples/pthread_mutex.rs
+// inspired by <https://github.com/nbdd0121/pin-init/blob/trunk/examples/pthread_mutex.rs>
#![allow(clippy::undocumented_unsafe_blocks)]
#![cfg_attr(feature = "alloc", feature(allocator_api))]
#[cfg(not(windows))]
diff --git a/rust/pin-init/src/lib.rs b/rust/pin-init/src/lib.rs
index 05c44514765e..0806c689f693 100644
--- a/rust/pin-init/src/lib.rs
+++ b/rust/pin-init/src/lib.rs
@@ -1447,7 +1447,7 @@ macro_rules! impl_zeroable {
{<T: ?Sized + Zeroable>} UnsafeCell<T>,
// SAFETY: All zeros is equivalent to `None` (option layout optimization guarantee:
- // https://doc.rust-lang.org/stable/std/option/index.html#representation).
+ // <https://doc.rust-lang.org/stable/std/option/index.html#representation>).
Option<NonZeroU8>, Option<NonZeroU16>, Option<NonZeroU32>, Option<NonZeroU64>,
Option<NonZeroU128>, Option<NonZeroUsize>,
Option<NonZeroI8>, Option<NonZeroI16>, Option<NonZeroI32>, Option<NonZeroI64>,
--
2.48.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] pin-init fixes
2025-04-07 20:18 [PATCH 0/2] pin-init fixes Benno Lossin
2025-04-07 20:18 ` [PATCH 1/2] rust: pin-init: alloc: restrict `impl ZeroableOption` for `Box` to `T: Sized` Benno Lossin
2025-04-07 20:18 ` [PATCH 2/2] rust: pin-init: use Markdown autolinks in Rust comments Benno Lossin
@ 2025-04-08 19:48 ` Miguel Ojeda
2025-04-08 19:59 ` Miguel Ojeda
3 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2025-04-08 19:48 UTC (permalink / raw)
To: Benno Lossin
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, rust-for-linux
On Mon, Apr 7, 2025 at 10:18 PM Benno Lossin <benno.lossin@proton.me> wrote:
>
> Sync from the upstream repository [1]. This is the first time I used my
> sync script to port the patches, so if you see any issues, please let me
> know. You can find the commits in my repo [2].
>
> Just two small patches fixing one issue that got overlooked, since it
> was fixed at the same time the series got merged. And the other fixes a
> markdown papercut that I found during review of the previous fix.
Applied to `rust-fixes` -- thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] pin-init fixes
2025-04-07 20:18 [PATCH 0/2] pin-init fixes Benno Lossin
` (2 preceding siblings ...)
2025-04-08 19:48 ` [PATCH 0/2] pin-init fixes Miguel Ojeda
@ 2025-04-08 19:59 ` Miguel Ojeda
2025-04-08 21:49 ` Benno Lossin
3 siblings, 1 reply; 7+ messages in thread
From: Miguel Ojeda @ 2025-04-08 19:59 UTC (permalink / raw)
To: Benno Lossin
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, rust-for-linux
On Mon, Apr 7, 2025 at 10:18 PM Benno Lossin <benno.lossin@proton.me> wrote:
>
> Just two small patches fixing one issue that got overlooked, since it
> was fixed at the same time the series got merged. And the other fixes a
> markdown papercut that I found during review of the previous fix.
It looked good to me -- the Cc: stable may not be needed, since this
just arrived to -rc1 and there is nothing to backport it to, but I
assume it doesn't hurt.
The Fixes: tag can be a bit tricky sometimes, e.g. if one line applies
to one set of stable kernels, and another line to another set, then
the patch probably needs to be split. But they seemed fine in this
case.
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] pin-init fixes
2025-04-08 19:59 ` Miguel Ojeda
@ 2025-04-08 21:49 ` Benno Lossin
2025-04-09 14:15 ` Miguel Ojeda
0 siblings, 1 reply; 7+ messages in thread
From: Benno Lossin @ 2025-04-08 21:49 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, rust-for-linux
On Tue Apr 8, 2025 at 9:59 PM CEST, Miguel Ojeda wrote:
> On Mon, Apr 7, 2025 at 10:18 PM Benno Lossin <benno.lossin@proton.me> wrote:
>>
>> Just two small patches fixing one issue that got overlooked, since it
>> was fixed at the same time the series got merged. And the other fixes a
>> markdown papercut that I found during review of the previous fix.
>
> It looked good to me -- the Cc: stable may not be needed, since this
> just arrived to -rc1 and there is nothing to backport it to, but I
> assume it doesn't hurt.
I thought that if I add a Fixes tag, I should always Cc: stable.
> The Fixes: tag can be a bit tricky sometimes, e.g. if one line applies
> to one set of stable kernels, and another line to another set, then
> the patch probably needs to be split. But they seemed fine in this
> case.
Do you mean the second patch? Yeah, it fixes a line in the example
introduced in the fixed commit, but the other fixed instance is in code
that existed prior to that commit, as that code was just moved there.
Yeah, I probably could have split that one. But since it's only a
markdown fix... I don't think it's too important, but I'll keep it in
mind for future fixes.
---
Cheers,
Benno
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] pin-init fixes
2025-04-08 21:49 ` Benno Lossin
@ 2025-04-09 14:15 ` Miguel Ojeda
0 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2025-04-09 14:15 UTC (permalink / raw)
To: Benno Lossin
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, rust-for-linux
On Tue, Apr 8, 2025 at 11:49 PM Benno Lossin <benno.lossin@proton.me> wrote:
>
> I thought that if I add a Fixes tag, I should always Cc: stable.
That is the general rule, yeah, and it is best to add it than to miss it.
Sometimes I have skipped it on purpose, if I considered that it was
really not worth a backport.
> Do you mean the second patch? Yeah, it fixes a line in the example
> introduced in the fixed commit, but the other fixed instance is in code
> that existed prior to that commit, as that code was just moved there.
>
> Yeah, I probably could have split that one. But since it's only a
> markdown fix... I don't think it's too important, but I'll keep it in
> mind for future fixes.
No worries about that, I think it is fine.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-04-09 14:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07 20:18 [PATCH 0/2] pin-init fixes Benno Lossin
2025-04-07 20:18 ` [PATCH 1/2] rust: pin-init: alloc: restrict `impl ZeroableOption` for `Box` to `T: Sized` Benno Lossin
2025-04-07 20:18 ` [PATCH 2/2] rust: pin-init: use Markdown autolinks in Rust comments Benno Lossin
2025-04-08 19:48 ` [PATCH 0/2] pin-init fixes Miguel Ojeda
2025-04-08 19:59 ` Miguel Ojeda
2025-04-08 21:49 ` Benno Lossin
2025-04-09 14:15 ` Miguel Ojeda
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).