[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLghpXuv3sgGnO4dBydnn8Agqpm0ZDESQcwrbWEu58AyGxQ@mail.gmail.com>
Date: Thu, 25 Jul 2024 17:32:48 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>, Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...sung.com>,
Alexander Viro <viro@...iv.linux.org.uk>, Christian Brauner <brauner@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Arve Hjønnevåg <arve@...roid.com>,
Todd Kjos <tkjos@...roid.com>, Martijn Coenen <maco@...roid.com>,
Joel Fernandes <joel@...lfernandes.org>, Carlos Llamas <cmllamas@...gle.com>,
Suren Baghdasaryan <surenb@...gle.com>, Dan Williams <dan.j.williams@...el.com>,
Matthew Wilcox <willy@...radead.org>, Thomas Gleixner <tglx@...utronix.de>, Daniel Xu <dxu@...uu.xyz>,
Martin Rodriguez Reboredo <yakoyoku@...il.com>, Trevor Gross <tmgross@...ch.edu>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-fsdevel@...r.kernel.org,
Kees Cook <kees@...nel.org>
Subject: Re: [PATCH v8 1/8] rust: types: add `NotThreadSafe`
On Thu, Jul 25, 2024 at 5:30 PM Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Thu, Jul 25, 2024 at 05:09:14PM +0200, Alice Ryhl wrote:
>
> > > As per always for not being able to read rust; how does this extend to
> > > get_task_struct()? Once you've taken a reference on current, you should
> > > be free to pass it along to whomever.
> >
> > Once you take a reference on current, it becomes thread-safe. This is
> > because taking a reference creates a value of type ARef<Task> rather
> > than TaskRef, and ARef<Task> is considered thread-safe.
>
> Ignoring comments, there isn't a single mention of ARef there. Where
> does it come from?
That's because the conversion to ARef<Task> is a two-step process. The
TaskRef type just provides a conversion from &TaskRef to &Task via the
`impl Deref` block. There is a conversion from &Task to ARef<Task>
elsewhere, and this conversion is where the call to get_task_struct()
happens.
Alice
Powered by blists - more mailing lists