mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: <jongan.kim@lge.com>, <a.hindborg@kernel.org>,
	<aliceryhl@google.com>, <arve@android.com>,
	<bjorn3_gh@protonmail.com>, <boqun.feng@gmail.com>,
	<brauner@kernel.org>, <cmllamas@google.com>, <dakr@kernel.org>,
	<daniel.almeida@collabora.com>, <gary@garyguo.net>,
	<gregkh@linuxfoundation.org>, <tamird@gmail.com>,
	<tkjos@android.com>, <tmgross@umich.edu>,
	<viresh.kumar@linaro.org>, <vitaly.wool@konsulko.se>,
	<yury.norov@gmail.com>, <lossin@kernel.org>, <ojeda@kernel.org>
Cc: <heesu0025.kim@lge.com>, <ht.hong@lge.com>,
	<jungsu.hwang@lge.com>, <kernel-team@android.com>,
	<linux-kernel@vger.kernel.org>, <rust-for-linux@vger.kernel.org>,
	<sanghun.lee@lge.com>, <seulgi.lee@lge.com>,
	<sunghoon.kim@lge.com>
Subject: Re: [PATCH v3 2/3] rust: pid: add Pid abstraction and init_ns helper
Date: Tue, 03 Feb 2026 13:01:38 +0000	[thread overview]
Message-ID: <DG5CHD1A9UGQ.2V2A67G7Z6GF4@garyguo.net> (raw)
In-Reply-To: <20260203065928.4736-3-jongan.kim@lge.com>

On Tue Feb 3, 2026 at 6:59 AM GMT, jongan.kim wrote:
> From: HeeSu Kim <heesu0025.kim@lge.com>
>
> Add a new Pid abstraction in rust/kernel/pid.rs that wraps the
> kernel's struct pid and provides safe Rust interfaces for:
> - find_vpid: Find a pid by number under RCU protection
> - pid_task: Get the task associated with a pid under RCU protection
>
> Also add init_ns() associated function to PidNamespace to get
> a reference to the init PID namespace.
>
> These abstractions use lifetime-bounded references tied to RCU guards
> to ensure memory safety when accessing RCU-protected data structures.
>
> Signed-off-by: HeeSu Kim <heesu0025.kim@lge.com>
> ---
> v2 -> v3:
> - Add Send/Sync traits for Pid
> - Add AlwaysRefCounted for Pid with rust_helper_get_pid
> - Add from_raw() constructor to Pid and Task
> - Rename find_vpid_with_guard -> find_vpid
> - Rename pid_task_with_guard -> pid_task 
> - Convert init_pid_ns() to PidNamespace::init_ns()
> - Add PartialEq/Eq for PidNamespace (Alice)
> - Add rust/helpers/pid.c for get_pid() wrapper
>
>  rust/helpers/helpers.c       |   1 +
>  rust/helpers/pid.c           |   9 +++
>  rust/kernel/lib.rs           |   1 +
>  rust/kernel/pid.rs           | 138 +++++++++++++++++++++++++++++++++++
>  rust/kernel/pid_namespace.rs |  17 +++++
>  rust/kernel/task.rs          |  13 ++++
>  6 files changed, 179 insertions(+)
>  create mode 100644 rust/helpers/pid.c
>  create mode 100644 rust/kernel/pid.rs
>
> diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
> index 79c72762ad9c..3138b88df24f 100644
> --- a/rust/helpers/helpers.c
> +++ b/rust/helpers/helpers.c
> @@ -38,6 +38,7 @@
>  #include "of.c"
>  #include "page.c"
>  #include "pci.c"
> +#include "pid.c"
>  #include "pid_namespace.c"
>  #include "platform.c"
>  #include "poll.c"
> diff --git a/rust/helpers/pid.c b/rust/helpers/pid.c
> new file mode 100644
> index 000000000000..1337ca63ab0f
> --- /dev/null
> +++ b/rust/helpers/pid.c
> @@ -0,0 +1,9 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <linux/pid.h>
> +
> +/* Get a reference on a struct pid. */
> +struct pid *rust_helper_get_pid(struct pid *pid)

This needs a __rust_helper annotation.

The rest looks superb. With this fixed:

    Reviewed-by: Gary Guo <gary@garyguo.net>

Best,
Gary

> +{
> +	return get_pid(pid);
> +}
> diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
> index f812cf120042..60a518d65d0e 100644
> --- a/rust/kernel/lib.rs
> +++ b/rust/kernel/lib.rs

  reply	other threads:[~2026-02-03 13:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03  6:59 [PATCH v3 0/3] binder: handle PID namespace conversion for freeze operation jongan.kim
2026-02-03  6:59 ` [PATCH v3 1/3] " jongan.kim
2026-02-03 20:38   ` Yury Norov
2026-02-04  9:05     ` jongan.kim
2026-02-04 17:04       ` Yury Norov
2026-02-05  5:30         ` jongan.kim
2026-02-03  6:59 ` [PATCH v3 2/3] rust: pid: add Pid abstraction and init_ns helper jongan.kim
2026-02-03 13:01   ` Gary Guo [this message]
2026-02-03  6:59 ` [PATCH v3 3/3] rust_binder: handle PID namespace conversion for freeze operation jongan.kim
2026-02-03 12:59   ` Gary Guo
2026-02-04  9:11     ` jongan.kim
2026-02-04 10:50       ` Alice Ryhl
2026-02-05  5:01         ` jongan.kim
2026-02-05  8:20           ` 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=DG5CHD1A9UGQ.2V2A67G7Z6GF4@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=arve@android.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=brauner@kernel.org \
    --cc=cmllamas@google.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heesu0025.kim@lge.com \
    --cc=ht.hong@lge.com \
    --cc=jongan.kim@lge.com \
    --cc=jungsu.hwang@lge.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sanghun.lee@lge.com \
    --cc=seulgi.lee@lge.com \
    --cc=sunghoon.kim@lge.com \
    --cc=tamird@gmail.com \
    --cc=tkjos@android.com \
    --cc=tmgross@umich.edu \
    --cc=viresh.kumar@linaro.org \
    --cc=vitaly.wool@konsulko.se \
    --cc=yury.norov@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®