git: 28af3eb62b73 - main - Revert "swap_pager: small improvement to find_least"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 16 Jun 2024 15:37:43 UTC
The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=28af3eb62b733ce4d7e01e9ba30b7a18c8cf5369 commit 28af3eb62b733ce4d7e01e9ba30b7a18c8cf5369 Author: Doug Moore <dougm@FreeBSD.org> AuthorDate: 2024-06-16 15:37:16 +0000 Commit: Doug Moore <dougm@FreeBSD.org> CommitDate: 2024-06-16 15:37:16 +0000 Revert "swap_pager: small improvement to find_least" This reverts commit dd0e5c02ab13b9eb240d42a71a8f41a8b036bd33. --- sys/vm/swap_pager.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 455c39ab6fd7..8d9236a2eb1a 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -2298,17 +2298,22 @@ swap_pager_find_least(vm_object_t object, vm_pindex_t pindex) VM_OBJECT_ASSERT_LOCKED(object); MPASS((object->flags & OBJ_SWAP) != 0); + if (pctrie_is_empty(&object->un_pager.swp.swp_blks)) + return (object->size); sb = SWAP_PCTRIE_LOOKUP_GE(&object->un_pager.swp.swp_blks, rounddown(pindex, SWAP_META_PAGES)); if (sb == NULL) return (object->size); - for (i = pindex - sb->p; i < SWAP_META_PAGES; i++) { - if (sb->d[i] != SWAPBLK_NONE) - return (sb->p + i); + if (sb->p < pindex) { + for (i = pindex % SWAP_META_PAGES; i < SWAP_META_PAGES; i++) { + if (sb->d[i] != SWAPBLK_NONE) + return (sb->p + i); + } + sb = SWAP_PCTRIE_LOOKUP_GE(&object->un_pager.swp.swp_blks, + roundup(pindex, SWAP_META_PAGES)); + if (sb == NULL) + return (object->size); } - sb = SWAP_PCTRIE_LOOKUP_GE(&object->un_pager.swp.swp_blks, pindex); - if (sb == NULL) - return (object->size); for (i = 0; i < SWAP_META_PAGES; i++) { if (sb->d[i] != SWAPBLK_NONE) return (sb->p + i); @@ -2318,7 +2323,7 @@ swap_pager_find_least(vm_object_t object, vm_pindex_t pindex) * We get here if a swblk is present in the trie but it * doesn't map any blocks. */ - __unreachable(); + MPASS(0); return (object->size); }