mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-01 14:14:56 +00:00
swap_pager: small improvement to find_least
Drop an unneeded test, a branch and a needless computation to save a few instructions. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D45558
This commit is contained in:
parent
0277c0c6f7
commit
dd0e5c02ab
|
@ -2289,22 +2289,17 @@ 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);
|
||||
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);
|
||||
for (i = pindex - sb->p; 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, 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);
|
||||
|
@ -2314,7 +2309,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.
|
||||
*/
|
||||
MPASS(0);
|
||||
__unreachable();
|
||||
return (object->size);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue