Skip to contentSkip to conversation

rust: move ARef and AlwaysRefCounted to sync::aref

PATCH Superseded Shankari Anand 2 participants 3 messages Jun 23, 2025 – Jun 24, 2025

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: move ARef and AlwaysRefCounted to sync::aref

Move the definitions of ARef and AlwaysRefCounted from types.rs to a new file sync/aref.rs.
Define the corresponding aref module under rust/kernel/sync.rs. These types are better grouped in sync with other synchronization primitives.

To avoid breaking existing imports, they are re-exported from types.rs. Drop unused imports mem::ManuallyDrop, ptr::NonNull from types.rs, they are now only used in sync/aref.rs, where they are already imported.

---

The moving patch and updating patch are split as discussed in https://github.com/Rust-for-Linux/linux/issues/1173
A follow-up patch will update all the call sites to import ARef and AlwaysRefCounted directly from sync::aref instead of types.

Fixes were also made to intra-doc links: unresolved references to inc_ref and dec_ref were updated to use AlwaysRefCounted::inc_ref and AlwaysRefCounted::dec_ref.

---
 rust/kernel/sync.rs      |   1 +
 rust/kernel/sync/aref.rs | 170 +++++++++++++++++++++++++++++++++++++++
 rust/kernel/types.rs     | 156 ++---------------------------------
 3 files changed, 176 insertions(+), 151 deletions(-)
 create mode 100644 rust/kernel/sync/aref.rs
rust/kernel/sync.rs +1 -0
index 36a719015583..3e9748c213a8 100644
@@ -10,6 +10,7 @@
 use pin_init;
 
 mod arc;
+pub mod aref;
 mod condvar;
 pub mod lock;
 mod locked_by;
rust/kernel/sync/aref.rs new file +170 -0

170 lines not on this page · raw message

rust/kernel/types.rs +3 -151

170 lines not on this page · raw message

Signature · 1 line
2.34.1
reviewer
#1 lore raw
Quoted 9 lines · Shankari Anand

Move the definitions of ARef and AlwaysRefCounted from types.rs to a new file sync/aref.rs.
Define the corresponding aref module under rust/kernel/sync.rs. These types are better grouped in sync with other synchronization primitives.

To avoid breaking existing imports, they are re-exported from types.rs. Drop unused imports mem::ManuallyDrop, ptr::NonNull from types.rs, they are now only used in sync/aref.rs, where they are already imported.

Quoted 8 lines

---

The moving patch and updating patch are split as discussed in https://github.com/Rust-for-Linux/linux/issues/1173
A follow-up patch will update all the call sites to import ARef and AlwaysRefCounted directly from sync::aref instead of types.

Ah, I meant that you can just send the two patches in a single series. No need to wait for anything (it's easier to review the two distinct changes, that's why I thought it's a good idea to split them).

Quoted 9 lines

Fixes were also made to intra-doc links: unresolved references to inc_ref and dec_ref were updated to use AlwaysRefCounted::inc_ref and AlwaysRefCounted::dec_ref.

---
 rust/kernel/sync.rs      |   1 +
 rust/kernel/sync/aref.rs | 170 +++++++++++++++++++++++++++++++++++++++
 rust/kernel/types.rs     | 156 ++---------------------------------
 3 files changed, 176 insertions(+), 151 deletions(-)
 create mode 100644 rust/kernel/sync/aref.rs

This doesn't apply to rust-next or v6.16-rc3, what base did you use? When creating .patch files for sending, please use --base to make git add your base at the bottom.

---
Cheers,
Benno

#2 lore raw
Quoted 3 lines

Ah, I meant that you can just send the two patches in a single series. No need to wait for anything (it's easier to review the two distinct changes, that's why I thought it's a good idea to split them).

Apologies for the misunderstanding on my part regarding the split. I now understand that both patches should be sent as a single series for ease of review. Thanks for the clarification!

Quoted 3 lines

This doesn't apply to rust-next or v6.16-rc3, what base did you use? When creating .patch files for sending, please use --base to make git add your base at the bottom.

Regarding the patch not applying cleanly: I had tested it on rust-next at the time, but it’s possible that a new commit has landed upstream since then which is causing the conflict. I’ll rebase both patches on the latest rust-next, re-test, and resend them together as a patch series with --base included as well.

Thanks again for your feedback!

Quoted 41 lines · Benno Lossin
Quoted 9 lines · Shankari Anand

Move the definitions of ARef and AlwaysRefCounted from types.rs to a new file sync/aref.rs.
Define the corresponding aref module under rust/kernel/sync.rs. These types are better grouped in sync with other synchronization primitives.

To avoid breaking existing imports, they are re-exported from types.rs. Drop unused imports mem::ManuallyDrop, ptr::NonNull from types.rs, they are now only used in sync/aref.rs, where they are already imported.

Quoted 8 lines

---

The moving patch and updating patch are split as discussed in https://github.com/Rust-for-Linux/linux/issues/1173
A follow-up patch will update all the call sites to import ARef and AlwaysRefCounted directly from sync::aref instead of types.

Ah, I meant that you can just send the two patches in a single series. No need to wait for anything (it's easier to review the two distinct changes, that's why I thought it's a good idea to split them).

Quoted 9 lines

Fixes were also made to intra-doc links: unresolved references to inc_ref and dec_ref were updated to use AlwaysRefCounted::inc_ref and AlwaysRefCounted::dec_ref.

---
 rust/kernel/sync.rs      |   1 +
 rust/kernel/sync/aref.rs | 170 +++++++++++++++++++++++++++++++++++++++
 rust/kernel/types.rs     | 156 ++---------------------------------
 3 files changed, 176 insertions(+), 151 deletions(-)
 create mode 100644 rust/kernel/sync/aref.rs

This doesn't apply to rust-next or v6.16-rc3, what base did you use? When creating .patch files for sending, please use --base to make git add your base at the bottom.

---
Cheers,
Benno