rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]`
@ 2025-03-16  6:14 Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 01/16] rust: enable `raw_ref_op` feature Antonio Hickey
                   ` (15 more replies)
  0 siblings, 16 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux

This patch set enables the `raw_ref_op` feature, which became stable 
in Rust 1.82.

It then replaces all occurences of `addr_of!(place)` and
`addr_of_mut!(place)` with `&raw const place` and `&raw mut place`.

Finally it adds the previous macros `addr_of!` and `addr_of_mut!` to
the disallowed macros in `.clippy.toml`.

Changes in v4:
- Fix comment typo.
- Fix clippy issues.
- Add more context and link for disallowed macros with clippy.
- Seperate the patch replacing of `addr_of[_mut]!` macros with
  `&raw [const|mut]` into smaller patches for each section.
  (PATCH v3 2/3 -> PATCH v4 2/16 through 15/16)
- Fix email typo.
- Link to v3: https://lore.kernel.org/all/0100019597091f92-cb55b6cd-4d06-4d14-8d9c-1a1314949a00-000000@email.amazonses.com/

Changes in v3:
- Re ordered the patches, so that the patch adding the `addr_of[_mut]!`
  macros to the disallowed macros in clippy is applied after replacing
  all the instances of `addr_of_[_mut]` with `&raw [const|mut]`.
  (moved PATCH v2 2/3 -> PATCH v3 3/3 and PATCH v2 3/3 -> PATCH v3 2/3)
- Link to v2: https://lore.kernel.org/all/0100019592c224ba-0cf38e16-2aa2-459d-99cd-09a463d616d4-000000@email.amazonses.com/

Changes in v2:   
- Fix `&raw place` should be `&raw const place`
- Fix email typo
- Link to v1: https://lore.kernel.org/all/010001958dfeacb5-9039aaab-6114-494a-9f1d-f13982091169-000000@email.amazonses.com/

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>

---
Antonio Hickey (16):
  rust: enable `raw_ref_op` feature
  rust: init: refactor to use `&raw [const|mut]`
  rust: list: refactor to use `&raw [const|mut]`
  rust: task: refactor to use `&raw [const|mut]`
  rust: faux: refactor to use `&raw [const|mut]`
  rust: platform: refactor to use `&raw [const|mut]`
  rust: pci: refactor to use `&raw [const|mut]`
  rust: kunit: refactor to use `&raw [const|mut]`
  rust: workqueue: refactor to use `&raw [const|mut]`
  rust: rbtree: refactor to use `&raw [const|mut]`
  rust: net: phy: refactor to use `&raw [const|mut]`
  rust: sync: arc: refactor to use `&raw [const|mut]`
  rust: jump_label: refactor to use `&raw [const|mut]`
  rust: fs: file: refactor to use `&raw [const|mut]`
  rust: block: refactor to use `&raw [const|mut]`
  rust: clippy: disable `addr_of[_mut]!` macros

 .clippy.toml                           |  4 ++++
 rust/kernel/block/mq/request.rs        |  4 ++--
 rust/kernel/faux.rs                    |  4 ++--
 rust/kernel/fs/file.rs                 |  2 +-
 rust/kernel/init.rs                    |  8 ++++----
 rust/kernel/init/macros.rs             | 28 +++++++++++++-------------
 rust/kernel/jump_label.rs              |  4 ++--
 rust/kernel/kunit.rs                   |  4 ++--
 rust/kernel/lib.rs                     |  2 ++
 rust/kernel/list.rs                    |  2 +-
 rust/kernel/list/impl_list_item_mod.rs |  6 +++---
 rust/kernel/net/phy.rs                 |  4 ++--
 rust/kernel/pci.rs                     |  4 ++--
 rust/kernel/platform.rs                |  4 +---
 rust/kernel/rbtree.rs                  | 22 ++++++++++----------
 rust/kernel/sync/arc.rs                |  2 +-
 rust/kernel/task.rs                    |  4 ++--
 rust/kernel/workqueue.rs               |  9 +++++----
 18 files changed, 61 insertions(+), 56 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH v4 01/16] rust: enable `raw_ref_op` feature
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 02/16] rust: init: refactor to use `&raw [const|mut]` Antonio Hickey
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux, linux-kernel

Since Rust 1.82.0 the `raw_ref_op` feature is stable.

By enabling this feature we can use `&raw place` and `&raw mut place`
instead of using `addr_of!(place)` and `addr_of_mut!(place)` macros.

Allowing us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/lib.rs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
index 398242f92a96..1d078f69bb19 100644
--- a/rust/kernel/lib.rs
+++ b/rust/kernel/lib.rs
@@ -19,6 +19,8 @@
 #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(unsize))]
 #![feature(inline_const)]
 #![feature(lint_reasons)]
+// Stable in Rust 1.82
+#![feature(raw_ref_op)]
 // Stable in Rust 1.83
 #![feature(const_maybe_uninit_as_mut_ptr)]
 #![feature(const_mut_refs)]
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 02/16] rust: init: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 01/16] rust: enable `raw_ref_op` feature Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16 10:14   ` Benno Lossin
  2025-03-16  6:14 ` [PATCH v4 03/16] rust: list: " Antonio Hickey
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/init.rs        |  8 ++++----
 rust/kernel/init/macros.rs | 28 ++++++++++++++--------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs
index 7fd1ea8265a5..53dd39f9a550 100644
--- a/rust/kernel/init.rs
+++ b/rust/kernel/init.rs
@@ -122,7 +122,7 @@
 //! ```rust
 //! # #![expect(unreachable_pub, clippy::disallowed_names)]
 //! use kernel::{init, types::Opaque};
-//! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin};
+//! use core::{marker::PhantomPinned, pin::Pin};
 //! # mod bindings {
 //! #     #![expect(non_camel_case_types)]
 //! #     #![expect(clippy::missing_safety_doc)]
@@ -159,7 +159,7 @@
 //!         unsafe {
 //!             init::pin_init_from_closure(move |slot: *mut Self| {
 //!                 // `slot` contains uninit memory, avoid creating a reference.
-//!                 let foo = addr_of_mut!((*slot).foo);
+//!                 let foo = &raw mut (*slot).foo;
 //!
 //!                 // Initialize the `foo`
 //!                 bindings::init_foo(Opaque::raw_get(foo));
@@ -541,7 +541,7 @@ macro_rules! stack_try_pin_init {
 ///
 /// ```rust
 /// # use kernel::{macros::{Zeroable, pin_data}, pin_init};
-/// # use core::{ptr::addr_of_mut, marker::PhantomPinned};
+/// # use core::marker::PhantomPinned;
 /// #[pin_data]
 /// #[derive(Zeroable)]
 /// struct Buf {
@@ -554,7 +554,7 @@ macro_rules! stack_try_pin_init {
 /// pin_init!(&this in Buf {
 ///     buf: [0; 64],
 ///     // SAFETY: TODO.
-///     ptr: unsafe { addr_of_mut!((*this.as_ptr()).buf).cast() },
+///     ptr: unsafe { (&raw mut ((*this.as_ptr()).buf)).cast() },
 ///     pin: PhantomPinned,
 /// });
 /// pin_init!(Buf {
diff --git a/rust/kernel/init/macros.rs b/rust/kernel/init/macros.rs
index 1fd146a83241..af525fbb2f01 100644
--- a/rust/kernel/init/macros.rs
+++ b/rust/kernel/init/macros.rs
@@ -244,25 +244,25 @@
 //!                     struct __InitOk;
 //!                     // This is the expansion of `t,`, which is syntactic sugar for `t: t,`.
 //!                     {
-//!                         unsafe { ::core::ptr::write(::core::addr_of_mut!((*slot).t), t) };
+//!                         unsafe { ::core::ptr::write(&raw mut (*slot).t, t) };
 //!                     }
 //!                     // Since initialization could fail later (not in this case, since the
 //!                     // error type is `Infallible`) we will need to drop this field if there
 //!                     // is an error later. This `DropGuard` will drop the field when it gets
 //!                     // dropped and has not yet been forgotten.
 //!                     let __t_guard = unsafe {
-//!                         ::pinned_init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).t))
+//!                         ::pinned_init::__internal::DropGuard::new(&raw mut (*slot).t)
 //!                     };
 //!                     // Expansion of `x: 0,`:
 //!                     // Since this can be an arbitrary expression we cannot place it inside
 //!                     // of the `unsafe` block, so we bind it here.
 //!                     {
 //!                         let x = 0;
-//!                         unsafe { ::core::ptr::write(::core::addr_of_mut!((*slot).x), x) };
+//!                         unsafe { ::core::ptr::write(&raw mut (*slot).x, x) };
 //!                     }
 //!                     // We again create a `DropGuard`.
 //!                     let __x_guard = unsafe {
-//!                         ::kernel::init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).x))
+//!                         ::kernel::init::__internal::DropGuard::new(&raw mut (*slot).x)
 //!                     };
 //!                     // Since initialization has successfully completed, we can now forget
 //!                     // the guards. This is not `mem::forget`, since we only have
@@ -459,15 +459,15 @@
 //!         {
 //!             struct __InitOk;
 //!             {
-//!                 unsafe { ::core::ptr::write(::core::addr_of_mut!((*slot).a), a) };
+//!                 unsafe { ::core::ptr::write(&raw mut (*slot).a, a) };
 //!             }
 //!             let __a_guard = unsafe {
-//!                 ::kernel::init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).a))
+//!                 ::kernel::init::__internal::DropGuard::new(&raw mut (*slot).a)
 //!             };
 //!             let init = Bar::new(36);
-//!             unsafe { data.b(::core::addr_of_mut!((*slot).b), b)? };
+//!             unsafe { data.b(&raw mut (*slot).b, b)? };
 //!             let __b_guard = unsafe {
-//!                 ::kernel::init::__internal::DropGuard::new(::core::addr_of_mut!((*slot).b))
+//!                 ::kernel::init::__internal::DropGuard::new(&raw mut (*slot).b)
 //!             };
 //!             ::core::mem::forget(__b_guard);
 //!             ::core::mem::forget(__a_guard);
@@ -1210,7 +1210,7 @@ fn assert_zeroable<T: $crate::init::Zeroable>(_: *mut T) {}
         // SAFETY: `slot` is valid, because we are inside of an initializer closure, we
         // return when an error/panic occurs.
         // We also use the `data` to require the correct trait (`Init` or `PinInit`) for `$field`.
-        unsafe { $data.$field(::core::ptr::addr_of_mut!((*$slot).$field), init)? };
+        unsafe { $data.$field(&raw mut (*$slot).$field, init)? };
         // Create the drop guard:
         //
         // We rely on macro hygiene to make it impossible for users to access this local variable.
@@ -1218,7 +1218,7 @@ fn assert_zeroable<T: $crate::init::Zeroable>(_: *mut T) {}
         ::kernel::macros::paste! {
             // SAFETY: We forget the guard later when initialization has succeeded.
             let [< __ $field _guard >] = unsafe {
-                $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field))
+                $crate::init::__internal::DropGuard::new(&raw mut (*$slot).$field)
             };
 
             $crate::__init_internal!(init_slot($use_data):
@@ -1241,7 +1241,7 @@ fn assert_zeroable<T: $crate::init::Zeroable>(_: *mut T) {}
         //
         // SAFETY: `slot` is valid, because we are inside of an initializer closure, we
         // return when an error/panic occurs.
-        unsafe { $crate::init::Init::__init(init, ::core::ptr::addr_of_mut!((*$slot).$field))? };
+        unsafe { $crate::init::Init::__init(init, &raw mut (*$slot).$field)? };
         // Create the drop guard:
         //
         // We rely on macro hygiene to make it impossible for users to access this local variable.
@@ -1249,7 +1249,7 @@ fn assert_zeroable<T: $crate::init::Zeroable>(_: *mut T) {}
         ::kernel::macros::paste! {
             // SAFETY: We forget the guard later when initialization has succeeded.
             let [< __ $field _guard >] = unsafe {
-                $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field))
+                $crate::init::__internal::DropGuard::new(&raw mut (*$slot).$field)
             };
 
             $crate::__init_internal!(init_slot():
@@ -1272,7 +1272,7 @@ fn assert_zeroable<T: $crate::init::Zeroable>(_: *mut T) {}
             // Initialize the field.
             //
             // SAFETY: The memory at `slot` is uninitialized.
-            unsafe { ::core::ptr::write(::core::ptr::addr_of_mut!((*$slot).$field), $field) };
+            unsafe { ::core::ptr::write(&raw mut (*$slot).$field, $field) };
         }
         // Create the drop guard:
         //
@@ -1281,7 +1281,7 @@ fn assert_zeroable<T: $crate::init::Zeroable>(_: *mut T) {}
         ::kernel::macros::paste! {
             // SAFETY: We forget the guard later when initialization has succeeded.
             let [< __ $field _guard >] = unsafe {
-                $crate::init::__internal::DropGuard::new(::core::ptr::addr_of_mut!((*$slot).$field))
+                $crate::init::__internal::DropGuard::new(&raw mut (*$slot).$field)
             };
 
             $crate::__init_internal!(init_slot($($use_data)?):
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 03/16] rust: list: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 01/16] rust: enable `raw_ref_op` feature Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 02/16] rust: init: refactor to use `&raw [const|mut]` Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 04/16] rust: task: " Antonio Hickey
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/list.rs                    | 2 +-
 rust/kernel/list/impl_list_item_mod.rs | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/rust/kernel/list.rs b/rust/kernel/list.rs
index c0ed227b8a4f..e98f0820f002 100644
--- a/rust/kernel/list.rs
+++ b/rust/kernel/list.rs
@@ -176,7 +176,7 @@ pub fn new() -> impl PinInit<Self> {
     #[inline]
     unsafe fn fields(me: *mut Self) -> *mut ListLinksFields {
         // SAFETY: The caller promises that the pointer is valid.
-        unsafe { Opaque::raw_get(ptr::addr_of!((*me).inner)) }
+        unsafe { Opaque::raw_get(&raw const (*me).inner) }
     }
 
     /// # Safety
diff --git a/rust/kernel/list/impl_list_item_mod.rs b/rust/kernel/list/impl_list_item_mod.rs
index a0438537cee1..014b6713d59d 100644
--- a/rust/kernel/list/impl_list_item_mod.rs
+++ b/rust/kernel/list/impl_list_item_mod.rs
@@ -49,7 +49,7 @@ macro_rules! impl_has_list_links {
         // SAFETY: The implementation of `raw_get_list_links` only compiles if the field has the
         // right type.
         //
-        // The behavior of `raw_get_list_links` is not changed since the `addr_of_mut!` macro is
+        // The behavior of `raw_get_list_links` is not changed since the `&raw mut` op is
         // equivalent to the pointer offset operation in the trait definition.
         unsafe impl$(<$($implarg),*>)? $crate::list::HasListLinks$(<$id>)? for
             $self $(<$($selfarg),*>)?
@@ -61,7 +61,7 @@ unsafe fn raw_get_list_links(ptr: *mut Self) -> *mut $crate::list::ListLinks$(<$
                 // SAFETY: The caller promises that the pointer is not dangling. We know that this
                 // expression doesn't follow any pointers, as the `offset_of!` invocation above
                 // would otherwise not compile.
-                unsafe { ::core::ptr::addr_of_mut!((*ptr)$(.$field)*) }
+                unsafe { &raw mut (*ptr)$(.$field)* }
             }
         }
     )*};
@@ -103,7 +103,7 @@ macro_rules! impl_has_list_links_self_ptr {
             unsafe fn raw_get_list_links(ptr: *mut Self) -> *mut $crate::list::ListLinks$(<$id>)? {
                 // SAFETY: The caller promises that the pointer is not dangling.
                 let ptr: *mut $crate::list::ListLinksSelfPtr<$item_type $(, $id)?> =
-                    unsafe { ::core::ptr::addr_of_mut!((*ptr).$field) };
+                    unsafe { &raw mut (*ptr).$field };
                 ptr.cast()
             }
         }
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 04/16] rust: task: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (2 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 03/16] rust: list: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-17  4:00   ` Boqun Feng
  2025-03-16  6:14 ` [PATCH v4 05/16] rust: faux: " Antonio Hickey
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/task.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs
index 49012e711942..568b528e2cc4 100644
--- a/rust/kernel/task.rs
+++ b/rust/kernel/task.rs
@@ -257,7 +257,7 @@ pub fn as_ptr(&self) -> *mut bindings::task_struct {
     pub fn group_leader(&self) -> &Task {
         // SAFETY: The group leader of a task never changes after initialization, so reading this
         // field is not a data race.
-        let ptr = unsafe { *ptr::addr_of!((*self.as_ptr()).group_leader) };
+        let ptr = unsafe { (*self.as_ptr()).group_leader };
 
         // SAFETY: The lifetime of the returned task reference is tied to the lifetime of `self`,
         // and given that a task has a reference to its group leader, we know it must be valid for
@@ -269,7 +269,7 @@ pub fn group_leader(&self) -> &Task {
     pub fn pid(&self) -> Pid {
         // SAFETY: The pid of a task never changes after initialization, so reading this field is
         // not a data race.
-        unsafe { *ptr::addr_of!((*self.as_ptr()).pid) }
+        unsafe { (*self.as_ptr()).pid }
     }
 
     /// Returns the UID of the given task.
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 05/16] rust: faux: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (3 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 04/16] rust: task: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 06/16] rust: platform: " Antonio Hickey
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross
  Cc: Antonio Hickey, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/faux.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/faux.rs b/rust/kernel/faux.rs
index 5acc0c02d451..11e56fcbb6ed 100644
--- a/rust/kernel/faux.rs
+++ b/rust/kernel/faux.rs
@@ -7,7 +7,7 @@
 //! C header: [`include/linux/device/faux.h`]
 
 use crate::{bindings, device, error::code::*, prelude::*};
-use core::ptr::{addr_of_mut, null, null_mut, NonNull};
+use core::ptr::{null, null_mut, NonNull};
 
 /// The registration of a faux device.
 ///
@@ -45,7 +45,7 @@ impl AsRef<device::Device> for Registration {
     fn as_ref(&self) -> &device::Device {
         // SAFETY: The underlying `device` in `faux_device` is guaranteed by the C API to be
         // a valid initialized `device`.
-        unsafe { device::Device::as_ref(addr_of_mut!((*self.as_raw()).dev)) }
+        unsafe { device::Device::as_ref(&raw mut (*self.as_raw()).dev) }
     }
 }
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 06/16] rust: platform: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (4 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 05/16] rust: faux: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 07/16] rust: pci: " Antonio Hickey
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross
  Cc: Antonio Hickey, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/platform.rs | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
