]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
mkimg: Indicate that input file pages are unlikely to be reused.
authormarkj <markj@FreeBSD.org>
Wed, 1 Jun 2016 02:30:06 +0000 (02:30 +0000)
committermarkj <markj@FreeBSD.org>
Wed, 1 Jun 2016 02:30:06 +0000 (02:30 +0000)
commitbe9a20239f1e1d061ba3cb8c213dba515038484f
tree8243804fb1276e4c472709c21dbaf782a12a0ef4
parente4b5ee08b537ee3e1a899cbc2b82af88a52d9925
mkimg: Indicate that input file pages are unlikely to be reused.

mkimg(1) uses a swap file to back input file chunks. When the output file
is being written out, blocks of the swap file are mapped and their contents
copied. This causes the backing VM pages to enter the active queue, and when
the output file is large relative to system memory (as is generally the
case), can result in a shortfall of inactive memory. This causes the
pagedaemon to aggressively scan the active queue and swap out process
memory in an attempt to meet the shortfall. Because mkimg's input files
are typically the intermediate result of some build process, there's no
need to push them all through the active queue. Use madvise(2) to indicate
that the backing pages may be reclaimed in preference to active pages. In
the case of the swap file, these pages will be freed as soon as mkimg
exits anyway.

When using mkimg on a desktop-class system with large amounts of dirty
process memory, this change substantially improves mkimg runtime and
reduces swap usage.

Reviewed by: marcel
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D6654
usr.bin/mkimg/image.c