diff options
| author | Christian Brauner <brauner@kernel.org> | 2026-09-10 17:48:04 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-10-05 13:11:48 +0200 |
| commit | c8d9b40eabf07d822f212bd012e717f3947c4d7b (patch) | |
| tree | 7fe1e7d3ad07732b521fc33b5dd52fcdb877ecdf /tools/lib/python | |
| parent | 2b256ebe82872a85c91cbb26e9edd314923e0fbc (diff) | |
| download | linux-next-c8d9b40eabf07d822f212bd012e717f3947c4d7b.tar.gz linux-next-c8d9b40eabf07d822f212bd012e717f3947c4d7b.zip | |
fs: make close_files() synchronous
When the last reference to a descriptor table is dropped close_files()
closes every file but punts the actual work to task work. For an exiting
task that task work only runs in exit_task_work().
Before commit 4a9d4b024a31 ("switch fput to task_work_add") fput() was
synchronous everywhere and exit released its files in exit_files().
The deferral made fput() safe from any context. And exit_files()
offloaded to task work as a side-effect. And that has downsides.
Oleg and Neil noticed that some time ago. A task that exits with a big
descriptor table ends up queueing a very large number of files on task
work. That leaves a list for any later task_work_cancel() to search
under ->pi_lock and costs a lot of atomics too.
Let close_files() close right away. Flush and put each file inline the
way close(2) does. The final __fput() runs during the table walk now
instead of from task_work_run() in exit_task_work(). One difference is
the order: task work ran the final __fput()s in reverse and now they run
in table order.
Every put of a dying table is synchronous now:
- exit_files()
- copy_process()
- close_range(CLOSE_RANGE_UNSHARE)
- unshare(2)
- exec
Kernel threads don't own a file descriptor table and exec already splats
were they to exec. kthreadd and every kthread share init_files and
init_task pins that forever.
Link: https://patch.msgid.link/20260910-work-coredump-unlock-self-v4-6-a5c1800dc930@kernel.org
Reviewed-by: NeilBrown <neil@brown.name>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