index 1297f5292ba9..344875ad7b82 100644
--- a/rust/kernel/platform.rs
+++ b/rust/kernel/platform.rs
@@ -14,8 +14,6 @@
     ThisModule,
 };
 
-use core::ptr::addr_of_mut;
-
 /// An adapter for the registration of platform drivers.
 pub struct Adapter<T: Driver>(T);
 
@@ -55,7 +53,7 @@ unsafe fn unregister(pdrv: &Opaque<Self::RegType>) {
 impl<T: Driver + 'static> Adapter<T> {
     extern "C" fn probe_callback(pdev: *mut bindings::platform_device) -> kernel::ffi::c_int {
         // SAFETY: The platform bus only ever calls the probe callback with a valid `pdev`.
-        let dev = unsafe { device::Device::get_device(addr_of_mut!((*pdev).dev)) };
+        let dev = unsafe { device::Device::get_device(&raw mut (*pdev).dev) };
         // SAFETY: `dev` is guaranteed to be embedded in a valid `struct platform_device` by the
         // call above.
         let mut pdev = unsafe { Device::from_dev(dev) };
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 07/16] rust: pci: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (5 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 06/16] rust: platform: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 08/16] rust: kunit: " Antonio Hickey
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 UTC (permalink / raw)
  To: Bjorn Helgaas, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich
  Cc: Antonio Hickey, linux-pci, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/pci.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index f7b2743828ae..6cb9ed1e7cbf 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -17,7 +17,7 @@
     types::{ARef, ForeignOwnable, Opaque},
     ThisModule,
 };
-use core::{ops::Deref, ptr::addr_of_mut};
+use core::ops::Deref;
 use kernel::prelude::*;
 
 /// An adapter for the registration of PCI drivers.
@@ -60,7 +60,7 @@ extern "C" fn probe_callback(
     ) -> kernel::ffi::c_int {
         // SAFETY: The PCI bus only ever calls the probe callback with a valid pointer to a
         // `struct pci_dev`.
-        let dev = unsafe { device::Device::get_device(addr_of_mut!((*pdev).dev)) };
+        let dev = unsafe { device::Device::get_device(&raw mut (*pdev).dev) };
         // SAFETY: `dev` is guaranteed to be embedded in a valid `struct pci_dev` by the call
         // above.
         let mut pdev = unsafe { Device::from_dev(dev) };
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 08/16] rust: kunit: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (6 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 07/16] rust: pci: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-18  8:02   ` David Gow
  2025-03-16  6:14 ` [PATCH v4 09/16] rust: workqueue: " Antonio Hickey
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 UTC (permalink / raw)
  To: Brendan Higgins, David Gow, Rae Moar, Miguel Ojeda, Alex Gaynor,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich
  Cc: Antonio Hickey, linux-kselftest, kunit-dev, rust-for-linux,
	linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/kunit.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/kunit.rs b/rust/kernel/kunit.rs
index 824da0e9738a..a17ef3b2e860 100644
--- a/rust/kernel/kunit.rs
+++ b/rust/kernel/kunit.rs
@@ -128,9 +128,9 @@ unsafe impl Sync for UnaryAssert {}
             unsafe {
                 $crate::bindings::__kunit_do_failed_assertion(
                     kunit_test,
-                    core::ptr::addr_of!(LOCATION.0),
+                    &raw const LOCATION.0,
                     $crate::bindings::kunit_assert_type_KUNIT_ASSERTION,
-                    core::ptr::addr_of!(ASSERTION.0.assert),
+                    &raw const ASSERTION.0.assert,
                     Some($crate::bindings::kunit_unary_assert_format),
                     core::ptr::null(),
                 );
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 09/16] rust: workqueue: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (7 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 08/16] rust: kunit: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-17  4:21   ` Boqun Feng
  2025-03-16  6:14 ` [PATCH v4 10/16] rust: rbtree: " Antonio Hickey
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/workqueue.rs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
index 0cd100d2aefb..4e27df324d26 100644
--- a/rust/kernel/workqueue.rs
+++ b/rust/kernel/workqueue.rs
@@ -401,9 +401,10 @@ pub fn new(name: &'static CStr, key: &'static LockClassKey) -> impl PinInit<Self
     pub unsafe fn raw_get(ptr: *const Self) -> *mut bindings::work_struct {
         // SAFETY: The caller promises that the pointer is aligned and not dangling.
         //
-        // A pointer cast would also be ok due to `#[repr(transparent)]`. We use `addr_of!` so that
-        // the compiler does not complain that the `work` field is unused.
-        unsafe { Opaque::raw_get(core::ptr::addr_of!((*ptr).work)) }
+        // A pointer cast would also be ok due to `#[repr(transparent)]`. We use
+        // `&raw const (*ptr).work` so that the compiler does not complain that the
+        // `work` field is unused.
+        unsafe { Opaque::raw_get(&raw const (*ptr).work) }
     }
 }
 
@@ -510,7 +511,7 @@ macro_rules! impl_has_work {
             unsafe fn raw_get_work(ptr: *mut Self) -> *mut $crate::workqueue::Work<$work_type $(, $id)?> {
                 // SAFETY: The caller promises that the pointer is not dangling.
                 unsafe {
-                    ::core::ptr::addr_of_mut!((*ptr).$field)
+                    &raw mut (*ptr).$field
                 }
             }
         }
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 10/16] rust: rbtree: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (8 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 09/16] rust: workqueue: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 11/16] rust: net: phy: " Antonio Hickey
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/rbtree.rs | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/rust/kernel/rbtree.rs b/rust/kernel/rbtree.rs
index 1ea25c7092fb..b0ad35663cb0 100644
--- a/rust/kernel/rbtree.rs
+++ b/rust/kernel/rbtree.rs
@@ -11,7 +11,7 @@
     cmp::{Ord, Ordering},
     marker::PhantomData,
     mem::MaybeUninit,
-    ptr::{addr_of_mut, from_mut, NonNull},
+    ptr::{from_mut, NonNull},
 };
 
 /// A red-black tree with owned nodes.
@@ -238,7 +238,7 @@ pub fn values_mut(&mut self) -> impl Iterator<Item = &'_ mut V> {
 
     /// Returns a cursor over the tree nodes, starting with the smallest key.
     pub fn cursor_front(&mut self) -> Option<Cursor<'_, K, V>> {
