Page MenuHomeFreeBSD

MADV_FREE: Quick fix to time rewind
ClosedPublic

Authored by nwf20_cl.cam.ac.uk on Sep 4 2019, 1:35 PM.

Details

Summary

Don't FREE pages in a shadowing object. While this degrades MADV_FREE to a no-op (and we could, instead, choose to fall back to MADV_DONTNEED, at the cost of changing pmap_madvise), this is presently considered a temporary fix. We may prefer to risk a little fragmentation of the map by creating a zero/OBJT_DEFAULT entry over top of the existing object and, simultaneously, revert to the existing marking any pages in the former shadowing object in the advised region as reclaimable. At least one consumer of MADV_FREE (snmalloc) may use mmap() to construct zeroed pages "eventually" here anyway, so the fragmentation may be coming anyway.

See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240061

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

kib added inline comments.
sys/vm/vm_map.c
2777

I suggest to leave only the first sentence in the comment. You can write more in the commit message (AKA the review summary).

On the other hand, it might be worth noting that (even) read-only map lock prevents both object.vm_object and its backing_object from changing under us, so the test is valid after being performed.

I think this is fine modulo kib's comment. As I noted in the PR we could downgrade to MADV_DONTNEED instead, but that requires a change to pmap_advise().

This revision is now accepted and ready to land.Sep 4 2019, 5:03 PM
This revision was automatically updated to reflect the committed changes.