linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref
@ 2025-07-17  7:34 Shankari Anand
  2025-07-25 13:02 ` Shankari Anand
  0 siblings, 1 reply; 10+ messages in thread
From: Shankari Anand @ 2025-07-17  7:34 UTC (permalink / raw)
  To: linux-kernel, rust-for-linux
  Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Leon Romanovsky,
	Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Rafael J . Wysocki,
	Abdiel Janulgue, Daniel Almeida, Robin Murphy, Viresh Kumar,
	Nishanth Menon, Stephen Boyd, Bjorn Helgaas,
	Krzysztof Wilczyński, Shankari Anand

Update call sites in the core kernel files to import `ARef`
and `AlwaysRefCounted` from `sync::aref` instead of `types`.

This aligns with the ongoing effort to move `ARef` and
`AlwaysRefCounted` to sync.

Suggested-by: Benno Lossin <lossin@kernel.org>
Link: https://github.com/Rust-for-Linux/linux/issues/1173
Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
---
Its part of a subsystem-wise split series, as suggested in:
https://lore.kernel.org/rust-for-linux/CANiq72=NSRMV_6UxXVgkebmWmbgN4i=sfRszr-G+x3W5A4DYOg@mail.gmail.com/T/#u
This split series is intended to ease review and subsystem-level maintenance.

The original moving patch is here:
https://lore.kernel.org/rust-for-linux/DBCLH4WXYTJL.FDZ9B39OO3TY@kernel.org/T/#mb67fbddcd894665d6ec6b0854e37930dedab468b

Gradually the re-export from types.rs will be eliminated in the
future cycle.
---
 rust/kernel/auxiliary.rs     |  2 +-
 rust/kernel/cred.rs          |  6 +-----
 rust/kernel/device.rs        | 10 +++-------
 rust/kernel/devres.rs        |  3 +--
 rust/kernel/dma.rs           |  2 +-
 rust/kernel/opp.rs           | 13 +++++++------
 rust/kernel/pci.rs           |  5 +++--
 rust/kernel/pid_namespace.rs |  5 +----
 rust/kernel/platform.rs      |  2 +-
 rust/kernel/task.rs          |  7 ++++---
 10 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
index d2cfe1eeefb6..776c63387832 100644
--- a/rust/kernel/auxiliary.rs
+++ b/rust/kernel/auxiliary.rs
@@ -250,7 +250,7 @@ extern "C" fn release(dev: *mut bindings::device) {
 kernel::impl_device_context_into_aref!(Device);
 
 // SAFETY: Instances of `Device` are always reference-counted.
-unsafe impl crate::types::AlwaysRefCounted for Device {
+unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
     fn inc_ref(&self) {
         // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
         unsafe { bindings::get_device(self.as_ref().as_raw()) };
diff --git a/rust/kernel/cred.rs b/rust/kernel/cred.rs
index 2599f01e8b28..4a2229542fb7 100644
--- a/rust/kernel/cred.rs
+++ b/rust/kernel/cred.rs
@@ -8,11 +8,7 @@
 //!
 //! Reference: <https://www.kernel.org/doc/html/latest/security/credentials.html>
 
-use crate::{
-    bindings,
-    task::Kuid,
-    types::{AlwaysRefCounted, Opaque},
-};
+use crate::{bindings, sync::aref::AlwaysRefCounted, task::Kuid, types::Opaque};
 
 /// Wraps the kernel's `struct cred`.
 ///
diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
index 5c946af3a4d5..8b965b82163c 100644
--- a/rust/kernel/device.rs
+++ b/rust/kernel/device.rs
@@ -4,11 +4,7 @@
 //!
 //! C header: [`include/linux/device.h`](srctree/include/linux/device.h)
 
-use crate::{
-    bindings,
-    str::CStr,
-    types::{ARef, Opaque},
-};
+use crate::{bindings, str::CStr, sync::aref::ARef, types::Opaque};
 use core::{fmt, marker::PhantomData, ptr};
 
 #[cfg(CONFIG_PRINTK)]
@@ -216,7 +212,7 @@ pub fn property_present(&self, name: &CStr) -> bool {
 kernel::impl_device_context_into_aref!(Device);
 
 // SAFETY: Instances of `Device` are always reference-counted.
-unsafe impl crate::types::AlwaysRefCounted for Device {
+unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
     fn inc_ref(&self) {
         // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
         unsafe { bindings::get_device(self.as_raw()) };
@@ -322,7 +318,7 @@ macro_rules! impl_device_context_deref {
 #[macro_export]
 macro_rules! __impl_device_context_into_aref {
     ($src:ty, $device:tt) => {
-        impl ::core::convert::From<&$device<$src>> for $crate::types::ARef<$device> {
+        impl ::core::convert::From<&$device<$src>> for $crate::sync::aref::ARef<$device> {
             fn from(dev: &$device<$src>) -> Self {
                 (&**dev).into()
             }
diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs
index d0e6c6e162c2..7a1e2f2721b8 100644
--- a/rust/kernel/devres.rs
+++ b/rust/kernel/devres.rs
@@ -13,8 +13,7 @@
     ffi::c_void,
     prelude::*,
     revocable::{Revocable, RevocableGuard},
-    sync::{rcu, Arc, Completion},
-    types::ARef,
+    sync::{aref::ARef, rcu, Arc, Completion},
 };
 
 #[pin_data]
diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs
index 1f7bae643416..6339e1e22e08 100644
--- a/rust/kernel/dma.rs
+++ b/rust/kernel/dma.rs
@@ -9,8 +9,8 @@
     device::{Bound, Device},
     error::code::*,
     error::Result,
+    sync::aref::ARef,
     transmute::{AsBytes, FromBytes},
-    types::ARef,
 };
 
 /// Possible attributes associated with a DMA mapping.
diff --git a/rust/kernel/opp.rs b/rust/kernel/opp.rs
index 0e94cb2703ec..de1fea9964f3 100644
--- a/rust/kernel/opp.rs
+++ b/rust/kernel/opp.rs
@@ -16,7 +16,8 @@
     ffi::c_ulong,
     prelude::*,
     str::CString,
-    types::{ARef, AlwaysRefCounted, Opaque},
+    sync::aref::{ARef, AlwaysRefCounted},
+    types::Opaque,
 };
 
 #[cfg(CONFIG_CPU_FREQ)]
@@ -162,7 +163,7 @@ fn from(power: MicroWatt) -> Self {
 /// use kernel::device::Device;
 /// use kernel::error::Result;
 /// use kernel::opp::{Data, MicroVolt, Token};
-/// use kernel::types::ARef;
+/// use kernel::sync::aref::ARef;
 ///
 /// fn create_opp(dev: &ARef<Device>, freq: Hertz, volt: MicroVolt, level: u32) -> Result<Token> {
 ///     let data = Data::new(freq, volt, level, false);
@@ -211,7 +212,7 @@ fn drop(&mut self) {
 /// use kernel::device::Device;
 /// use kernel::error::Result;
 /// use kernel::opp::{Data, MicroVolt, Token};
-/// use kernel::types::ARef;
+/// use kernel::sync::aref::ARef;
 ///
 /// fn create_opp(dev: &ARef<Device>, freq: Hertz, volt: MicroVolt, level: u32) -> Result<Token> {
 ///     let data = Data::new(freq, volt, level, false);
@@ -262,7 +263,7 @@ fn freq(&self) -> Hertz {
 /// use kernel::clk::Hertz;
 /// use kernel::error::Result;
 /// use kernel::opp::{OPP, SearchType, Table};
-/// use kernel::types::ARef;
+/// use kernel::sync::aref::ARef;
 ///
 /// fn find_opp(table: &Table, freq: Hertz) -> Result<ARef<OPP>> {
 ///     let opp = table.opp_from_freq(freq, Some(true), None, SearchType::Exact)?;
@@ -335,7 +336,7 @@ fn drop(&mut self) {
 /// use kernel::error::Result;
 /// use kernel::opp::{Config, ConfigOps, ConfigToken};
 /// use kernel::str::CString;
-/// use kernel::types::ARef;
+/// use kernel::sync::aref::ARef;
 /// use kernel::macros::vtable;
 ///
 /// #[derive(Default)]
@@ -581,7 +582,7 @@ extern "C" fn config_regulators(
 /// use kernel::device::Device;
 /// use kernel::error::Result;
 /// use kernel::opp::Table;
-/// use kernel::types::ARef;
+/// use kernel::sync::aref::ARef;
 ///
 /// fn get_table(dev: &ARef<Device>, mask: &mut Cpumask, freq: Hertz) -> Result<Table> {
 ///     let mut opp_table = Table::from_of_cpumask(dev, mask)?;
diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
index 5ce07999168e..7c17c937de59 100644
--- a/rust/kernel/pci.rs
+++ b/rust/kernel/pci.rs
@@ -14,7 +14,8 @@
     io::Io,
     io::IoRaw,
     str::CStr,
-    types::{ARef, ForeignOwnable, Opaque},
+    sync::aref::ARef,
+    types::{ForeignOwnable, Opaque},
     ThisModule,
 };
 use core::{
@@ -438,7 +439,7 @@ pub fn set_master(&self) {
 kernel::impl_device_context_into_aref!(Device);
 
 // SAFETY: Instances of `Device` are always reference-counted.
-unsafe impl crate::types::AlwaysRefCounted for Device {
+unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
     fn inc_ref(&self) {
         // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
         unsafe { bindings::pci_dev_get(self.as_raw()) };
diff --git a/rust/kernel/pid_namespace.rs b/rust/kernel/pid_namespace.rs
index 0e93808e4639..979a9718f153 100644
--- a/rust/kernel/pid_namespace.rs
+++ b/rust/kernel/pid_namespace.rs
@@ -7,10 +7,7 @@
 //! C header: [`include/linux/pid_namespace.h`](srctree/include/linux/pid_namespace.h) and
 //! [`include/linux/pid.h`](srctree/include/linux/pid.h)
 
-use crate::{
-    bindings,
-    types::{AlwaysRefCounted, Opaque},
-};
+use crate::{bindings, sync::aref::AlwaysRefCounted, types::Opaque};
 use core::ptr;
 
 /// Wraps the kernel's `struct pid_namespace`. Thread safe.
diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
index e894790c510c..1c136341b670 100644
--- a/rust/kernel/platform.rs
+++ b/rust/kernel/platform.rs
@@ -198,7 +198,7 @@ fn as_raw(&self) -> *mut bindings::platform_device {
 kernel::impl_device_context_into_aref!(Device);
 
 // SAFETY: Instances of `Device` are always reference-counted.
-unsafe impl crate::types::AlwaysRefCounted for Device {
+unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
     fn inc_ref(&self) {
         // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
         unsafe { bindings::get_device(self.as_ref().as_raw()) };
diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs
index 927413d85484..b46488f6d1a8 100644
--- a/rust/kernel/task.rs
+++ b/rust/kernel/task.rs
@@ -9,7 +9,8 @@
     ffi::{c_int, c_long, c_uint},
     mm::MmWithUser,
     pid_namespace::PidNamespace,
-    types::{ARef, NotThreadSafe, Opaque},
+    sync::aref::ARef,
+    types::{NotThreadSafe, Opaque},
 };
 use core::{
     cmp::{Eq, PartialEq},
@@ -76,7 +77,7 @@ macro_rules! current {
 /// incremented when creating `State` and decremented when it is dropped:
 ///
 /// ```
