Generic Linux architectural discussions
 help / color / mirror / Atom feed
* [PATCH v2] coredump: exit_files() in coredump_wait() if MMF_DUMP_MAPPED_SHARED is not set
@ 2026-06-18 15:03 Xin Zhao
  2026-06-18 16:07 ` Pedro Falcato
  0 siblings, 1 reply; 4+ messages in thread
From: Xin Zhao @ 2026-06-18 15:03 UTC (permalink / raw)
  To: viro, brauner, jack, jlayton, chuck.lever, alex.aring, arnd,
	ebiederm, keescook, mcgrof, j.granados, allen.lkml
  Cc: linux-fsdevel, linux-kernel, linux-arch, Xin Zhao

A coredump typically takes some time to complete. If we happen to hold a
write lock with flock just before triggering the coredump, that write lock
will not be released during the entire coredump process. As a result,
other processes attempting to acquire the same write lock may experience
significant delays.

To address this, call exit_files() in the end of coredump_wait(), if
MMF_DUMP_MAPPED_SHARED is not set.

Signed-off-by: Xin Zhao <jackzxcui1989@163.com>
---

Change in v2:
- Get rid of the implement of adding new fcntl API, the issue does not
  worth inflicting the cost on everyone,
  as suggested by Al Viro.
- Call exit_files() in coredump_wait(),
  as suggested by Eric W. Biederman.
  Add MMF_DUMP_MAPPED_SHARED mm_flags_test() check to filter cases that
  need to dump file-backed shared memory.

v1:
- Link to v1: https://lore.kernel.org/all/20260618030700.2511668-1-jackzxcui1989@163.com/
---
 fs/coredump.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/coredump.c b/fs/coredump.c
index bb6fdb1f4..e20baf44f 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -548,6 +548,9 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
 		}
 	}
 
+	if (!mm_flags_test(MMF_DUMP_MAPPED_SHARED, tsk->mm))
+		exit_files(tsk);
+
 	return core_waiters;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-19  0:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-18 15:03 [PATCH v2] coredump: exit_files() in coredump_wait() if MMF_DUMP_MAPPED_SHARED is not set Xin Zhao
2026-06-18 16:07 ` Pedro Falcato
2026-06-18 17:19   ` Pedro Falcato
2026-06-19  0:39     ` Xin Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox