Page MenuHomeFreeBSD

MADV_FREE: Quick fix to time rewind

Authored by on Wed, Sep 4, 1:35 PM.



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.


Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kib added reviewers: markj, alc.Wed, Sep 4, 2:17 PM
kib added inline comments.
2786 ↗(On Diff #61642)

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.

markj added a comment.Wed, Sep 4, 3:31 PM

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(). edited the summary of this revision. (Show Details)Wed, Sep 4, 4:26 PM edited the summary of this revision. (Show Details)
kib accepted this revision.Wed, Sep 4, 5:03 PM
This revision is now accepted and ready to land.Wed, Sep 4, 5:03 PM
markj accepted this revision.Wed, Sep 4, 7:41 PM
This revision was automatically updated to reflect the committed changes.