-        let root = addr_of_mut!(self.root);
+        let root = &raw mut self.root;
         // SAFETY: `self.root` is always a valid root node
         let current = unsafe { bindings::rb_first(root) };
         NonNull::new(current).map(|current| {
@@ -253,7 +253,7 @@ pub fn cursor_front(&mut self) -> Option<Cursor<'_, K, V>> {
 
     /// Returns a cursor over the tree nodes, starting with the largest key.
     pub fn cursor_back(&mut self) -> Option<Cursor<'_, K, V>> {
-        let root = addr_of_mut!(self.root);
+        let root = &raw mut self.root;
         // SAFETY: `self.root` is always a valid root node
         let current = unsafe { bindings::rb_last(root) };
         NonNull::new(current).map(|current| {
@@ -459,7 +459,7 @@ pub fn cursor_lower_bound(&mut self, key: &K) -> Option<Cursor<'_, K, V>>
         let best = best_match?;
 
         // SAFETY: `best` is a non-null node so it is valid by the type invariants.
-        let links = unsafe { addr_of_mut!((*best.as_ptr()).links) };
+        let links = unsafe { &raw mut (*best.as_ptr()).links };
 
         NonNull::new(links).map(|current| {
             // INVARIANT:
@@ -767,7 +767,7 @@ pub fn remove_current(self) -> (Option<Self>, RBTreeNode<K, V>) {
         let node = RBTreeNode { node };
         // SAFETY: The reference to the tree used to create the cursor outlives the cursor, so
         // the tree cannot change. By the tree invariant, all nodes are valid.
-        unsafe { bindings::rb_erase(&mut (*this).links, addr_of_mut!(self.tree.root)) };
+        unsafe { bindings::rb_erase(&mut (*this).links, &raw mut self.tree.root) };
 
         let current = match (prev, next) {
             (_, Some(next)) => next,
@@ -803,7 +803,7 @@ fn remove_neighbor(&mut self, direction: Direction) -> Option<RBTreeNode<K, V>>
             let neighbor = neighbor.as_ptr();
             // SAFETY: The reference to the tree used to create the cursor outlives the cursor, so
             // the tree cannot change. By the tree invariant, all nodes are valid.
-            unsafe { bindings::rb_erase(neighbor, addr_of_mut!(self.tree.root)) };
+            unsafe { bindings::rb_erase(neighbor, &raw mut self.tree.root) };
             // SAFETY: By the type invariant of `Self`, all non-null `rb_node` pointers stored in `self`
             // point to the links field of `Node<K, V>` objects.
             let this = unsafe { container_of!(neighbor, Node<K, V>, links) }.cast_mut();
@@ -918,7 +918,7 @@ unsafe fn to_key_value_raw<'b>(node: NonNull<bindings::rb_node>) -> (&'b K, *mut
         let k = unsafe { &(*this).key };
         // SAFETY: The passed `node` is the current node or a non-null neighbor,
         // thus `this` is valid by the type invariants.
-        let v = unsafe { addr_of_mut!((*this).value) };
+        let v = unsafe { &raw mut (*this).value };
         (k, v)
     }
 }
@@ -1027,7 +1027,7 @@ fn next(&mut self) -> Option<Self::Item> {
         self.next = unsafe { bindings::rb_next(self.next) };
 
         // SAFETY: By the same reasoning above, it is safe to dereference the node.
-        Some(unsafe { (addr_of_mut!((*cur).key), addr_of_mut!((*cur).value)) })
+        Some(unsafe { (&raw mut (*cur).key, &raw mut (*cur).value) })
     }
 }
 
@@ -1170,7 +1170,7 @@ fn insert(self, node: RBTreeNode<K, V>) -> &'a mut V {
 
         // SAFETY: `node` is valid at least until we call `Box::from_raw`, which only happens when
         // the node is removed or replaced.
-        let node_links = unsafe { addr_of_mut!((*node).links) };
+        let node_links = unsafe { &raw mut (*node).links };
 
         // INVARIANT: We are linking in a new node, which is valid. It remains valid because we
         // "forgot" it with `Box::into_raw`.
@@ -1178,7 +1178,7 @@ fn insert(self, node: RBTreeNode<K, V>) -> &'a mut V {
         unsafe { bindings::rb_link_node(node_links, self.parent, self.child_field_of_parent) };
 
         // SAFETY: All pointers are valid. `node` has just been inserted into the tree.
-        unsafe { bindings::rb_insert_color(node_links, addr_of_mut!((*self.rbtree).root)) };
+        unsafe { bindings::rb_insert_color(node_links, &raw mut (*self.rbtree).root) };
 
         // SAFETY: The node is valid until we remove it from the tree.
         unsafe { &mut (*node).value }
@@ -1261,7 +1261,7 @@ fn replace(self, node: RBTreeNode<K, V>) -> RBTreeNode<K, V> {
 
         // SAFETY: `node` is valid at least until we call `Box::from_raw`, which only happens when
         // the node is removed or replaced.
-        let new_node_links = unsafe { addr_of_mut!((*node).links) };
+        let new_node_links = unsafe { &raw mut (*node).links };
 
         // SAFETY: This updates the pointers so that `new_node_links` is in the tree where
         // `self.node_links` used to be.
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 11/16] rust: net: phy: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (9 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 10/16] rust: rbtree: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 12/16] rust: sync: arc: " Antonio Hickey
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 UTC (permalink / raw)
  To: FUJITA Tomonori, Trevor Gross, Miguel Ojeda, Alex Gaynor,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Danilo Krummrich
  Cc: Antonio Hickey, netdev, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/net/phy.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs
index a59469c785e3..757db052cc09 100644
--- a/rust/kernel/net/phy.rs
+++ b/rust/kernel/net/phy.rs
@@ -7,7 +7,7 @@
 //! C headers: [`include/linux/phy.h`](srctree/include/linux/phy.h).
 
 use crate::{error::*, prelude::*, types::Opaque};
-use core::{marker::PhantomData, ptr::addr_of_mut};
+use core::marker::PhantomData;
 
 pub mod reg;
 
@@ -285,7 +285,7 @@ impl AsRef<kernel::device::Device> for Device {
     fn as_ref(&self) -> &kernel::device::Device {
         let phydev = self.0.get();
         // SAFETY: The struct invariant ensures that `mdio.dev` is valid.
-        unsafe { kernel::device::Device::as_ref(addr_of_mut!((*phydev).mdio.dev)) }
+        unsafe { kernel::device::Device::as_ref(&raw mut (*phydev).mdio.dev) }
     }
 }
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 12/16] rust: sync: arc: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (10 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 11/16] rust: net: phy: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 13/16] rust: jump_label: " Antonio Hickey
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/sync/arc.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
index 3cefda7a4372..81d8b0f84957 100644
--- a/rust/kernel/sync/arc.rs
+++ b/rust/kernel/sync/arc.rs
@@ -243,7 +243,7 @@ pub fn into_raw(self) -> *const T {
         let ptr = self.ptr.as_ptr();
         core::mem::forget(self);
         // SAFETY: The pointer is valid.
-        unsafe { core::ptr::addr_of!((*ptr).data) }
+        unsafe { &raw const (*ptr).data }
     }
 
     /// Recreates an [`Arc`] instance previously deconstructed via [`Arc::into_raw`].
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 13/16] rust: jump_label: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (11 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 12/16] rust: sync: arc: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 14/16] rust: fs: file: " Antonio Hickey
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/jump_label.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/jump_label.rs b/rust/kernel/jump_label.rs
index 4e974c768dbd..ca10abae0eee 100644
--- a/rust/kernel/jump_label.rs
+++ b/rust/kernel/jump_label.rs
@@ -20,8 +20,8 @@
 #[macro_export]
 macro_rules! static_branch_unlikely {
     ($key:path, $keytyp:ty, $field:ident) => {{
-        let _key: *const $keytyp = ::core::ptr::addr_of!($key);
-        let _key: *const $crate::bindings::static_key_false = ::core::ptr::addr_of!((*_key).$field);
+        let _key: *const $keytyp = &raw const $key;
+        let _key: *const $crate::bindings::static_key_false = &raw const (*_key).$field;
         let _key: *const $crate::bindings::static_key = _key.cast();
 
         #[cfg(not(CONFIG_JUMP_LABEL))]
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 14/16] rust: fs: file: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (12 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 13/16] rust: jump_label: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-17  4:33   ` Boqun Feng
  2025-03-16  6:14 ` [PATCH v4 15/16] rust: block: " Antonio Hickey
  2025-03-16  6:14 ` [PATCH v4 16/16] rust: clippy: disable `addr_of[_mut]!` macros Antonio Hickey
  15 siblings, 1 reply; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/fs/file.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/fs/file.rs b/rust/kernel/fs/file.rs
index ed57e0137cdb..7ee4830b67f3 100644
--- a/rust/kernel/fs/file.rs
+++ b/rust/kernel/fs/file.rs
@@ -331,7 +331,7 @@ pub fn flags(&self) -> u32 {
         // SAFETY: The file is valid because the shared reference guarantees a nonzero refcount.
         //
         // FIXME(read_once): Replace with `read_once` when available on the Rust side.
-        unsafe { core::ptr::addr_of!((*self.as_ptr()).f_flags).read_volatile() }
+        unsafe { (&raw const (*self.as_ptr()).f_flags).read_volatile() }
     }
 }
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 15/16] rust: block: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (13 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 14/16] rust: fs: file: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-17  4:04   ` Boqun Feng
  2025-03-16  6:14 ` [PATCH v4 16/16] rust: clippy: disable `addr_of[_mut]!` macros Antonio Hickey
  15 siblings, 1 reply; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 UTC (permalink / raw)
  To: Andreas Hindborg, Boqun Feng, Miguel Ojeda, Alex Gaynor, Gary Guo,
	Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
	Danilo Krummrich
  Cc: Antonio Hickey, linux-block, rust-for-linux, linux-kernel

Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
with `&raw const place` and `&raw mut place` respectively.

This will allow us to reduce macro complexity, and improve consistency
with existing reference syntax as `&raw const`, `&raw mut` are similar
to `&`, `&mut` making it fit more naturally with other existing code.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 rust/kernel/block/mq/request.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/kernel/block/mq/request.rs b/rust/kernel/block/mq/request.rs
index 7943f43b9575..4a5b7ec914ef 100644
--- a/rust/kernel/block/mq/request.rs
+++ b/rust/kernel/block/mq/request.rs
@@ -12,7 +12,7 @@
 };
 use core::{
     marker::PhantomData,
-    ptr::{addr_of_mut, NonNull},
+    ptr::NonNull,
     sync::atomic::{AtomicU64, Ordering},
 };
 
@@ -187,7 +187,7 @@ pub(crate) fn refcount(&self) -> &AtomicU64 {
     pub(crate) unsafe fn refcount_ptr(this: *mut Self) -> *mut AtomicU64 {
         // SAFETY: Because of the safety requirements of this function, the
         // field projection is safe.
-        unsafe { addr_of_mut!((*this).refcount) }
+        unsafe { &raw mut (*this).refcount }
     }
 }
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH v4 16/16] rust: clippy: disable `addr_of[_mut]!` macros
  2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
                   ` (14 preceding siblings ...)
  2025-03-16  6:14 ` [PATCH v4 15/16] rust: block: " Antonio Hickey
@ 2025-03-16  6:14 ` Antonio Hickey
  2025-03-16  9:50   ` Benno Lossin
  2025-03-16 12:57   ` Tamir Duberstein
  15 siblings, 2 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-16  6:14 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: Antonio Hickey, rust-for-linux, linux-kernel

With the `raw_ref_op` feature enabled we no longer want to
allow use of `addr_of!` and `addr_of_mut!` macros.

We instead want to use `&raw` and `&raw mut` to get raw
pointers to a place.

Note that this lint isn't currently reliable, but we enable
it nevertheless because:
1. Document that one shouldn't use the `addr_of[_mut]!` macros.
2. When the lint becomes useful we will already have it enabled.

Suggested-by: Benno Lossin <benno.lossin@proton.me>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Link: https://github.com/rust-lang/rust-clippy/issues/11431
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
 .clippy.toml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.clippy.toml b/.clippy.toml
index 815c94732ed7..95c73959f039 100644
--- a/.clippy.toml
+++ b/.clippy.toml
@@ -8,4 +8,8 @@ disallowed-macros = [
     # The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate
     # it here, see: https://github.com/rust-lang/rust-clippy/issues/11303.
     { path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool" },
+    # With `raw_ref_op` feature enabled we no longer want to allow use of `addr_of!`
+    # and `addr_of_mut!` macros, but instead use `&raw` or `&raw mut`.
+    { path = "core::ptr::addr_of_mut", reason = "use `&raw mut` instead `addr_of_mut!`" },
+    { path = "core::ptr::addr_of", reason = "use `&raw` instead `addr_of!`" },
 ]
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 16/16] rust: clippy: disable `addr_of[_mut]!` macros
  2025-03-16  6:14 ` [PATCH v4 16/16] rust: clippy: disable `addr_of[_mut]!` macros Antonio Hickey
@ 2025-03-16  9:50   ` Benno Lossin
  2025-03-16 12:57   ` Tamir Duberstein
  1 sibling, 0 replies; 32+ messages in thread
From: Benno Lossin @ 2025-03-16  9:50 UTC (permalink / raw)
  To: Antonio Hickey, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich
  Cc: Antonio Hickey, rust-for-linux, linux-kernel

On Sun Mar 16, 2025 at 7:14 AM CET, Antonio Hickey wrote:
> With the `raw_ref_op` feature enabled we no longer want to
> allow use of `addr_of!` and `addr_of_mut!` macros.
>
> We instead want to use `&raw` and `&raw mut` to get raw

`&raw const`

> pointers to a place.
>
> Note that this lint isn't currently reliable, but we enable
> it nevertheless because:
> 1. Document that one shouldn't use the `addr_of[_mut]!` macros.
> 2. When the lint becomes useful we will already have it enabled.
>
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Link: https://github.com/rust-lang/rust-clippy/issues/11431
> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
> ---
>  .clippy.toml | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/.clippy.toml b/.clippy.toml
> index 815c94732ed7..95c73959f039 100644
> --- a/.clippy.toml
> +++ b/.clippy.toml
> @@ -8,4 +8,8 @@ disallowed-macros = [
>      # The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate
>      # it here, see: https://github.com/rust-lang/rust-clippy/issues/11303.
>      { path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool" },
> +    # With `raw_ref_op` feature enabled we no longer want to allow use of `addr_of!`
> +    # and `addr_of_mut!` macros, but instead use `&raw` or `&raw mut`.
> +    { path = "core::ptr::addr_of_mut", reason = "use `&raw mut` instead `addr_of_mut!`" },
> +    { path = "core::ptr::addr_of", reason = "use `&raw` instead `addr_of!`" },

`&raw const`

---
Cheers,
Benno

>  ]



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 02/16] rust: init: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 ` [PATCH v4 02/16] rust: init: refactor to use `&raw [const|mut]` Antonio Hickey
@ 2025-03-16 10:14   ` Benno Lossin
  0 siblings, 0 replies; 32+ messages in thread
From: Benno Lossin @ 2025-03-16 10:14 UTC (permalink / raw)
  To: Antonio Hickey, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich
  Cc: Antonio Hickey, rust-for-linux, linux-kernel

On Sun Mar 16, 2025 at 7:14 AM CET, Antonio Hickey wrote:
> Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
> with `&raw const place` and `&raw mut place` respectively.
>
> This will allow us to reduce macro complexity, and improve consistency
> with existing reference syntax as `&raw const`, `&raw mut` are similar
> to `&`, `&mut` making it fit more naturally with other existing code.
>
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
> ---
>  rust/kernel/init.rs        |  8 ++++----
>  rust/kernel/init/macros.rs | 28 ++++++++++++++--------------
>  2 files changed, 18 insertions(+), 18 deletions(-)

When compiling this on Rust 1.78, I get:

    error[E0658]: raw address of syntax is experimental
      --> drivers/block/rnull.rs:57:9
       |
    57 | /         try_pin_init!(Self {
    58 | |             _disk <- new_mutex!(disk?, "nullb:disk"),
    59 | |         })
       | |__________^
       |
       = note: see issue #64490 <https://github.com/rust-lang/rust/issues/64490> for more information
       = help: add `#![feature(raw_ref_op)]` to the crate attributes to enable
       = note: this compiler was built on 2024-04-29; consider upgrading it if it is out of date
       = note: this error originates in the macro `$crate::__init_internal` which comes from the expansion of the macro `try_pin_init` (in Nightly builds, run with -Z macro-backtrace for more info)

So the previous commit also needs to affect doctests.

---
Cheers,
Benno


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 16/16] rust: clippy: disable `addr_of[_mut]!` macros
  2025-03-16  6:14 ` [PATCH v4 16/16] rust: clippy: disable `addr_of[_mut]!` macros Antonio Hickey
  2025-03-16  9:50   ` Benno Lossin
@ 2025-03-16 12:57   ` Tamir Duberstein
  1 sibling, 0 replies; 32+ messages in thread
From: Tamir Duberstein @ 2025-03-16 12:57 UTC (permalink / raw)
  To: Antonio Hickey
  Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Antonio Hickey, rust-for-linux,
	linux-kernel

On Sun, Mar 16, 2025 at 2:38 AM Antonio Hickey <contact@byte-forge.io> wrote:
>
> With the `raw_ref_op` feature enabled we no longer want to
> allow use of `addr_of!` and `addr_of_mut!` macros.
>
> We instead want to use `&raw` and `&raw mut` to get raw
> pointers to a place.
>
> Note that this lint isn't currently reliable, but we enable
> it nevertheless because:
> 1. Document that one shouldn't use the `addr_of[_mut]!` macros.
> 2. When the lint becomes useful we will already have it enabled.
>
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Link: https://github.com/rust-lang/rust-clippy/issues/11431
> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
> ---
>  .clippy.toml | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/.clippy.toml b/.clippy.toml
> index 815c94732ed7..95c73959f039 100644
> --- a/.clippy.toml
> +++ b/.clippy.toml
> @@ -8,4 +8,8 @@ disallowed-macros = [
>      # The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate
>      # it here, see: https://github.com/rust-lang/rust-clippy/issues/11303.
>      { path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool" },
> +    # With `raw_ref_op` feature enabled we no longer want to allow use of `addr_of!`
> +    # and `addr_of_mut!` macros, but instead use `&raw` or `&raw mut`.
> +    { path = "core::ptr::addr_of_mut", reason = "use `&raw mut` instead `addr_of_mut!`" },
> +    { path = "core::ptr::addr_of", reason = "use `&raw` instead `addr_of!`" },
>  ]
> --
> 2.48.1

Consider using the word "disallow" rather than "disable" in the
subject line of this commit, given that this is the word used in the
clippy config.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 04/16] rust: task: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 ` [PATCH v4 04/16] rust: task: " Antonio Hickey
@ 2025-03-17  4:00   ` Boqun Feng
  0 siblings, 0 replies; 32+ messages in thread
From: Boqun Feng @ 2025-03-17  4:00 UTC (permalink / raw)
  To: Antonio Hickey
  Cc: Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Antonio Hickey, rust-for-linux, linux-kernel

Hi Antonio,

On Sun, Mar 16, 2025 at 02:14:13AM -0400, Antonio Hickey wrote:
> Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
> with `&raw const place` and `&raw mut place` respectively.
> 
> This will allow us to reduce macro complexity, and improve consistency
> with existing reference syntax as `&raw const`, `&raw mut` are similar
> to `&`, `&mut` making it fit more naturally with other existing code.
> 
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148

You need to change the above because this patch doesn't replace
addr_of_{,mut}!() with `&raw`, and also the patch title. Thanks!

Regards,
Boqun

> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
> ---
>  rust/kernel/task.rs | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs
> index 49012e711942..568b528e2cc4 100644
> --- a/rust/kernel/task.rs
> +++ b/rust/kernel/task.rs
> @@ -257,7 +257,7 @@ pub fn as_ptr(&self) -> *mut bindings::task_struct {
>      pub fn group_leader(&self) -> &Task {
>          // SAFETY: The group leader of a task never changes after initialization, so reading this
>          // field is not a data race.
> -        let ptr = unsafe { *ptr::addr_of!((*self.as_ptr()).group_leader) };
> +        let ptr = unsafe { (*self.as_ptr()).group_leader };
>  
>          // SAFETY: The lifetime of the returned task reference is tied to the lifetime of `self`,
>          // and given that a task has a reference to its group leader, we know it must be valid for
> @@ -269,7 +269,7 @@ pub fn group_leader(&self) -> &Task {
>      pub fn pid(&self) -> Pid {
>          // SAFETY: The pid of a task never changes after initialization, so reading this field is
>          // not a data race.
> -        unsafe { *ptr::addr_of!((*self.as_ptr()).pid) }
> +        unsafe { (*self.as_ptr()).pid }
>      }
>  
>      /// Returns the UID of the given task.
> -- 
> 2.48.1
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 15/16] rust: block: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 ` [PATCH v4 15/16] rust: block: " Antonio Hickey
@ 2025-03-17  4:04   ` Boqun Feng
  0 siblings, 0 replies; 32+ messages in thread
From: Boqun Feng @ 2025-03-17  4:04 UTC (permalink / raw)
  To: Antonio Hickey
  Cc: Andreas Hindborg, Miguel Ojeda, Alex Gaynor, Gary Guo,
	Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Antonio Hickey, linux-block, rust-for-linux,
	linux-kernel

On Sun, Mar 16, 2025 at 02:14:24AM -0400, Antonio Hickey wrote:
> Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
> with `&raw const place` and `&raw mut place` respectively.
> 
> This will allow us to reduce macro complexity, and improve consistency
> with existing reference syntax as `&raw const`, `&raw mut` are similar
> to `&`, `&mut` making it fit more naturally with other existing code.
> 
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

> ---
>  rust/kernel/block/mq/request.rs | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/rust/kernel/block/mq/request.rs b/rust/kernel/block/mq/request.rs
> index 7943f43b9575..4a5b7ec914ef 100644
> --- a/rust/kernel/block/mq/request.rs
> +++ b/rust/kernel/block/mq/request.rs
> @@ -12,7 +12,7 @@
>  };
>  use core::{
>      marker::PhantomData,
> -    ptr::{addr_of_mut, NonNull},
> +    ptr::NonNull,
>      sync::atomic::{AtomicU64, Ordering},
>  };
>  
> @@ -187,7 +187,7 @@ pub(crate) fn refcount(&self) -> &AtomicU64 {
>      pub(crate) unsafe fn refcount_ptr(this: *mut Self) -> *mut AtomicU64 {
>          // SAFETY: Because of the safety requirements of this function, the
>          // field projection is safe.
> -        unsafe { addr_of_mut!((*this).refcount) }
> +        unsafe { &raw mut (*this).refcount }
>      }
>  }
>  
> -- 
> 2.48.1
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 09/16] rust: workqueue: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 ` [PATCH v4 09/16] rust: workqueue: " Antonio Hickey
@ 2025-03-17  4:21   ` Boqun Feng
  2025-03-17  4:32     ` Boqun Feng
  0 siblings, 1 reply; 32+ messages in thread
From: Boqun Feng @ 2025-03-17  4:21 UTC (permalink / raw)
  To: Antonio Hickey
  Cc: Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Antonio Hickey, rust-for-linux, linux-kernel

On Sun, Mar 16, 2025 at 02:14:18AM -0400, Antonio Hickey wrote:
> Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
> with `&raw const place` and `&raw mut place` respectively.
> 
> This will allow us to reduce macro complexity, and improve consistency
> with existing reference syntax as `&raw const`, `&raw mut` are similar
> to `&`, `&mut` making it fit more naturally with other existing code.
> 
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
> ---
>  rust/kernel/workqueue.rs | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
> index 0cd100d2aefb..4e27df324d26 100644
> --- a/rust/kernel/workqueue.rs
> +++ b/rust/kernel/workqueue.rs
> @@ -401,9 +401,10 @@ pub fn new(name: &'static CStr, key: &'static LockClassKey) -> impl PinInit<Self
>      pub unsafe fn raw_get(ptr: *const Self) -> *mut bindings::work_struct {
>          // SAFETY: The caller promises that the pointer is aligned and not dangling.
>          //
> -        // A pointer cast would also be ok due to `#[repr(transparent)]`. We use `addr_of!` so that
> -        // the compiler does not complain that the `work` field is unused.
> -        unsafe { Opaque::raw_get(core::ptr::addr_of!((*ptr).work)) }
> +        // A pointer cast would also be ok due to `#[repr(transparent)]`. We use
> +        // `&raw const (*ptr).work` so that the compiler does not complain that the
> +        // `work` field is unused.

I think we can actually use the pointer casting here. Because now we use
pin-init for Work initialization, so `work` field is always used.

Could you replace this with a:

	// CAST: `Work` is transparent to `bindings::work_struct`.
	ptr.cast_mut().cast()

in a separate patch?

Thanks!

Regards,
Boqun

> +        unsafe { Opaque::raw_get(&raw const (*ptr).work) }
>      }
>  }
>  
> @@ -510,7 +511,7 @@ macro_rules! impl_has_work {
>              unsafe fn raw_get_work(ptr: *mut Self) -> *mut $crate::workqueue::Work<$work_type $(, $id)?> {
>                  // SAFETY: The caller promises that the pointer is not dangling.
>                  unsafe {
> -                    ::core::ptr::addr_of_mut!((*ptr).$field)
> +                    &raw mut (*ptr).$field
>                  }
>              }
>          }
> -- 
> 2.48.1
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 09/16] rust: workqueue: refactor to use `&raw [const|mut]`
  2025-03-17  4:21   ` Boqun Feng
@ 2025-03-17  4:32     ` Boqun Feng
  0 siblings, 0 replies; 32+ messages in thread
