Page MenuHomeFreeBSD

swap_pager_freespace: fix freed count
ClosedPublic

Authored by dougm on Aug 6 2024, 7:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 5, 1:42 PM
Unknown Object (File)
Wed, Oct 30, 5:00 AM
Unknown Object (File)
Wed, Oct 30, 1:55 AM
Unknown Object (File)
Sun, Oct 20, 1:41 PM
Unknown Object (File)
Wed, Oct 16, 4:06 PM
Unknown Object (File)
Wed, Oct 16, 10:20 AM
Unknown Object (File)
Oct 2 2024, 2:39 AM
Unknown Object (File)
Sep 30 2024, 3:10 PM
Subscribers

Details

Summary

I suspect an error in the computation of *moved in swp_pager_meta_transfer that would produce incorrect output from swap_pager_freespace.

In the main loop of swp_pager_meta_transfer (after the first iteration) pindex is the value that was passed to LOOKUP_GE to produce a new swblk sb. This code seems to assume that pindex == sb->p, but if there's a gap between the end of one swblk and the beginning of another, then they differ according to the size of that gap.

Concretely, if on iteration 2, pindex is 32 and sb->p is 48, then the vm_page_lookup calls will be for values in the range [32,48), while the sb block represents values in [48, 64). So the wrong pages will be looked up.

If I'm right, then this patch should fix it. If I'm wrong because there can be no gaps, then we should be using LOOKUP instead of LOOKUP_GE. If I'm wrong for some other reason, because my understanding is too limited, I apologize bothering you with this.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dougm requested review of this revision.Aug 6 2024, 7:27 AM
dougm updated this revision to Diff 141852.
dougm created this revision.

Add missing parameter.

sys/vm/swap_pager.c
2179

Wouldn't we get the problem with the gap there as well?

IMO we should adjust pindex right after SWAP_PCTRIE_LOOKUP_GE() if it returned sb which does not contain the pindex info.

sys/vm/swap_pager.c
2179

If we've jumped a gap, then pindex < sb->p, so start will be 0, which is correct.

If we adjust pindex right after SWAP_PCTRIE_LOOKUP_GE, then start will always be 0, which is wrong in the case of the first iteration where pindex is 20 and sb->p is 16.

This revision is now accepted and ready to land.Aug 7 2024, 8:11 AM
This revision was automatically updated to reflect the committed changes.