pidfs: reduce wait_pidfd lock scope

There's no need to hold the lock after we realized that pid->attr is
set. We're holding a reference to struct pid so it won't go away and
pidfs_exit() is called once per struct pid.

Link: https://patch.msgid.link/20251105-work-pidfs-wait_pidfd-lock-v1-1-02638783be07@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2025-11-05 00:05:01 +01:00
parent a45ff1c7c9
commit 390d967653
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
1 changed files with 13 additions and 11 deletions

View File

@ -634,7 +634,8 @@ void pidfs_exit(struct task_struct *tsk)
might_sleep();
guard(spinlock_irq)(&pid->wait_pidfd.lock);
/* Synchronize with pidfs_register_pid(). */
scoped_guard(spinlock_irq, &pid->wait_pidfd.lock) {
attr = pid->attr;
if (!attr) {
/*
@ -646,6 +647,7 @@ void pidfs_exit(struct task_struct *tsk)
pid->attr = PIDFS_PID_DEAD;
return;
}
}
/*
* If @pid->attr is set someone might still legitimately hold a