From: Boqun Feng @ 2025-03-17  4:32 UTC (permalink / raw)
  To: Antonio Hickey
  Cc: Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Antonio Hickey, rust-for-linux, linux-kernel

On Sun, Mar 16, 2025 at 09:21:00PM -0700, Boqun Feng wrote:
> On Sun, Mar 16, 2025 at 02:14:18AM -0400, Antonio Hickey wrote:
> > Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
> > with `&raw const place` and `&raw mut place` respectively.
> > 
> > This will allow us to reduce macro complexity, and improve consistency
> > with existing reference syntax as `&raw const`, `&raw mut` are similar
> > to `&`, `&mut` making it fit more naturally with other existing code.
> > 
> > Suggested-by: Benno Lossin <benno.lossin@proton.me>
> > Link: https://github.com/Rust-for-Linux/linux/issues/1148
> > Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
> > ---
> >  rust/kernel/workqueue.rs | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
> > index 0cd100d2aefb..4e27df324d26 100644
> > --- a/rust/kernel/workqueue.rs
> > +++ b/rust/kernel/workqueue.rs
> > @@ -401,9 +401,10 @@ pub fn new(name: &'static CStr, key: &'static LockClassKey) -> impl PinInit<Self
> >      pub unsafe fn raw_get(ptr: *const Self) -> *mut bindings::work_struct {
> >          // SAFETY: The caller promises that the pointer is aligned and not dangling.
> >          //
> > -        // A pointer cast would also be ok due to `#[repr(transparent)]`. We use `addr_of!` so that
> > -        // the compiler does not complain that the `work` field is unused.
> > -        unsafe { Opaque::raw_get(core::ptr::addr_of!((*ptr).work)) }
> > +        // A pointer cast would also be ok due to `#[repr(transparent)]`. We use
> > +        // `&raw const (*ptr).work` so that the compiler does not complain that the
> > +        // `work` field is unused.
> 
> I think we can actually use the pointer casting here. Because now we use
> pin-init for Work initialization, so `work` field is always used.
> 
> Could you replace this with a:
> 
> 	// CAST: `Work` is transparent to `bindings::work_struct`.
> 	ptr.cast_mut().cast()
> 
> in a separate patch?
> 

Hmm.. think more about this, this raw_get() function can be a safe
function because it's just a pointer casting? I've checked the
callsites, it doesn't seems that they need the pointer provenance
from Opaque::raw_get().

Alice, any objection? Am I missing something subtle here? We can also
remove this function at all, and use cast() in __enqueue()s.

Regards,
Boqun

> Thanks!
> 
> Regards,
> Boqun
> 
> > +        unsafe { Opaque::raw_get(&raw const (*ptr).work) }
> >      }
> >  }
> >  
> > @@ -510,7 +511,7 @@ macro_rules! impl_has_work {
> >              unsafe fn raw_get_work(ptr: *mut Self) -> *mut $crate::workqueue::Work<$work_type $(, $id)?> {
> >                  // SAFETY: The caller promises that the pointer is not dangling.
> >                  unsafe {
> > -                    ::core::ptr::addr_of_mut!((*ptr).$field)
> > +                    &raw mut (*ptr).$field
> >                  }
> >              }
> >          }
> > -- 
> > 2.48.1
> > 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 14/16] rust: fs: file: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 ` [PATCH v4 14/16] rust: fs: file: " Antonio Hickey
@ 2025-03-17  4:33   ` Boqun Feng
  0 siblings, 0 replies; 32+ messages in thread
