]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Implement sparse core dumps
authormarkj <markj@FreeBSD.org>
Fri, 2 Oct 2020 17:50:22 +0000 (17:50 +0000)
committermarkj <markj@FreeBSD.org>
Fri, 2 Oct 2020 17:50:22 +0000 (17:50 +0000)
commitb5a8a00c4307f6a1024e85e779c8e418ee087127
tree48e8f80e8f761026dd2b1a55043a65ade961562e
parent6f3e6e054cae25d733cbc55bc6172aba091a9da0
Implement sparse core dumps

Currently we allocate and map zero-filled anonymous pages when dumping
core.  This can result in lots of needless disk I/O and page
allocations.  This change tries to make the core dumper more clever and
represent unbacked ranges of virtual memory by holes in the core dump
file.

Add a new page fault type, VM_FAULT_NOFILL, which causes vm_fault() to
clean up and return an error when it would otherwise map a zero-filled
page.  Then, in the core dumper code, prefault all user pages and handle
errors by simply extending the size of the core file.  This also fixes a
bug related to the fact that vn_io_fault1() does not attempt partial I/O
in the face of errors from vm_fault_quick_hold_pages(): if a truncated
file is mapped into a user process, an attempt to dump beyond the end of
the file results in an error, but this means that valid pages
immediately preceding the end of the file might not have been dumped
either.

The change reduces the core dump size of trivial programs by a factor of
ten simply by excluding unaccessed libc.so pages.

PR: 249067
Reviewed by: kib
Tested by: pho
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26590
sys/kern/imgact_elf.c
sys/vm/vm_fault.c
sys/vm/vm_map.h