git: d537d1f12e88 - main - vm_pager: add methods for page insertion and removal notifications
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 09 Dec 2022 12:17:37 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d537d1f12e8829faccd395115193b03b578f1176 commit d537d1f12e8829faccd395115193b03b578f1176 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-10-20 12:55:38 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-12-09 12:15:37 +0000 vm_pager: add methods for page insertion and removal notifications Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37097 --- sys/vm/vm_page.c | 4 ++++ sys/vm/vm_pager.c | 2 ++ sys/vm/vm_pager.h | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 4f97b84ee205..20238e0ad807 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1483,6 +1483,7 @@ vm_page_insert_after(vm_page_t m, vm_object_t object, vm_pindex_t pindex, return (1); } vm_page_insert_radixdone(m, object, mpred); + vm_pager_page_inserted(object, m); return (0); } @@ -1557,6 +1558,8 @@ vm_page_object_remove(vm_page_t m) if ((m->a.flags & PGA_SWAP_FREE) != 0) vm_pager_page_unswapped(m); + vm_pager_page_removed(object, m); + m->object = NULL; mrem = vm_radix_remove(&object->rtree, m->pindex); KASSERT(mrem == m, ("removed page %p, expected page %p", mrem, m)); @@ -1879,6 +1882,7 @@ vm_page_rename(vm_page_t m, vm_object_t new_object, vm_pindex_t new_pindex) vm_page_insert_radixdone(m, new_object, mpred); vm_page_dirty(m); + vm_pager_page_inserted(new_object, m); return (0); } diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index cc0be174987d..36ce380dedbc 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -430,6 +430,8 @@ vm_pager_alloc_dyn_type(struct pagerops *ops, int base_type) FIX(mightbedirty); FIX(getvp); FIX(freespace); + FIX(page_inserted); + FIX(page_removed); #undef FIX } pagertab[res] = ops; /* XXXKIB should be rel, but acq is too much */ diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h index e332231a77c6..5917bf651760 100644 --- a/sys/vm/vm_pager.h +++ b/sys/vm/vm_pager.h @@ -69,6 +69,8 @@ typedef void pgo_getvp_t(vm_object_t object, struct vnode **vpp, bool *vp_heldp); typedef void pgo_freespace_t(vm_object_t object, vm_pindex_t start, vm_size_t size); +typedef void pgo_page_inserted_t(vm_object_t object, vm_page_t m); +typedef void pgo_page_removed_t(vm_object_t object, vm_page_t m); struct pagerops { int pgo_kvme_type; @@ -87,6 +89,8 @@ struct pagerops { pgo_mightbedirty_t *pgo_mightbedirty; pgo_getvp_t *pgo_getvp; pgo_freespace_t *pgo_freespace; + pgo_page_inserted_t *pgo_page_inserted; + pgo_page_removed_t *pgo_page_removed; }; extern const struct pagerops defaultpagerops; @@ -249,6 +253,26 @@ vm_pager_freespace(vm_object_t object, vm_pindex_t start, method(object, start, size); } +static __inline void +vm_pager_page_inserted(vm_object_t object, vm_page_t m) +{ + pgo_page_inserted_t *method; + + method = pagertab[object->type]->pgo_page_inserted; + if (method != NULL) + method(object, m); +} + +static __inline void +vm_pager_page_removed(vm_object_t object, vm_page_t m) +{ + pgo_page_removed_t *method; + + method = pagertab[object->type]->pgo_page_removed; + if (method != NULL) + method(object, m); +} + int vm_pager_alloc_dyn_type(struct pagerops *ops, int base_type); void vm_pager_free_dyn_type(objtype_t type);