All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: "Christian Brauner" <christian@brauner.io>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Panagiotis Foliadis" <pfoliadis@posteo.net>,
	"Shankari Anand" <shankari.ak0208@gmail.com>,
	"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
	"Alexey Gladkov" <legion@kernel.org>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: rust: wrong SAFETY comments in group_leader() and pid() + questions
Date: Thu, 11 Dec 2025 01:20:08 +0000	[thread overview]
Message-ID: <aTocSJ_zlTkejD5F@google.com> (raw)
In-Reply-To: <aTbg6O2HS2fGAow6@redhat.com>

On Mon, Dec 08, 2025 at 03:30:00PM +0100, Oleg Nesterov wrote:
> Alice,
> 
> Thanks again for your explanations. Not that I fully understand
> them, though ;)
> 
> On 12/05, Alice Ryhl wrote:
> >
> > To start with, it's likely that this comment is not the right choice
> > for this function, given our discussion. Most likely group_leader()
> > needs to be moved to `impl CurrentTask {}`
> 
> I obviously can't comment this proposal,
> 
> > and the safety comment needs
> > to explain why being the current task ensures that the returned &Task
> > lives for long enough.
> 
> This is simple. task->group_leader can't change or go away until
> this task exits or execs. The "current" task can't exit/exec.
> 
> (This also covers the race with mt-exec from current's subthread,
>  the execing thread will kill all the threads and wait until they
>  all pass release_task(). Only then it will change ->group_leader).
> 
> > impl CurrentTask {
> >     fn group_leader(&self) -> &Task {
> >         // SAFETY: This is the current task, so the task must be alive.
> >         // Therefore the group leader cannot change, and thus it will
> >         // stay valid as long as self is the current task.
> >         unsafe { &*bindings::task_group_leader(self.as_ptr()).cast::<Task>() }
> >     }
> > }
> 
> Yes, the comment looks good to me.
> 
> But we don't have the task_group_leader() helper yet, so far I
> only sent the trivial initial preparations, see
> https://lore.kernel.org/all/aTV1KYdcDGvjXHos@redhat.com/
> 
> So if you are going to move Task::group_leader to the
> CurrentTask block, please use .group_leader directly, like
> the current code does.

Yeah I'll be moving it soon (after conferences). I'll add a Reported-by
tag for you if that's okay :)

Alice

  reply	other threads:[~2025-12-11  1:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-05 14:08 rust: wrong SAFETY comments in group_leader() and pid() + questions Oleg Nesterov
2025-12-05 14:19 ` Alice Ryhl
2025-12-05 14:29   ` Alice Ryhl
2025-12-05 17:21     ` Oleg Nesterov
2025-12-05 18:17       ` Alice Ryhl
2025-12-08 14:30         ` Oleg Nesterov
2025-12-11  1:20           ` Alice Ryhl [this message]
2025-12-08 15:43         ` Gary Guo
2025-12-11  1:16           ` Alice Ryhl
2025-12-05 15:35   ` Oleg Nesterov
2025-12-05 16:28     ` Alice Ryhl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aTocSJ_zlTkejD5F@google.com \
    --to=aliceryhl@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=christian@brauner.io \
    --cc=dakr@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=legion@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=oleg@redhat.com \
    --cc=pfoliadis@posteo.net \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=shankari.ak0208@gmail.com \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.