git: ff4c19bb5427 - main - vm_page: pass page to iter_free

From: Doug Moore <dougm_at_FreeBSD.org>
Date: Mon, 25 Nov 2024 08:05:06 UTC
The branch main has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=ff4c19bb5427ca8e90f7354ff5601b985edf3f9e

commit ff4c19bb5427ca8e90f7354ff5601b985edf3f9e
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2024-11-25 08:03:34 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2024-11-25 08:03:34 +0000

    vm_page: pass page to iter_free
    
    Pass the to-be-freed page to vm_page_iter_free as a parameter, rather
    than computing it from the iterator parameter, to improve performance.
    
    Sort declarations of page_iter functions in vm_page.h.
    
    Reviewed by:    alc
    Differential Revision:  https://reviews.freebsd.org/D47727
---
 sys/vm/vm_kern.c   | 2 +-
 sys/vm/vm_object.c | 2 +-
 sys/vm/vm_page.c   | 8 +++-----
 sys/vm/vm_page.h   | 8 ++++----
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c
index 6343fb66cfa3..a748a6c57d65 100644
--- a/sys/vm/vm_kern.c
+++ b/sys/vm/vm_kern.c
@@ -660,7 +660,7 @@ _kmem_unback(vm_object_t object, vm_offset_t addr, vm_size_t size)
 	    m = vm_page_iter_lookup(&pages, atop(offset))) {
 		vm_page_xbusy_claim(m);
 		vm_page_unwire_noq(m);
-		vm_page_iter_free(&pages);
+		vm_page_iter_free(&pages, m);
 	}
 	VM_OBJECT_WUNLOCK(object);
 
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 21773318cea0..84981d7cc7cd 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -2060,7 +2060,7 @@ wired:
 		if ((options & OBJPR_NOTMAPPED) == 0 &&
 		    object->ref_count != 0 && !vm_page_try_remove_all(p))
 			goto wired;
-		vm_page_iter_free(&pages);
+		vm_page_iter_free(&pages, p);
 	}
 	vm_object_pip_wakeup(object);
 
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index f82ca5e16c98..a37619c7743e 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -1713,14 +1713,12 @@ vm_page_free_object_prep(vm_page_t m)
 /*
  *	vm_page_iter_free:
  *
- *	Free the current page, as identified by iterator.
+ *	Free the given page, and use the iterator to remove it from the radix
+ *	tree.
  */
 void
-vm_page_iter_free(struct pctrie_iter *pages)
+vm_page_iter_free(struct pctrie_iter *pages, vm_page_t m)
 {
-	vm_page_t m;
-
-	m = vm_radix_iter_page(pages);
 	vm_radix_iter_remove(pages);
 	vm_page_free_object_prep(m);
 	vm_page_xunbusy(m);
diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
index 613896e77dd9..f641942efb87 100644
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -602,7 +602,6 @@ bool vm_page_busy_sleep(vm_page_t m, const char *msg, int allocflags);
 void vm_page_busy_sleep_unlocked(vm_object_t obj, vm_page_t m,
     vm_pindex_t pindex, const char *wmesg, int allocflags);
 void vm_page_free(vm_page_t m);
-void vm_page_iter_free(struct pctrie_iter *);
 void vm_page_free_zero(vm_page_t m);
 
 void vm_page_activate (vm_page_t);
@@ -651,11 +650,13 @@ void vm_page_init_marker(vm_page_t marker, int queue, uint16_t aflags);
 void vm_page_init_page(vm_page_t m, vm_paddr_t pa, int segind, int pool);
 int vm_page_insert (vm_page_t, vm_object_t, vm_pindex_t);
 void vm_page_invalid(vm_page_t m);
-void vm_page_launder(vm_page_t m);
-vm_page_t vm_page_lookup(vm_object_t, vm_pindex_t);
+void vm_page_iter_free(struct pctrie_iter *pages, vm_page_t m);
 void vm_page_iter_init(struct pctrie_iter *, vm_object_t);
 void vm_page_iter_limit_init(struct pctrie_iter *, vm_object_t, vm_pindex_t);
 vm_page_t vm_page_iter_lookup(struct pctrie_iter *, vm_pindex_t);
+bool vm_page_iter_remove(struct pctrie_iter *pages);
+void vm_page_launder(vm_page_t m);
+vm_page_t vm_page_lookup(vm_object_t, vm_pindex_t);
 vm_page_t vm_page_lookup_unlocked(vm_object_t, vm_pindex_t);
 vm_page_t vm_page_next(vm_page_t m);
 void vm_page_pqbatch_drain(void);
@@ -680,7 +681,6 @@ void vm_page_release(vm_page_t m, int flags);
 void vm_page_release_locked(vm_page_t m, int flags);
 vm_page_t vm_page_relookup(vm_object_t, vm_pindex_t);
 bool vm_page_remove(vm_page_t);
-bool vm_page_iter_remove(struct pctrie_iter *);
 bool vm_page_remove_xbusy(vm_page_t);
 int vm_page_rename(struct pctrie_iter *, vm_object_t, vm_pindex_t);
 void vm_page_replace(vm_page_t mnew, vm_object_t object,