Page MenuHomeFreeBSD

mkimg: Indicate that input image pages are unlikely to be reused
ClosedPublic

Authored by markj on May 31 2016, 1:20 AM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 15 2023, 10:47 AM
Unknown Object (File)
Apr 26 2023, 3:48 PM
Unknown Object (File)
Apr 8 2023, 9:16 PM
Unknown Object (File)
Jan 10 2023, 7:57 PM
Unknown Object (File)
Nov 26 2022, 8:55 AM
Unknown Object (File)
Feb 4 2017, 11:07 PM
Unknown Object (File)
Dec 13 2016, 8:30 AM
Unknown Object (File)
Oct 29 2016, 12:23 PM
Subscribers

Details

Summary

Currently, when mkimg(1) is used to create an image that's large
relative to system memory, it pulls its input files (e.g. filesystem
images) into the active queue in image_copyout_file(). This triggers
some aggressive behaviour from the pagedaemon, since it results in a
state where the inactive queue is depleted and almost all of system
memory is in the active queue. In particular, this forces the pagedaemon
to swap out lots of anonymous memory in an attempt to address the
shortfall.

Use madvise(2) in image_file_unmap() to hint to the VM that pages
backing input files should be reclaimed before other pages. This
basically means that they'll be reclaimed in FIFO order from the
inactive queue when the system is under memory pressure, avoiding
a global impact on the system.

Test Plan

Tested on a desktop-class system with 16GB of memory, creating
16GB raw bhyve images. With this change, I see an order of magnitude
less swap usage after creating an image. I also see a large runtime
improvement if most of the system's dirty anonymous memory has
not already been swapped out: 50s down to 20s. Once most inactive
pages have been swapped out, there's no significant difference in
runtime.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj retitled this revision from to mkimg: Indicate that input image pages are unlikely to be reused.
markj edited the test plan for this revision. (Show Details)
markj updated this object.
markj edited the test plan for this revision. (Show Details)
markj added a reviewer: marcel.
marcel edited edge metadata.

Very nice!

This revision is now accepted and ready to land.May 31 2016, 2:40 AM
This revision was automatically updated to reflect the committed changes.