Re: [PATCH 1/2] rust: sync: add Arc::DATA_OFFSET

From
Daniel Almeida <daniel.almeida@collabora.com>
Date
2025-12-04 13:32:44
Also in
lkml, rust-for-linux
Reply to
Alice Ryhl, 2025-12-03
quoted hunk ↗ jump to hunk
On 3 Dec 2025, at 08:48, Alice Ryhl [off-list ref] wrote:

This constant will be used to expose some offset constants from the Rust
Binder driver to tracepoints which are implemented in C. The constant is
usually equal to sizeof(refcount_t), but may be larger if T has a large
alignment.

Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
rust/kernel/sync/arc.rs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
index 289f77abf415a2a52e039a2c0291413eda01217c..921e19333b895f0d971591c4753047d0248a3029 100644
--- a/rust/kernel/sync/arc.rs
+++ b/rust/kernel/sync/arc.rs
@@ -240,6 +240,9 @@ pub fn new(contents: T, flags: Flags) -> Result<Self, AllocError> {
        // `Arc` object.
        Ok(unsafe { Self::from_inner(inner) })
    }
+
+    /// The offset that the value is stored at.
+    pub const DATA_OFFSET: usize = core::mem::offset_of!(ArcInner<T>, data);
}

impl<T: ?Sized> Arc<T> {

-- 
2.52.0.158.g65b55ccf14-goog

Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Thread (6 messages) 6 messages, 3 authors, last reply 2026-01-28
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help