public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] implement `kernel::sync::Refcount` and convert users
@ 2024-12-21 18:29 Gary Guo
  2024-12-21 18:29 ` [PATCH v2 1/3] rust: implement `kernel::sync::Refcount` Gary Guo
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Gary Guo @ 2024-12-21 18:29 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross
  Cc: Will Deacon, Peter Zijlstra, Mark Rutland, rust-for-linux

Currently there're two refcount usage in rust/, `Arc` and `block::mq`.
`Arc` uses `refcount_t` with FFI calls directly, and `block::mq` use
Rust atomics and custom refcounting.

This series consolidate them to have a single `Refcount` which wraps
`refcount_t` and have it used by both.

With the removal of Rust `AtomicU64` this would also make the code work
for 32-bit systems. See [1] as a previous attempt to fix this issue.

Cc: Will Deacon <will@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/rust-for-linux/20240905061214.3954271-1-davidgow@google.com/ [1]

Changes in v2:
- `Refcount::read` method is dropped
- `Refcount::dec_not_one` method is added and `Arc::into_unique_or_drop`
  is converted to use it.
- Link to v1: https://lore.kernel.org/rust-for-linux/20241004155247.2210469-1-gary@garyguo.net

Gary Guo (3):
  rust: implement `kernel::sync::Refcount`
  rust: convert `Arc` to use `Refcount`
  rust: block: convert `block::mq` to use `Refcount`

 rust/helpers/refcount.c            |  10 +++
 rust/kernel/block/mq/operations.rs |   7 +-
 rust/kernel/block/mq/request.rs    |  70 ++++++------------
 rust/kernel/sync.rs                |   2 +
 rust/kernel/sync/arc.rs            |  64 +++++++----------
 rust/kernel/sync/refcount.rs       | 109 +++++++++++++++++++++++++++++
 6 files changed, 172 insertions(+), 90 deletions(-)
 create mode 100644 rust/kernel/sync/refcount.rs


base-commit: 0c5928deada15a8d075516e6e0d9ee19011bb000
-- 
2.47.0


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

end of thread, other threads:[~2025-01-15 19:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-21 18:29 [PATCH v2 0/3] implement `kernel::sync::Refcount` and convert users Gary Guo
2024-12-21 18:29 ` [PATCH v2 1/3] rust: implement `kernel::sync::Refcount` Gary Guo
2025-01-14 10:04   ` Alice Ryhl
2025-01-14 15:50   ` Boqun Feng
2024-12-21 18:29 ` [PATCH v2 2/3] rust: convert `Arc` to use `Refcount` Gary Guo
2025-01-14 10:02   ` Alice Ryhl
2025-01-15 12:32     ` Gary Guo
2025-01-15 18:53       ` Boqun Feng
2025-01-15 19:01       ` Alice Ryhl
2024-12-21 18:29 ` [PATCH v2 3/3] rust: block: convert `block::mq` " Gary Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox