aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2022-10-20 12:55:38 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2022-12-09 12:15:37 +0000
commitd537d1f12e8829faccd395115193b03b578f1176 (patch)
tree5e82af530f6a6d65a3d0e47a7678fe01b7c33931
parentd9dc64f1589360f2062ad92d63f69e13121e472a (diff)
downloadsrc-d537d1f12e8829faccd395115193b03b578f1176.tar.gz
src-d537d1f12e8829faccd395115193b03b578f1176.zip
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
-rw-r--r--sys/vm/vm_page.c4
-rw-r--r--sys/vm/vm_pager.c2
-rw-r--r--sys/vm/vm_pager.h24
3 files changed, 30 insertions, 0 deletions
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);