From: Boqun Feng @ 2025-03-17  4:33 UTC (permalink / raw)
  To: Antonio Hickey
  Cc: Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Antonio Hickey, rust-for-linux, linux-kernel

On Sun, Mar 16, 2025 at 02:14:23AM -0400, Antonio Hickey wrote:
> Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
> with `&raw const place` and `&raw mut place` respectively.
> 
> This will allow us to reduce macro complexity, and improve consistency
> with existing reference syntax as `&raw const`, `&raw mut` are similar
> to `&`, `&mut` making it fit more naturally with other existing code.
> 
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

> ---
>  rust/kernel/fs/file.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/rust/kernel/fs/file.rs b/rust/kernel/fs/file.rs
> index ed57e0137cdb..7ee4830b67f3 100644
> --- a/rust/kernel/fs/file.rs
> +++ b/rust/kernel/fs/file.rs
> @@ -331,7 +331,7 @@ pub fn flags(&self) -> u32 {
>          // SAFETY: The file is valid because the shared reference guarantees a nonzero refcount.
>          //
>          // FIXME(read_once): Replace with `read_once` when available on the Rust side.
> -        unsafe { core::ptr::addr_of!((*self.as_ptr()).f_flags).read_volatile() }
> +        unsafe { (&raw const (*self.as_ptr()).f_flags).read_volatile() }
>      }
>  }
>  
> -- 
> 2.48.1
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 08/16] rust: kunit: refactor to use `&raw [const|mut]`
  2025-03-16  6:14 ` [PATCH v4 08/16] rust: kunit: " Antonio Hickey
@ 2025-03-18  8:02   ` David Gow
  2025-03-20  1:39     ` Antonio Hickey
  2025-03-20 23:15     ` Miguel Ojeda
  0 siblings, 2 replies; 32+ messages in thread
