mirror of https://github.com/torvalds/linux.git
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:
parent
a45ff1c7c9
commit
390d967653
24
fs/pidfs.c
24
fs/pidfs.c
|
|
@ -634,17 +634,19 @@ void pidfs_exit(struct task_struct *tsk)
|
|||
|
||||
might_sleep();
|
||||
|
||||
guard(spinlock_irq)(&pid->wait_pidfd.lock);
|
||||
attr = pid->attr;
|
||||
if (!attr) {
|
||||
/*
|
||||
* No one ever held a pidfd for this struct pid.
|
||||
* Mark it as dead so no one can add a pidfs
|
||||
* entry anymore. We're about to be reaped and
|
||||
* so no exit information would be available.
|
||||
*/
|
||||
pid->attr = PIDFS_PID_DEAD;
|
||||
return;
|
||||
/* Synchronize with pidfs_register_pid(). */
|
||||
scoped_guard(spinlock_irq, &pid->wait_pidfd.lock) {
|
||||
attr = pid->attr;
|
||||
if (!attr) {
|
||||
/*
|
||||
* No one ever held a pidfd for this struct pid.
|
||||
* Mark it as dead so no one can add a pidfs
|
||||
* entry anymore. We're about to be reaped and
|
||||
* so no exit information would be available.
|
||||
*/
|
||||
pid->attr = PIDFS_PID_DEAD;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue