Re: [RFC PATCH v10 18/28] fork: Support CLONE_INTO_RUN in clone3()
From: bot+bpf-ci
Date: Fri Dec 04 2026 - 23:17:58 EST
> fork: Support CLONE_INTO_RUN in clone3()
TL;DR: Design/cleanup question, not a bug: new pid_ns_is_adding() in fork.c
duplicates runfd_pidns_alive() and the loop in alloc_pid(), differing in
READ_ONCE() and init_pid_ns handling. Could they share one helper?
> diff --git a/kernel/fork.c b/kernel/fork.c
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
[ ... ]
> @@ -2019,6 +2035,17 @@ static bool need_futex_hash_allocate_default(u64 clone_flags)
> return clone_flags & CLONE_VM;
> }
>
> +static bool pid_ns_is_adding(const struct pid *pid)
> +{
> + int i;
> +
> + for (i = pid->level; i >= 0; i--) {
> + if (unlikely(!(pid->numbers[i].ns->pid_allocated & PIDNS_ADDING)))
> + return false;
> + }
> + return true;
> +}
> +
This isn't a bug, but this helper answers the same question as
runfd_pidns_alive() in kernel/runfd.c, which walks pid_ns->parent using
READ_ONCE() and stops before init_pid_ns. alloc_pid() in kernel/pid.c also
has an open-coded copy of the same loop:
for (upid = pid->numbers + ns->level; upid >= pid->numbers; --upid)
if (unlikely(!(upid->ns->pid_allocated & PIDNS_ADDING)))
Could these share one helper in kernel/pid.c or pid_namespace.h? Or is
there a reason they differ in READ_ONCE() use and in whether init_pid_ns is
checked?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/47474652355