Skip to content

Commit 0a36bad

Browse files
oleg-nesterovbrauner
authored andcommitted
release_task: kill the no longer needed get/put_pid(thread_pid)
After the commit 7903f90 ("pid: perform free_pid() calls outside of tasklist_lock") __unhash_process() -> detach_pid() no longer calls free_pid(), proc_flush_pid() can just use p->thread_pid without the now pointless get_pid() + put_pid(). Signed-off-by: Oleg Nesterov <[email protected]> Link: https://lore.kernel.org/[email protected] Reviewed-by: Mateusz Guzik <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent a9d7de0 commit 0a36bad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/exit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ void release_task(struct task_struct *p)
258258
pidfs_exit(p);
259259
cgroup_release(p);
260260

261-
thread_pid = get_pid(p->thread_pid);
261+
/* Retrieve @thread_pid before __unhash_process() may set it to NULL. */
262+
thread_pid = task_pid(p);
262263

263264
write_lock_irq(&tasklist_lock);
264265
ptrace_release_task(p);
@@ -287,8 +288,8 @@ void release_task(struct task_struct *p)
287288
}
288289

289290
write_unlock_irq(&tasklist_lock);
291+
/* @thread_pid can't go away until free_pids() below */
290292
proc_flush_pid(thread_pid);
291-
put_pid(thread_pid);
292293
add_device_randomness(&p->se.sum_exec_runtime,
293294
sizeof(p->se.sum_exec_runtime));
294295
free_pids(post.pids);

0 commit comments

Comments
 (0)