Page MenuHomeFreeBSD

allow frees to aggregate in swap_pager_copy
ClosedPublic

Authored by dougm on Nov 29 2017, 8:40 AM.
Tags
None
Referenced Files
F93767639: D13290.diff
Thu, Sep 12, 9:28 AM
Unknown Object (File)
Sun, Sep 8, 4:34 PM
Unknown Object (File)
Sun, Sep 8, 2:20 PM
Unknown Object (File)
Sun, Sep 8, 12:13 PM
Unknown Object (File)
Sun, Sep 8, 3:38 AM
Unknown Object (File)
Sun, Sep 8, 1:41 AM
Unknown Object (File)
Sun, Sep 8, 12:51 AM
Unknown Object (File)
Sat, Sep 7, 7:51 PM
Subscribers

Details

Summary

swap_pager_copy frees blocks one at at time, via swp_pager_meta_ctl, with no opportunity to recognize freeing of consecutive blocks and free fewer block ranges. To open that opportunity, this change removes the SWM_FREE option from swp_pager_meta_ctl, and compels the caller to do the freeing when a valid block address is returned. In swap_pager_copy, these frees are aggregated, so that a sequence of them can be done at one time.

The only other caller to swp_pager_meta_ctl that passes SWM_FREE, swp_pager_unswapped, is also modified to handle its single free explicitly.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dougm added a reviewer: alc.
kib added inline comments.
sys/vm/swap_pager.c
314

Perhaps change the value to 0x1 ?

943

Move the variables to the function' locals block, per style.

This revision is now accepted and ready to land.Dec 30 2017, 2:38 PM

Adopt reviewer suggestions.

This revision now requires review to proceed.Dec 30 2017, 4:45 PM
sys/vm/swap_pager.c
2004

Please remove the "and vm_page_t". It was a stale reference even before your proposed change.

2006

"... of either lookup up or removing swapblk ..."

2007

"... meta data. It returns ..."

2008

"... looked up, popped, or ..."

2010

This last sentence makes no sense to me. Just delete it.

2016

I don't see the point of the ".. pop it out". However, I do see the point of saying that this option does not free the swap block.

Adopt reviewer comments about comments.

sys/vm/swap_pager.c
968–969

The "else" should be on the same line as the "}".

Is there some reason why we shouldn't do

srcaddr = swp_pager_meta_ctl(srcobject, i + offset, SWM_POP);
if (srcaddr == SWAPBLK_NONE)
        continue;

before the

dstaddr = swp_pager_meta_ctl(dstobject, i, 0);

?

That would seem to eliminate unnecessary lookups on the dstobject, which would be another improvement over the existing code.

sys/vm/swap_pager.c
938

Let's capitalize the "t" in "transfer" while we're in the neighborhood.

Capitalize in a comment.

As swap_pager_meta_ctl(,,0) looks side-effect free, I agree that it can be called to compute srcaddr before deciding whether to compute dstaddr (with side effects). The comment that precedes all this seems like gibberish, and is mostly deleted.

sys/vm/swap_pager.c
947

I don't think that this comment adds anything useful. Just delete it.

This revision is now accepted and ready to land.Dec 31 2017, 3:45 AM
This revision was automatically updated to reflect the committed changes.