From: David Gow @ 2025-03-18  8:02 UTC (permalink / raw)
  To: Antonio Hickey
  Cc: Brendan Higgins, Rae Moar, Miguel Ojeda, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Antonio Hickey,
	linux-kselftest, kunit-dev, rust-for-linux, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]

On Sun, 16 Mar 2025 at 14:20, Antonio Hickey <contact@byte-forge.io> wrote:
>
> Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
> with `&raw const place` and `&raw mut place` respectively.
>
> This will allow us to reduce macro complexity, and improve consistency
> with existing reference syntax as `&raw const`, `&raw mut` are similar
> to `&`, `&mut` making it fit more naturally with other existing code.
>
> Suggested-by: Benno Lossin <benno.lossin@proton.me>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
> ---

Thanks, Antonio.

So this looks fine, but it's also a bit annoying, as the remaining
KUnit/Rust integration patches[1] were recently updated to use
`addr_of_mut!()`, so either this patch, or those, will need updating.

In general, I think changes such as those in this series are going to
get progressively more prone to conflicts as Rust is adopted by other
subsystems, as the 'rust' tree won't be the only one carrying changes
which could be affected. Maybe in the future it'd make sense to split
these up into a series which enables the new feature, and only then
put the warnings in place in the next version?

In the KUnit case in particular, since the patches haven't actually
been merged yet, we have three options:
- Merge this into rust-next, and send out a new version of the KUnit
patches which depend on it, which then are also carried in rust-next,
or delayed (again) to 6.16. I suspect given how close to the merge
window we are, the delay is more likely.
- Merge the KUnit changes as-is (either into rust-next or
kselftest/kunit), and send out a new version of this series which also
updates it (probably in 6.16, but maybe sooner if everything goes via
rust-next).
- Merge both, and accept that there'll be some clippy errors until a
follow-up patch fixing them is sent and merged.

As someone with a vested interest in the KUnit changes, and at best a
mild academic interest in the addr_of_muit!() deprecation, my
preferences are with the latter two options. (I'd also, in general,
whinge that the frequency of new Rust versions / warnings is high
enough that it's taking a not insignificant portion of the limited
time I have working on Rust things to understand and deal with the
churn.)

Regardless, apart from the minor irritation of having to learn yet
another new syntax, I have no objections to this patch in particular.

Reviewed-by: David Gow <davidgow@google.com>

Thanks (and sorry for the grumpiness: don't take it personally),
-- David

[1]: https://lore.kernel.org/rust-for-linux/20250307090103.918788-1-davidgow@google.com/

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5281 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 08/16] rust: kunit: refactor to use `&raw [const|mut]`
  2025-03-18  8:02   ` David Gow
@ 2025-03-20  1:39     ` Antonio Hickey
  2025-03-20 23:15     ` Miguel Ojeda
  1 sibling, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-20  1:39 UTC (permalink / raw)
  To: davidgow
  Cc: a.hindborg, alex.gaynor, aliceryhl, benno.lossin, bjorn3_gh,
	boqun.feng, brendan.higgins, contact, contact, dakr, gary,
	kunit-dev, linux-kernel, linux-kselftest, ojeda, rmoar,
	rust-for-linux, tmgross

On Tue, Mar 18, 2025 at 04:02:15PM +0800, David Gow wrote:
> On Sun, 16 Mar 2025 at 14:20, Antonio Hickey <contact@byte-forge.io> wrote:
> >
> > Replacing all occurrences of `addr_of!(place)` and `addr_of_mut!(place)`
> > with `&raw const place` and `&raw mut place` respectively.
> >
> > This will allow us to reduce macro complexity, and improve consistency
> > with existing reference syntax as `&raw const`, `&raw mut` are similar
> > to `&`, `&mut` making it fit more naturally with other existing code.
> >
> > Suggested-by: Benno Lossin <benno.lossin@proton.me>
> > Link: https://github.com/Rust-for-Linux/linux/issues/1148
> > Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
> > ---
> 
> Thanks, Antonio.
> 
> So this looks fine, but it's also a bit annoying, as the remaining
> KUnit/Rust integration patches[1] were recently updated to use
> `addr_of_mut!()`, so either this patch, or those, will need updating.
> 
> In general, I think changes such as those in this series are going to
> get progressively more prone to conflicts as Rust is adopted by other
> subsystems, as the 'rust' tree won't be the only one carrying changes
> which could be affected. Maybe in the future it'd make sense to split
> these up into a series which enables the new feature, and only then
> put the warnings in place in the next version?
> 

Hi David,

I understand your general frustration around this, but I do
think it's better to have a higher frequency of change now while
Rust adoption is still early than later on. I know you're looking
at this in a more forward lense of the future, and I think you have
a fair point that this can be more problematic as adoption increases. 

> In the KUnit case in particular, since the patches haven't actually
> been merged yet, we have three options:
> - Merge this into rust-next, and send out a new version of the KUnit
> patches which depend on it, which then are also carried in rust-next,
> or delayed (again) to 6.16. I suspect given how close to the merge
> window we are, the delay is more likely.
> - Merge the KUnit changes as-is (either into rust-next or
> kselftest/kunit), and send out a new version of this series which also
> updates it (probably in 6.16, but maybe sooner if everything goes via
> rust-next).
> - Merge both, and accept that there'll be some clippy errors until a
> follow-up patch fixing them is sent and merged.

I'm currently preparing to send out a new version of my patch right 
now. Depending on how the timing of our patches plays out, I'm not
opposed to updating your patches KUnit changes within my patch set, as
it's very much aligned with the scope of my patch set.

> 
> As someone with a vested interest in the KUnit changes, and at best a
> mild academic interest in the addr_of_muit!() deprecation, my
> preferences are with the latter two options. (I'd also, in general,
> whinge that the frequency of new Rust versions / warnings is high
> enough that it's taking a not insignificant portion of the limited
> time I have working on Rust things to understand and deal with the
> churn.)
> 
> Regardless, apart from the minor irritation of having to learn yet
> another new syntax, I have no objections to this patch in particular.
> 
> Reviewed-by: David Gow <davidgow@google.com>
> 
> Thanks (and sorry for the grumpiness: don't take it personally),
> -- David

Haha no problem, you have a fair point.

Thanks,
Antonio

> 
> [1]: https://lore.kernel.org/rust-for-linux/20250307090103.918788-1-davidgow@google.com/



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 08/16] rust: kunit: refactor to use `&raw [const|mut]`
  2025-03-18  8:02   ` David Gow
  2025-03-20  1:39     ` Antonio Hickey
@ 2025-03-20 23:15     ` Miguel Ojeda
  2025-03-21  2:28       ` David Gow
  2025-03-21 19:01       ` Antonio Hickey
  1 sibling, 2 replies; 32+ messages in thread
From: Miguel Ojeda @ 2025-03-20 23:15 UTC (permalink / raw)
  To: David Gow
  Cc: Antonio Hickey, Brendan Higgins, Rae Moar, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Antonio Hickey, linux-kselftest, kunit-dev,
	rust-for-linux, linux-kernel

On Tue, Mar 18, 2025 at 9:02 AM David Gow <davidgow@google.com> wrote:
>
> In general, I think changes such as those in this series are going to
> get progressively more prone to conflicts as Rust is adopted by other
> subsystems, as the 'rust' tree won't be the only one carrying changes
> which could be affected. Maybe in the future it'd make sense to split
> these up into a series which enables the new feature, and only then
> put the warnings in place in the next version?

+1, I had to do a two-cycle split for other things in the past
already, e.g. for Gary's FFI series.

I agree that churn for this kind of change has a cost. For tree-wide
series, it will become harder and harder over time, just like in C,
and some changes and cleanups may take several cycles.

For Clippy lints, I think we have some extra flexibility. We still aim
to keep everything Clippy-clean (and patches sent should be sent clean
under the latest stable Rust version at least, and maintainers should
enable Clippy in their test runs), but if something slips in a
particular corner/config/arch that is not routinely tested, it is not
the end of the world as long as it gets cleaned up.

Anyway, KUnit `#[test]`s are in -- I was not planning to merge this
now anyway, it should be reviewed a bit more.

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 08/16] rust: kunit: refactor to use `&raw [const|mut]`
  2025-03-20 23:15     ` Miguel Ojeda
@ 2025-03-21  2:28       ` David Gow
  2025-03-21 17:06         ` Boqun Feng
  2025-03-21 19:01       ` Antonio Hickey
  1 sibling, 1 reply; 32+ messages in thread
From: David Gow @ 2025-03-21  2:28 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Antonio Hickey, Brendan Higgins, Rae Moar, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Antonio Hickey, linux-kselftest, kunit-dev,
	rust-for-linux, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1759 bytes --]

On Fri, 21 Mar 2025 at 07:16, Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Tue, Mar 18, 2025 at 9:02 AM David Gow <davidgow@google.com> wrote:
> >
> > In general, I think changes such as those in this series are going to
> > get progressively more prone to conflicts as Rust is adopted by other
> > subsystems, as the 'rust' tree won't be the only one carrying changes
> > which could be affected. Maybe in the future it'd make sense to split
> > these up into a series which enables the new feature, and only then
> > put the warnings in place in the next version?
>
> +1, I had to do a two-cycle split for other things in the past
> already, e.g. for Gary's FFI series.
>
> I agree that churn for this kind of change has a cost. For tree-wide
> series, it will become harder and harder over time, just like in C,
> and some changes and cleanups may take several cycles.
>
> For Clippy lints, I think we have some extra flexibility. We still aim
> to keep everything Clippy-clean (and patches sent should be sent clean
> under the latest stable Rust version at least, and maintainers should
> enable Clippy in their test runs), but if something slips in a
> particular corner/config/arch that is not routinely tested, it is not
> the end of the world as long as it gets cleaned up.
>

Sounds like the right sort of compromise to me: if we aim to have
things be clean on the branches they're applied to, we can clean up
any warnings which arise as a result of merging afterwards.

> Anyway, KUnit `#[test]`s are in -- I was not planning to merge this
> now anyway, it should be reviewed a bit more.

Excellent! I'll make sure to review the new version of the patch when
it's rebased.

Cheers,
-- David

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5281 bytes --]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 08/16] rust: kunit: refactor to use `&raw [const|mut]`
  2025-03-21  2:28       ` David Gow
@ 2025-03-21 17:06         ` Boqun Feng
  2025-03-21 19:04           ` Miguel Ojeda
  0 siblings, 1 reply; 32+ messages in thread
From: Boqun Feng @ 2025-03-21 17:06 UTC (permalink / raw)
  To: David Gow
  Cc: Miguel Ojeda, Antonio Hickey, Brendan Higgins, Rae Moar,
	Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Antonio Hickey, linux-kselftest, kunit-dev,
	rust-for-linux, linux-kernel

On Fri, Mar 21, 2025 at 10:28:06AM +0800, David Gow wrote:
[...]
> > Anyway, KUnit `#[test]`s are in -- I was not planning to merge this
> > now anyway, it should be reviewed a bit more.
> 

I agree this whole series should wait a bit, but do we want to merge
patch #1 as early as possible (maybe right after v6.15-rc1), so that new
code can switch to &raw since that's the direction anyway?

Regards,
Boqun

> Excellent! I'll make sure to review the new version of the patch when
> it's rebased.
> 
> Cheers,
> -- David



^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 08/16] rust: kunit: refactor to use `&raw [const|mut]`
  2025-03-20 23:15     ` Miguel Ojeda
  2025-03-21  2:28       ` David Gow
@ 2025-03-21 19:01       ` Antonio Hickey
  1 sibling, 0 replies; 32+ messages in thread
From: Antonio Hickey @ 2025-03-21 19:01 UTC (permalink / raw)
  To: miguel.ojeda.sandonis
  Cc: a.hindborg, alex.gaynor, aliceryhl, benno.lossin, bjorn3_gh,
	boqun.feng, brendan.higgins, contact, contact, dakr, davidgow,
	gary, kunit-dev, linux-kernel, linux-kselftest, ojeda, rmoar,
	rust-for-linux, tmgross

On Fri, Mar 21, 2025 at 10:06:03AM -0700, Boqun Feng wrote:
> On Fri, Mar 21, 2025 at 10:28:06AM +0800, David Gow wrote:
> [...]
> > > Anyway, KUnit `#[test]`s are in -- I was not planning to merge this
> > > now anyway, it should be reviewed a bit more.
> > 
> 
> I agree this whole series should wait a bit, but do we want to merge
> patch #1 as early as possible (maybe right after v6.15-rc1), so that new
> code can switch to &raw since that's the direction anyway?

This would make the most sense to me, it would keep things clippy clean
while also allowing new patches to use the feature. This would also
potentially help reduce the amount of refactoring my patch series will 
have to do as it's delayed. 

Thanks,
Antonio

> 
> Regards,
> Boqun
> 
> > Excellent! I'll make sure to review the new version of the patch when
> > it's rebased.
> > 
> > Cheers,
> > -- David
> 
>

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH v4 08/16] rust: kunit: refactor to use `&raw [const|mut]`
  2025-03-21 17:06         ` Boqun Feng
@ 2025-03-21 19:04           ` Miguel Ojeda
  0 siblings, 0 replies; 32+ messages in thread
From: Miguel Ojeda @ 2025-03-21 19:04 UTC (permalink / raw)
  To: Boqun Feng
  Cc: David Gow, Antonio Hickey, Brendan Higgins, Rae Moar,
	Miguel Ojeda, Alex Gaynor, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Antonio Hickey, linux-kselftest, kunit-dev,
	rust-for-linux, linux-kernel

On Fri, Mar 21, 2025 at 6:06 PM Boqun Feng <boqun.feng@gmail.com> wrote:
>
> I agree this whole series should wait a bit, but do we want to merge
> patch #1 as early as possible (maybe right after v6.15-rc1), so that new
> code can switch to &raw since that's the direction anyway?

Sounds like a good idea to me.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2025-03-21 19:05 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-16  6:14 [PATCH v4 00/16] rust: refactor to utilize `&raw [const|mut]` Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 01/16] rust: enable `raw_ref_op` feature Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 02/16] rust: init: refactor to use `&raw [const|mut]` Antonio Hickey
2025-03-16 10:14   ` Benno Lossin
2025-03-16  6:14 ` [PATCH v4 03/16] rust: list: " Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 04/16] rust: task: " Antonio Hickey
2025-03-17  4:00   ` Boqun Feng
2025-03-16  6:14 ` [PATCH v4 05/16] rust: faux: " Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 06/16] rust: platform: " Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 07/16] rust: pci: " Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 08/16] rust: kunit: " Antonio Hickey
2025-03-18  8:02   ` David Gow
2025-03-20  1:39     ` Antonio Hickey
2025-03-20 23:15     ` Miguel Ojeda
2025-03-21  2:28       ` David Gow
2025-03-21 17:06         ` Boqun Feng
2025-03-21 19:04           ` Miguel Ojeda
2025-03-21 19:01       ` Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 09/16] rust: workqueue: " Antonio Hickey
2025-03-17  4:21   ` Boqun Feng
2025-03-17  4:32     ` Boqun Feng
2025-03-16  6:14 ` [PATCH v4 10/16] rust: rbtree: " Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 11/16] rust: net: phy: " Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 12/16] rust: sync: arc: " Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 13/16] rust: jump_label: " Antonio Hickey
2025-03-16  6:14 ` [PATCH v4 14/16] rust: fs: file: " Antonio Hickey
2025-03-17  4:33   ` Boqun Feng
2025-03-16  6:14 ` [PATCH v4 15/16] rust: block: " Antonio Hickey
2025-03-17  4:04   ` Boqun Feng
2025-03-16  6:14 ` [PATCH v4 16/16] rust: clippy: disable `addr_of[_mut]!` macros Antonio Hickey
2025-03-16  9:50   ` Benno Lossin
2025-03-16 12:57   ` Tamir Duberstein

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).