lkml.org 
[lkml]   [2023]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH 01/13] rust: sync: introduce `LockClassKey`
    From
    On 3/30/23 06:39, Wedson Almeida Filho wrote:
    > From: Wedson Almeida Filho <walmeida@microsoft.com>
    >
    > It is a wrapper around C's `lock_class_key`, which is used by the
    > synchronisation primitives that are checked with lockdep. This is in
    > preparation for introducing Rust abstractions for these primitives.
    >
    > Cc: Peter Zijlstra <peterz@infradead.org>
    > Cc: Ingo Molnar <mingo@redhat.com>
    > Cc: Will Deacon <will@kernel.org>
    > Cc: Waiman Long <longman@redhat.com>
    > Co-developed-by: Boqun Feng <boqun.feng@gmail.com>
    > Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
    > Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
    > ---
    > +// SAFETY: `bindings::lock_class_key` is designed to be used concurrently from multiple threads and
    > +// provides its own synchronization.
    > +unsafe impl Sync for LockClassKey {}

    No Send?

    > +
    > +impl LockClassKey {
    > + /// Creates a new lock class key.
    > + pub const fn new() -> Self {
    > + Self(Opaque::uninit())
    > + }
    > +
    > + #[allow(dead_code)]
    > + pub(crate) fn as_ptr(&self) -> *mut bindings::lock_class_key {
    > + self.0.get()
    > + }

    I would just make this pub and drop the `#[allow(dead_code)]`. I think
    it is often useful to have methods like this available publicly.

    \
     
     \ /
      Last update: 2023-03-31 09:28    [W:4.110 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site