git: 76c60597fa2a - main - swap_pager: use vm_page_iterators for lookup
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 28 Sep 2024 21:47:46 UTC
The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=76c60597fa2af9ec5b5a24305794b70ad1530755 commit 76c60597fa2af9ec5b5a24305794b70ad1530755 Author: Doug Moore <dougm@FreeBSD.org> AuthorDate: 2024-09-28 21:46:40 +0000 Commit: Doug Moore <dougm@FreeBSD.org> CommitDate: 2024-09-28 21:46:40 +0000 swap_pager: use vm_page_iterators for lookup Replace the use of page lookups and page next pointers in swap_pager.c with vm_page iterators. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D46704 --- sys/vm/swap_pager.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index aa0297daefe9..fbf2967aaf17 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -1856,6 +1856,7 @@ swap_pager_swapped_pages(vm_object_t object) static void swap_pager_swapoff_object(struct swdevt *sp, vm_object_t object) { + struct pctrie_iter pages; struct page_range range; struct swblk *sb; vm_page_t m; @@ -1870,6 +1871,7 @@ swap_pager_swapoff_object(struct swdevt *sp, vm_object_t object) pi = 0; i = 0; + vm_page_iter_init(&pages, object); swp_pager_init_freerange(&range); for (;;) { if (i == 0 && (object->flags & OBJ_DEAD) != 0) { @@ -1896,7 +1898,6 @@ swap_pager_swapoff_object(struct swdevt *sp, vm_object_t object) if (sb == NULL) break; sb_empty = true; - m = NULL; } /* Skip an invalid block. */ @@ -1904,7 +1905,6 @@ swap_pager_swapoff_object(struct swdevt *sp, vm_object_t object) if (blk == SWAPBLK_NONE || !swp_pager_isondev(blk, sp)) { if (blk != SWAPBLK_NONE) sb_empty = false; - m = NULL; i++; continue; } @@ -1913,8 +1913,7 @@ swap_pager_swapoff_object(struct swdevt *sp, vm_object_t object) * Look for a page corresponding to this block, If the found * page has pending operations, sleep and restart the scan. */ - m = m != NULL ? vm_page_next(m) : - vm_page_lookup(object, sb->p + i); + m = vm_page_iter_lookup(&pages, sb->p + i); if (m != NULL && (m->oflags & VPO_SWAPINPROG) != 0) { m->oflags |= VPO_SWAPSLEEP; VM_OBJECT_SLEEP(object, &object->handle, PSWP, "swpoff", @@ -2272,6 +2271,7 @@ static void swp_pager_meta_free(vm_object_t object, vm_pindex_t pindex, vm_pindex_t count, vm_size_t *freed) { + struct pctrie_iter pages; struct page_range range; struct swblk *sb; vm_page_t m; @@ -2282,11 +2282,11 @@ swp_pager_meta_free(vm_object_t object, vm_pindex_t pindex, vm_pindex_t count, VM_OBJECT_ASSERT_WLOCKED(object); fc = 0; - m = NULL; if (count == 0 || swblk_is_empty(object)) goto out; swp_pager_init_freerange(&range); + vm_page_iter_init(&pages, object); last = pindex + count; sb = swblk_start_limit(object, pindex, last); start = (sb != NULL && sb->p < pindex) ? pindex - sb->p : 0; @@ -2298,9 +2298,7 @@ swp_pager_meta_free(vm_object_t object, vm_pindex_t pindex, vm_pindex_t count, continue; swp_pager_update_freerange(&range, sb->d[i]); if (freed != NULL) { - m = (m != NULL && m->pindex == sb->p + i - 1) ? - vm_page_next(m) : - vm_page_lookup(object, sb->p + i); + m = vm_page_iter_lookup(&pages, sb->p + i); if (m == NULL || vm_page_none_valid(m)) fc++; }