-/// use kernel::{task::Task, types::ARef};
+/// use kernel::{task::Task, sync::aref::ARef};
 ///
 /// struct State {
 ///     creator: ARef<Task>,
@@ -340,7 +341,7 @@ pub fn active_pid_ns(&self) -> Option<&PidNamespace> {
 }
 
 // SAFETY: The type invariants guarantee that `Task` is always refcounted.
-unsafe impl crate::types::AlwaysRefCounted for Task {
+unsafe impl crate::sync::aref::AlwaysRefCounted for Task {
     fn inc_ref(&self) {
         // SAFETY: The existence of a shared reference means that the refcount is nonzero.
         unsafe { bindings::get_task_struct(self.as_ptr()) };

base-commit: 8ecb65b7b68ea48350833ba59c1257718e859768
-- 
2.34.1


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

* Re: [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref
  2025-07-17  7:34 [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref Shankari Anand
@ 2025-07-25 13:02 ` Shankari Anand
  2025-07-25 14:03   ` Miguel Ojeda
  0 siblings, 1 reply; 10+ messages in thread
From: Shankari Anand @ 2025-07-25 13:02 UTC (permalink / raw)
  To: linux-kernel, rust-for-linux
  Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Leon Romanovsky,
	Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Rafael J . Wysocki,
	Abdiel Janulgue, Daniel Almeida, Robin Murphy, Viresh Kumar,
	Nishanth Menon, Stephen Boyd, Bjorn Helgaas,
	Krzysztof Wilczyński

Hello,

Can this be picked up for review? Should I be splitting each core
kernel file into a separate patch?

On Thu, Jul 17, 2025 at 1:05 PM Shankari Anand
<shankari.ak0208@gmail.com> wrote:
>
> Update call sites in the core kernel files to import `ARef`
> and `AlwaysRefCounted` from `sync::aref` instead of `types`.
>
> This aligns with the ongoing effort to move `ARef` and
> `AlwaysRefCounted` to sync.
>
> Suggested-by: Benno Lossin <lossin@kernel.org>
> Link: https://github.com/Rust-for-Linux/linux/issues/1173
> Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
> ---
> Its part of a subsystem-wise split series, as suggested in:
> https://lore.kernel.org/rust-for-linux/CANiq72=NSRMV_6UxXVgkebmWmbgN4i=sfRszr-G+x3W5A4DYOg@mail.gmail.com/T/#u
> This split series is intended to ease review and subsystem-level maintenance.
>
> The original moving patch is here:
> https://lore.kernel.org/rust-for-linux/DBCLH4WXYTJL.FDZ9B39OO3TY@kernel.org/T/#mb67fbddcd894665d6ec6b0854e37930dedab468b
>
> Gradually the re-export from types.rs will be eliminated in the
> future cycle.
> ---
>  rust/kernel/auxiliary.rs     |  2 +-
>  rust/kernel/cred.rs          |  6 +-----
>  rust/kernel/device.rs        | 10 +++-------
>  rust/kernel/devres.rs        |  3 +--
>  rust/kernel/dma.rs           |  2 +-
>  rust/kernel/opp.rs           | 13 +++++++------
>  rust/kernel/pci.rs           |  5 +++--
>  rust/kernel/pid_namespace.rs |  5 +----
>  rust/kernel/platform.rs      |  2 +-
>  rust/kernel/task.rs          |  7 ++++---
>  10 files changed, 23 insertions(+), 32 deletions(-)
>
> diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
> index d2cfe1eeefb6..776c63387832 100644
> --- a/rust/kernel/auxiliary.rs
> +++ b/rust/kernel/auxiliary.rs
> @@ -250,7 +250,7 @@ extern "C" fn release(dev: *mut bindings::device) {
>  kernel::impl_device_context_into_aref!(Device);
>
>  // SAFETY: Instances of `Device` are always reference-counted.
> -unsafe impl crate::types::AlwaysRefCounted for Device {
> +unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
>      fn inc_ref(&self) {
>          // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
>          unsafe { bindings::get_device(self.as_ref().as_raw()) };
> diff --git a/rust/kernel/cred.rs b/rust/kernel/cred.rs
> index 2599f01e8b28..4a2229542fb7 100644
> --- a/rust/kernel/cred.rs
> +++ b/rust/kernel/cred.rs
> @@ -8,11 +8,7 @@
>  //!
>  //! Reference: <https://www.kernel.org/doc/html/latest/security/credentials.html>
>
> -use crate::{
> -    bindings,
> -    task::Kuid,
> -    types::{AlwaysRefCounted, Opaque},
> -};
> +use crate::{bindings, sync::aref::AlwaysRefCounted, task::Kuid, types::Opaque};
>
>  /// Wraps the kernel's `struct cred`.
>  ///
> diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
> index 5c946af3a4d5..8b965b82163c 100644
> --- a/rust/kernel/device.rs
> +++ b/rust/kernel/device.rs
> @@ -4,11 +4,7 @@
>  //!
>  //! C header: [`include/linux/device.h`](srctree/include/linux/device.h)
>
> -use crate::{
> -    bindings,
> -    str::CStr,
> -    types::{ARef, Opaque},
> -};
> +use crate::{bindings, str::CStr, sync::aref::ARef, types::Opaque};
>  use core::{fmt, marker::PhantomData, ptr};
>
>  #[cfg(CONFIG_PRINTK)]
> @@ -216,7 +212,7 @@ pub fn property_present(&self, name: &CStr) -> bool {
>  kernel::impl_device_context_into_aref!(Device);
>
>  // SAFETY: Instances of `Device` are always reference-counted.
> -unsafe impl crate::types::AlwaysRefCounted for Device {
> +unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
>      fn inc_ref(&self) {
>          // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
>          unsafe { bindings::get_device(self.as_raw()) };
> @@ -322,7 +318,7 @@ macro_rules! impl_device_context_deref {
>  #[macro_export]
>  macro_rules! __impl_device_context_into_aref {
>      ($src:ty, $device:tt) => {
> -        impl ::core::convert::From<&$device<$src>> for $crate::types::ARef<$device> {
> +        impl ::core::convert::From<&$device<$src>> for $crate::sync::aref::ARef<$device> {
>              fn from(dev: &$device<$src>) -> Self {
>                  (&**dev).into()
>              }
> diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs
> index d0e6c6e162c2..7a1e2f2721b8 100644
> --- a/rust/kernel/devres.rs
> +++ b/rust/kernel/devres.rs
> @@ -13,8 +13,7 @@
>      ffi::c_void,
>      prelude::*,
>      revocable::{Revocable, RevocableGuard},
> -    sync::{rcu, Arc, Completion},
> -    types::ARef,
> +    sync::{aref::ARef, rcu, Arc, Completion},
>  };
>
>  #[pin_data]
> diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs
> index 1f7bae643416..6339e1e22e08 100644
> --- a/rust/kernel/dma.rs
> +++ b/rust/kernel/dma.rs
> @@ -9,8 +9,8 @@
>      device::{Bound, Device},
>      error::code::*,
>      error::Result,
> +    sync::aref::ARef,
>      transmute::{AsBytes, FromBytes},
> -    types::ARef,
>  };
>
>  /// Possible attributes associated with a DMA mapping.
> diff --git a/rust/kernel/opp.rs b/rust/kernel/opp.rs
> index 0e94cb2703ec..de1fea9964f3 100644
> --- a/rust/kernel/opp.rs
> +++ b/rust/kernel/opp.rs
> @@ -16,7 +16,8 @@
>      ffi::c_ulong,
>      prelude::*,
>      str::CString,
> -    types::{ARef, AlwaysRefCounted, Opaque},
> +    sync::aref::{ARef, AlwaysRefCounted},
> +    types::Opaque,
>  };
>
>  #[cfg(CONFIG_CPU_FREQ)]
> @@ -162,7 +163,7 @@ fn from(power: MicroWatt) -> Self {
>  /// use kernel::device::Device;
>  /// use kernel::error::Result;
>  /// use kernel::opp::{Data, MicroVolt, Token};
> -/// use kernel::types::ARef;
> +/// use kernel::sync::aref::ARef;
>  ///
>  /// fn create_opp(dev: &ARef<Device>, freq: Hertz, volt: MicroVolt, level: u32) -> Result<Token> {
>  ///     let data = Data::new(freq, volt, level, false);
> @@ -211,7 +212,7 @@ fn drop(&mut self) {
>  /// use kernel::device::Device;
>  /// use kernel::error::Result;
>  /// use kernel::opp::{Data, MicroVolt, Token};
> -/// use kernel::types::ARef;
> +/// use kernel::sync::aref::ARef;
>  ///
>  /// fn create_opp(dev: &ARef<Device>, freq: Hertz, volt: MicroVolt, level: u32) -> Result<Token> {
>  ///     let data = Data::new(freq, volt, level, false);
> @@ -262,7 +263,7 @@ fn freq(&self) -> Hertz {
>  /// use kernel::clk::Hertz;
>  /// use kernel::error::Result;
>  /// use kernel::opp::{OPP, SearchType, Table};
> -/// use kernel::types::ARef;
> +/// use kernel::sync::aref::ARef;
>  ///
>  /// fn find_opp(table: &Table, freq: Hertz) -> Result<ARef<OPP>> {
>  ///     let opp = table.opp_from_freq(freq, Some(true), None, SearchType::Exact)?;
> @@ -335,7 +336,7 @@ fn drop(&mut self) {
>  /// use kernel::error::Result;
>  /// use kernel::opp::{Config, ConfigOps, ConfigToken};
>  /// use kernel::str::CString;
> -/// use kernel::types::ARef;
> +/// use kernel::sync::aref::ARef;
>  /// use kernel::macros::vtable;
>  ///
>  /// #[derive(Default)]
> @@ -581,7 +582,7 @@ extern "C" fn config_regulators(
>  /// use kernel::device::Device;
>  /// use kernel::error::Result;
>  /// use kernel::opp::Table;
> -/// use kernel::types::ARef;
> +/// use kernel::sync::aref::ARef;
>  ///
>  /// fn get_table(dev: &ARef<Device>, mask: &mut Cpumask, freq: Hertz) -> Result<Table> {
>  ///     let mut opp_table = Table::from_of_cpumask(dev, mask)?;
> diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs
> index 5ce07999168e..7c17c937de59 100644
> --- a/rust/kernel/pci.rs
> +++ b/rust/kernel/pci.rs
> @@ -14,7 +14,8 @@
>      io::Io,
>      io::IoRaw,
>      str::CStr,
> -    types::{ARef, ForeignOwnable, Opaque},
> +    sync::aref::ARef,
> +    types::{ForeignOwnable, Opaque},
>      ThisModule,
>  };
>  use core::{
> @@ -438,7 +439,7 @@ pub fn set_master(&self) {
>  kernel::impl_device_context_into_aref!(Device);
>
>  // SAFETY: Instances of `Device` are always reference-counted.
> -unsafe impl crate::types::AlwaysRefCounted for Device {
> +unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
>      fn inc_ref(&self) {
>          // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
>          unsafe { bindings::pci_dev_get(self.as_raw()) };
> diff --git a/rust/kernel/pid_namespace.rs b/rust/kernel/pid_namespace.rs
> index 0e93808e4639..979a9718f153 100644
> --- a/rust/kernel/pid_namespace.rs
> +++ b/rust/kernel/pid_namespace.rs
> @@ -7,10 +7,7 @@
>  //! C header: [`include/linux/pid_namespace.h`](srctree/include/linux/pid_namespace.h) and
>  //! [`include/linux/pid.h`](srctree/include/linux/pid.h)
>
> -use crate::{
> -    bindings,
> -    types::{AlwaysRefCounted, Opaque},
> -};
> +use crate::{bindings, sync::aref::AlwaysRefCounted, types::Opaque};
>  use core::ptr;
>
>  /// Wraps the kernel's `struct pid_namespace`. Thread safe.
> diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs
> index e894790c510c..1c136341b670 100644
> --- a/rust/kernel/platform.rs
> +++ b/rust/kernel/platform.rs
> @@ -198,7 +198,7 @@ fn as_raw(&self) -> *mut bindings::platform_device {
>  kernel::impl_device_context_into_aref!(Device);
>
>  // SAFETY: Instances of `Device` are always reference-counted.
> -unsafe impl crate::types::AlwaysRefCounted for Device {
> +unsafe impl crate::sync::aref::AlwaysRefCounted for Device {
>      fn inc_ref(&self) {
>          // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero.
>          unsafe { bindings::get_device(self.as_ref().as_raw()) };
> diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs
> index 927413d85484..b46488f6d1a8 100644
> --- a/rust/kernel/task.rs
> +++ b/rust/kernel/task.rs
> @@ -9,7 +9,8 @@
>      ffi::{c_int, c_long, c_uint},
>      mm::MmWithUser,
>      pid_namespace::PidNamespace,
> -    types::{ARef, NotThreadSafe, Opaque},
> +    sync::aref::ARef,
> +    types::{NotThreadSafe, Opaque},
>  };
>  use core::{
>      cmp::{Eq, PartialEq},
> @@ -76,7 +77,7 @@ macro_rules! current {
>  /// incremented when creating `State` and decremented when it is dropped:
>  ///
>  /// ```
> -/// use kernel::{task::Task, types::ARef};
> +/// use kernel::{task::Task, sync::aref::ARef};
>  ///
>  /// struct State {
>  ///     creator: ARef<Task>,
> @@ -340,7 +341,7 @@ pub fn active_pid_ns(&self) -> Option<&PidNamespace> {
>  }
>
>  // SAFETY: The type invariants guarantee that `Task` is always refcounted.
> -unsafe impl crate::types::AlwaysRefCounted for Task {
> +unsafe impl crate::sync::aref::AlwaysRefCounted for Task {
>      fn inc_ref(&self) {
>          // SAFETY: The existence of a shared reference means that the refcount is nonzero.
>          unsafe { bindings::get_task_struct(self.as_ptr()) };
>
> base-commit: 8ecb65b7b68ea48350833ba59c1257718e859768
> --
> 2.34.1
>

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

* Re: [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref
  2025-07-25 13:02 ` Shankari Anand
@ 2025-07-25 14:03   ` Miguel Ojeda
  2025-07-27  7:30     ` Shankari Anand
  2025-08-01  8:39     ` Danilo Krummrich
  0 siblings, 2 replies; 10+ messages in thread
From: Miguel Ojeda @ 2025-07-25 14:03 UTC (permalink / raw)
  To: Shankari Anand
  Cc: linux-kernel, rust-for-linux, Greg Kroah-Hartman, Dave Ertman,
	Ira Weiny, Leon Romanovsky, Miguel Ojeda, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Rafael J . Wysocki,
	Abdiel Janulgue, Daniel Almeida, Robin Murphy, Viresh Kumar,
	Nishanth Menon, Stephen Boyd, Bjorn Helgaas,
	Krzysztof Wilczyński

On Fri, Jul 25, 2025 at 3:02 PM Shankari Anand
<shankari.ak0208@gmail.com> wrote:
>
> Can this be picked up for review? Should I be splitting each core
> kernel file into a separate patch?

It has been only a week (and we are close to the merge window, thus
maintainers are typically dealing with other things/patches):

    https://docs.kernel.org/process/submitting-patches.html#don-t-get-discouraged-or-impatient

Having said that, I am not sure why this one in particular has e.g.
`opp.rs` and `devres.rs` -- those are different
entries/trees/maintainers in `MAINTAINERS`. So it would likely help to
perform a split that doesn't involve different subsystems.

By the way, if you meant to send the patches as completely independent
ones, then I would suggest avoiding the series notation (e.g. "7/7")
-- at least I see them in Lore as separate threads:

    https://lore.kernel.org/rust-for-linux/20250717073450.15090-1-shankari.ak0208@gmail.com/

Thanks!

Cheers,
Miguel

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

* Re: [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref
  2025-07-25 14:03   ` Miguel Ojeda
@ 2025-07-27  7:30     ` Shankari Anand
  2025-07-27 12:28       ` Miguel Ojeda
  2025-08-01  8:39     ` Danilo Krummrich
  1 sibling, 1 reply; 10+ messages in thread
From: Shankari Anand @ 2025-07-27  7:30 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: linux-kernel, rust-for-linux, Greg Kroah-Hartman, Dave Ertman,
	Ira Weiny, Leon Romanovsky, Miguel Ojeda, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Rafael J . Wysocki,
	Abdiel Janulgue, Daniel Almeida, Robin Murphy, Viresh Kumar,
	Nishanth Menon, Stephen Boyd, Bjorn Helgaas,
	Krzysztof Wilczyński

> It has been only a week (and we are close to the merge window, thus
> maintainers are typically dealing with other things/patches):
>   https://docs.kernel.org/process/submitting-patches.html#don-t-get-discouraged-or-impatient

Apologies for the early ping, I was unsure about the appropriate way
to split the patches and wanted to confirm before proceeding.

>  Having said that, I am not sure why this one in particular has e.g.
> `opp.rs` and `devres.rs` -- those are different
> entries/trees/maintainers in `MAINTAINERS`. So it would likely help to
> perform a split that doesn't involve different subsystems.

Sure, I'll carefully split the patches accordingly in the next version
to align with the relevant maintainers and trees.

>  By the way, if you meant to send the patches as completely independent
> ones, then I would suggest avoiding the series notation (e.g. "7/7")
> -- at least I see them in Lore as separate threads:

Regarding the series notation (e.g., "7/7"), I included it to indicate
the overall scope of changes as part of the same effort. However,
since the patches are independent and target different subsystems,
I’ll avoid that format going forward, as suggested.

Thanks for your guidance.
~ Shankari


On Fri, Jul 25, 2025 at 7:33 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Fri, Jul 25, 2025 at 3:02 PM Shankari Anand
> <shankari.ak0208@gmail.com> wrote:
> >
> > Can this be picked up for review? Should I be splitting each core
> > kernel file into a separate patch?
>
> It has been only a week (and we are close to the merge window, thus
> maintainers are typically dealing with other things/patches):
>
>     https://docs.kernel.org/process/submitting-patches.html#don-t-get-discouraged-or-impatient
>
> Having said that, I am not sure why this one in particular has e.g.
> `opp.rs` and `devres.rs` -- those are different
> entries/trees/maintainers in `MAINTAINERS`. So it would likely help to
> perform a split that doesn't involve different subsystems.
>
> By the way, if you meant to send the patches as completely independent
> ones, then I would suggest avoiding the series notation (e.g. "7/7")
> -- at least I see them in Lore as separate threads:
>
>     https://lore.kernel.org/rust-for-linux/20250717073450.15090-1-shankari.ak0208@gmail.com/
>
> Thanks!
>
> Cheers,
> Miguel

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

* Re: [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref
  2025-07-27  7:30     ` Shankari Anand
@ 2025-07-27 12:28       ` Miguel Ojeda
  2025-07-27 12:37         ` Benno Lossin
  0 siblings, 1 reply; 10+ messages in thread
From: Miguel Ojeda @ 2025-07-27 12:28 UTC (permalink / raw)
  To: Shankari Anand
  Cc: linux-kernel, rust-for-linux, Greg Kroah-Hartman, Dave Ertman,
	Ira Weiny, Leon Romanovsky, Miguel Ojeda, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Rafael J . Wysocki,
	Abdiel Janulgue, Daniel Almeida, Robin Murphy, Viresh Kumar,
	Nishanth Menon, Stephen Boyd, Bjorn Helgaas,
	Krzysztof Wilczyński

On Sun, Jul 27, 2025 at 9:30 AM Shankari Anand
<shankari.ak0208@gmail.com> wrote:
>
> Apologies for the early ping, I was unsure about the appropriate way
> to split the patches and wanted to confirm before proceeding.

No worries at all, that is fine :)

> Sure, I'll carefully split the patches accordingly in the next version
> to align with the relevant maintainers and trees.

Thanks, that will be useful.

> Regarding the series notation (e.g., "7/7"), I included it to indicate
> the overall scope of changes as part of the same effort. However,
> since the patches are independent and target different subsystems,
> I’ll avoid that format going forward, as suggested.

Thanks -- sometimes people do it in a single series, even if they are
technically independent, especially if they expect everything to go in
at once (which may not be the case here).

However, I was mainly talking about using the "7/7" notation but
having the emails be separate, i.e. if one uses that notation, then
people will likely be a bit confused when they don't see the other
patches in the series. So if it is not a series, then it is best to
avoid that notation; and if it is a series, then the notation should
be used.

I hope that clarifies!

Cheers,
Miguel

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

* Re: [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref
  2025-07-27 12:28       ` Miguel Ojeda
@ 2025-07-27 12:37         ` Benno Lossin
  2025-07-27 14:26           ` Miguel Ojeda
  0 siblings, 1 reply; 10+ messages in thread
From: Benno Lossin @ 2025-07-27 12:37 UTC (permalink / raw)
  To: Miguel Ojeda, Shankari Anand
  Cc: linux-kernel, rust-for-linux, Greg Kroah-Hartman, Dave Ertman,
	Ira Weiny, Leon Romanovsky, Miguel Ojeda, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Rafael J . Wysocki,
	Abdiel Janulgue, Daniel Almeida, Robin Murphy, Viresh Kumar,
	Nishanth Menon, Stephen Boyd, Bjorn Helgaas,
	Krzysztof Wilczyński

On Sun Jul 27, 2025 at 2:28 PM CEST, Miguel Ojeda wrote:
> On Sun, Jul 27, 2025 at 9:30 AM Shankari Anand
> <shankari.ak0208@gmail.com> wrote:
>> Regarding the series notation (e.g., "7/7"), I included it to indicate
>> the overall scope of changes as part of the same effort. However,
>> since the patches are independent and target different subsystems,
>> I’ll avoid that format going forward, as suggested.
>
> Thanks -- sometimes people do it in a single series, even if they are
> technically independent, especially if they expect everything to go in
> at once (which may not be the case here).
>
> However, I was mainly talking about using the "7/7" notation but
> having the emails be separate, i.e. if one uses that notation, then
> people will likely be a bit confused when they don't see the other
> patches in the series. So if it is not a series, then it is best to
> avoid that notation; and if it is a series, then the notation should
> be used.

That's good advice. I want to add that in this case, I think a series is
better sending 7 independent patches. Using a series allows people to
see if it is complete (ie there might be places that are missed). It
also allows someone to send a single mail reviewing all patches & giving
general comments about all patches in the series.

---
Cheers,
Benno

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

* Re: [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref
  2025-07-27 12:37         ` Benno Lossin
@ 2025-07-27 14:26           ` Miguel Ojeda
  2025-07-27 17:20             ` Benno Lossin
  0 siblings, 1 reply; 10+ messages in thread
From: Miguel Ojeda @ 2025-07-27 14:26 UTC (permalink / raw)
  To: Benno Lossin
  Cc: Shankari Anand, linux-kernel, rust-for-linux, Greg Kroah-Hartman,
	Dave Ertman, Ira Weiny, Leon Romanovsky, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Rafael J . Wysocki, Abdiel Janulgue, Daniel Almeida, Robin Murphy,
	Viresh Kumar, Nishanth Menon, Stephen Boyd, Bjorn Helgaas,
	Krzysztof Wilczyński

On Sun, Jul 27, 2025 at 2:37 PM Benno Lossin <lossin@kernel.org> wrote:
>
> That's good advice. I want to add that in this case, I think a series is
> better sending 7 independent patches. Using a series allows people to
> see if it is complete (ie there might be places that are missed). It
> also allows someone to send a single mail reviewing all patches & giving
> general comments about all patches in the series.

It is fine if places are missed, since in this case they are not meant
to be applied at once -- maintainers may think they are supposed to
give Acked-bys instead of applying them, and here the idea was to try
to see if we could get a migration like this via different trees
slowly, rather than the way we did the others.

For the "final series" that removes the re-export, it should
definitely be a series, because in such a case the idea is to apply
them all and remove the re-export at the end of it.

I guess it depends a bit on what maintainers want to do and the case
(e.g. if it is a tricky change, it may be best to have a series).
Sometimes same people may do it differently, e.g. [1][2].

But I agree that many independent patches are painful too, including
in Lore; and that it is always nice to have an "index" of all the
patches for those that want to see it as you say -- perhaps providing
a link to a Lore search, or having them all in the same thread can
help (though that can be confusing on its own), or having a first RFC
version as a series that can be linked later before splitting.

Cheers,
Miguel

[1] https://lore.kernel.org/all/20241127091036.444330-2-u.kleine-koenig@baylibre.com/
[2] https://lore.kernel.org/lkml/20221118224540.619276-1-uwe@kleine-koenig.org/

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

* Re: [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref
  2025-07-27 14:26           ` Miguel Ojeda
@ 2025-07-27 17:20             ` Benno Lossin
  2025-07-27 18:05               ` Miguel Ojeda
  0 siblings, 1 reply; 10+ messages in thread
From: Benno Lossin @ 2025-07-27 17:20 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Shankari Anand, linux-kernel, rust-for-linux, Greg Kroah-Hartman,
	Dave Ertman, Ira Weiny, Leon Romanovsky, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Rafael J . Wysocki, Abdiel Janulgue, Daniel Almeida, Robin Murphy,
	Viresh Kumar, Nishanth Menon, Stephen Boyd, Bjorn Helgaas,
	Krzysztof Wilczyński

On Sun Jul 27, 2025 at 4:26 PM CEST, Miguel Ojeda wrote:
> On Sun, Jul 27, 2025 at 2:37 PM Benno Lossin <lossin@kernel.org> wrote:
>>
>> That's good advice. I want to add that in this case, I think a series is
>> better sending 7 independent patches. Using a series allows people to
>> see if it is complete (ie there might be places that are missed). It
>> also allows someone to send a single mail reviewing all patches & giving
>> general comments about all patches in the series.
>
> It is fine if places are missed, since in this case they are not meant
> to be applied at once -- maintainers may think they are supposed to
> give Acked-bys instead of applying them, and here the idea was to try
> to see if we could get a migration like this via different trees
> slowly, rather than the way we did the others.

AFAIK maintainers can pick different parts of a series', right?

> For the "final series" that removes the re-export, it should
> definitely be a series, because in such a case the idea is to apply
> them all and remove the re-export at the end of it.
>
> I guess it depends a bit on what maintainers want to do and the case
> (e.g. if it is a tricky change, it may be best to have a series).
> Sometimes same people may do it differently, e.g. [1][2].
>
> But I agree that many independent patches are painful too, including
> in Lore; and that it is always nice to have an "index" of all the
> patches for those that want to see it as you say -- perhaps providing
> a link to a Lore search, or having them all in the same thread can
> help (though that can be confusing on its own), or having a first RFC
> version as a series that can be linked later before splitting.

This is the main benefit in this case I'd say.

---
Cheers,
Benno

>
> Cheers,
> Miguel
>
> [1] https://lore.kernel.org/all/20241127091036.444330-2-u.kleine-koenig@baylibre.com/
> [2] https://lore.kernel.org/lkml/20221118224540.619276-1-uwe@kleine-koenig.org/

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

* Re: [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref
  2025-07-27 17:20             ` Benno Lossin
@ 2025-07-27 18:05               ` Miguel Ojeda
  0 siblings, 0 replies; 10+ messages in thread
From: Miguel Ojeda @ 2025-07-27 18:05 UTC (permalink / raw)
  To: Benno Lossin
  Cc: Shankari Anand, linux-kernel, rust-for-linux, Greg Kroah-Hartman,
	Dave Ertman, Ira Weiny, Leon Romanovsky, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Rafael J . Wysocki, Abdiel Janulgue, Daniel Almeida, Robin Murphy,
	Viresh Kumar, Nishanth Menon, Stephen Boyd, Bjorn Helgaas,
	Krzysztof Wilczyński

On Sun, Jul 27, 2025 at 7:20 PM Benno Lossin <lossin@kernel.org> wrote:
>
> AFAIK maintainers can pick different parts of a series', right?

It depends -- some may not be able to be picked independently by
different trees because it would break the build.

Even for those series where there are subsets that can be picked
separately, typically in a normal series if I get Cc'd in a single
patch, then I would assume I am supposed to give my Acked-by so that
it gets picked elsewhere. So unless the cover letter says otherwise, I
would expect a series to be applied as a series.

At the end of the day, it is about coordinating and case-by-case.

Cheers,
Miguel

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

* Re: [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref
  2025-07-25 14:03   ` Miguel Ojeda
  2025-07-27  7:30     ` Shankari Anand
@ 2025-08-01  8:39     ` Danilo Krummrich
  1 sibling, 0 replies; 10+ messages in thread
From: Danilo Krummrich @ 2025-08-01  8:39 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Shankari Anand, linux-kernel, rust-for-linux, Greg Kroah-Hartman,
	Dave Ertman, Ira Weiny, Leon Romanovsky, Miguel Ojeda,
	Alex Gaynor, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Rafael J . Wysocki, Abdiel Janulgue, Daniel Almeida, Robin Murphy,
	Viresh Kumar, Nishanth Menon, Stephen Boyd, Bjorn Helgaas,
	Krzysztof Wilczyński

On Fri Jul 25, 2025 at 4:03 PM CEST, Miguel Ojeda wrote:
> On Fri, Jul 25, 2025 at 3:02 PM Shankari Anand
> <shankari.ak0208@gmail.com> wrote:
>>
>> Can this be picked up for review? Should I be splitting each core
>> kernel file into a separate patch?

[...]

> Having said that, I am not sure why this one in particular has e.g.
> `opp.rs` and `devres.rs` -- those are different
> entries/trees/maintainers in `MAINTAINERS`. So it would likely help to
> perform a split that doesn't involve different subsystems.

For reference:

https://lore.kernel.org/lkml/DBQYD7G5SOZA.2MSKKQWXTPCBB@kernel.org/

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

end of thread, other threads:[~2025-08-01  8:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-17  7:34 [PATCH 7/7] rust: kernel: update ARef and AlwaysRefCounted imports from sync::aref Shankari Anand
2025-07-25 13:02 ` Shankari Anand
2025-07-25 14:03   ` Miguel Ojeda
2025-07-27  7:30     ` Shankari Anand
2025-07-27 12:28       ` Miguel Ojeda
2025-07-27 12:37         ` Benno Lossin
2025-07-27 14:26           ` Miguel Ojeda
2025-07-27 17:20             ` Benno Lossin
2025-07-27 18:05               ` Miguel Ojeda
2025-08-01  8:39     ` Danilo Krummrich

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