Re: [RFC PATCH] pidfs: ensure consistent ENOENT/ESRCH reporting
From: Oleg Nesterov
Date: Fri Apr 11 2025 - 07:42:32 EST
On 04/11, Oleg Nesterov wrote:
>
> On 04/11, Christian Brauner wrote:
> >
> > > Looking close at this. Why is:
> > >
> > > if (type == PIDTYPE_PID) {
> > > WARN_ON_ONCE(pid_has_task(pid, PIDTYPE_PID));
> > > wake_up_all(&pid->wait_pidfd);
> > > }
> > >
> > > located in __change_pid()? The only valid call to __change_pid() with a NULL
> > > argument and PIDTYPE_PID is from __unhash_process(), no?
> >
> > We used to perform free_pid() directly from __change_pid() so prior to
> > v6.15 changes it wasn't possible.
>
> Yes, exactly ;)
To clarify, it was actually possible because the caller, release_task(),
does
thread_pid = get_pid(p->thread_pid);
before __exit_signal() and detach_pid(PIDTYPE_PID) uses the same
task_struct->thread_pid. But I didn't want to rely on this fact.
And it seems we can do another cleanup... We can kill the no longer
needed get_pid/put_pid in release_task(). I'll send the patch.
> > Now that we free the pids separately let's
> > just move the notification into __unhash_process(). I have a patch ready
> > for this.
>
> Agreed,
>
> Acked-by: Oleg Nesterov <oleg@xxxxxxxxxx>