-/* $OpenBSD: uvm_aobj.c,v 1.96 2021/05/20 08:03:35 mpi Exp $ */
+/* $OpenBSD: uvm_aobj.c,v 1.97 2021/06/15 16:38:09 mpi Exp $ */
/* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */
/*
static struct uao_swhash_elt *uao_find_swhash_elt(struct uvm_aobj *, int,
boolean_t);
-static int uao_find_swslot(struct uvm_aobj *, int);
+static int uao_find_swslot(struct uvm_object *, int);
static boolean_t uao_flush(struct uvm_object *, voff_t,
voff_t, int);
static void uao_free(struct uvm_aobj *);
* uao_find_swslot: find the swap slot number for an aobj/pageidx
*/
inline static int
-uao_find_swslot(struct uvm_aobj *aobj, int pageidx)
+uao_find_swslot(struct uvm_object *uobj, int pageidx)
{
+ struct uvm_aobj *aobj = (struct uvm_aobj *)uobj;
+
+ KASSERT(UVM_OBJ_IS_AOBJ(uobj));
/*
* if noswap flag is set, then we never return a slot
int oldslot;
KERNEL_ASSERT_LOCKED();
+ KASSERT(UVM_OBJ_IS_AOBJ(uobj));
/*
* if noswap flag is set, then we can't set a slot
{
struct uvm_object *uobj = &aobj->u_obj;
+ KASSERT(UVM_OBJ_IS_AOBJ(uobj));
uao_dropswap_range(uobj, 0, 0);
if (UAO_USES_SWHASH(aobj)) {
struct vm_page *pp;
voff_t curoff;
+ KASSERT(UVM_OBJ_IS_AOBJ(uobj));
KERNEL_ASSERT_LOCKED();
if (flags & PGO_ALLPAGES) {
int lcv, gotpages, maxpages, swslot, rv, pageidx;
boolean_t done;
+ KASSERT(UVM_OBJ_IS_AOBJ(uobj));
KERNEL_ASSERT_LOCKED();
/*
* if page is new, attempt to allocate the page,
* zero-fill'd.
*/
- if (ptmp == NULL && uao_find_swslot(aobj,
+ if (ptmp == NULL && uao_find_swslot(uobj,
current_offset >> PAGE_SHIFT) == 0) {
ptmp = uvm_pagealloc(uobj, current_offset,
NULL, UVM_PGA_ZERO);
* we have a "fake/busy/clean" page that we just allocated.
* do the needed "i/o", either reading from swap or zeroing.
*/
- swslot = uao_find_swslot(aobj, pageidx);
+ swslot = uao_find_swslot(uobj, pageidx);
/* just zero the page if there's nothing in swap. */
if (swslot == 0) {
{
int slot;
+ KASSERT(UVM_OBJ_IS_AOBJ(uobj));
+
slot = uao_set_swslot(uobj, pageidx, 0);
if (slot) {
uvm_swap_free(slot, 1);
struct uvm_aobj *aobj = (struct uvm_aobj *)uobj;
int swpgonlydelta = 0;
+ KASSERT(UVM_OBJ_IS_AOBJ(uobj));
/* KASSERT(mutex_owned(uobj->vmobjlock)); */
if (end == 0) {
-/* $OpenBSD: uvm_object.h,v 1.24 2020/10/21 09:08:14 mpi Exp $ */
+/* $OpenBSD: uvm_object.h,v 1.25 2021/06/15 16:38:09 mpi Exp $ */
/* $NetBSD: uvm_object.h,v 1.11 2001/03/09 01:02:12 chs Exp $ */
/*
#define UVM_OBJ_IS_VNODE(uobj) \
((uobj)->pgops == &uvm_vnodeops)
-#define UVM_OBJ_IS_DEVICE(uobj) \
+#define UVM_OBJ_IS_DEVICE(uobj) \
((uobj)->pgops == &uvm_deviceops)
#define UVM_OBJ_IS_VTEXT(uobj) \
((uobj)->pgops == &uvm_vnodeops && \
((struct vnode *)uobj)->v_flag & VTEXT)
+#define UVM_OBJ_IS_AOBJ(uobj) \
+ ((uobj)->pgops == &aobj_pager)
+
void uvm_objinit(struct uvm_object *, const struct uvm_pagerops *, int);
int uvm_objwire(struct uvm_object *, voff_t, voff_t, struct pglist *);
void uvm_objunwire(struct uvm_object *, voff_t, voff_t);