-/* $OpenBSD: uvm_page.c,v 1.165 2022/05/04 14:58:26 mpi Exp $ */
+/* $OpenBSD: uvm_page.c,v 1.166 2022/05/12 12:48:36 mpi Exp $ */
/* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */
/*
/*
* now remove the page from the queues
*/
- if (pg->pg_flags & PQ_ACTIVE) {
- TAILQ_REMOVE(&uvm.page_active, pg, pageq);
- flags_to_clear |= PQ_ACTIVE;
- uvmexp.active--;
- }
- if (pg->pg_flags & PQ_INACTIVE) {
- TAILQ_REMOVE(&uvm.page_inactive, pg, pageq);
- flags_to_clear |= PQ_INACTIVE;
- uvmexp.inactive--;
- }
+ uvm_pagedequeue(pg);
/*
* if the page was wired, unwire it now.
MUTEX_ASSERT_LOCKED(&uvm.pageqlock);
if (pg->wire_count == 0) {
- if (pg->pg_flags & PQ_ACTIVE) {
- TAILQ_REMOVE(&uvm.page_active, pg, pageq);
- atomic_clearbits_int(&pg->pg_flags, PQ_ACTIVE);
- uvmexp.active--;
- }
- if (pg->pg_flags & PQ_INACTIVE) {
- TAILQ_REMOVE(&uvm.page_inactive, pg, pageq);
- atomic_clearbits_int(&pg->pg_flags, PQ_INACTIVE);
- uvmexp.inactive--;
- }
+ uvm_pagedequeue(pg);
uvmexp.wired++;
}
pg->wire_count++;
KASSERT(uvm_page_owner_locked_p(pg));
MUTEX_ASSERT_LOCKED(&uvm.pageqlock);
+ uvm_pagedequeue(pg);
+ if (pg->wire_count == 0) {
+ TAILQ_INSERT_TAIL(&uvm.page_active, pg, pageq);
+ atomic_setbits_int(&pg->pg_flags, PQ_ACTIVE);
+ uvmexp.active++;
+
+ }
+}
+
+/*
+ * uvm_pagedequeue: remove a page from any paging queue
+ */
+void
+uvm_pagedequeue(struct vm_page *pg)
+{
+ if (pg->pg_flags & PQ_ACTIVE) {
+ TAILQ_REMOVE(&uvm.page_active, pg, pageq);
+ atomic_clearbits_int(&pg->pg_flags, PQ_ACTIVE);
+ uvmexp.active--;
+ }
if (pg->pg_flags & PQ_INACTIVE) {
TAILQ_REMOVE(&uvm.page_inactive, pg, pageq);
atomic_clearbits_int(&pg->pg_flags, PQ_INACTIVE);
uvmexp.inactive--;
}
- if (pg->wire_count == 0) {
- /*
- * if page is already active, remove it from list so we
- * can put it at tail. if it wasn't active, then mark
- * it active and bump active count
- */
- if (pg->pg_flags & PQ_ACTIVE)
- TAILQ_REMOVE(&uvm.page_active, pg, pageq);
- else {
- atomic_setbits_int(&pg->pg_flags, PQ_ACTIVE);
- uvmexp.active++;
- }
-
- TAILQ_INSERT_TAIL(&uvm.page_active, pg, pageq);
- }
}
-
/*
* uvm_pagezero: zero fill a page
*/
-/* $OpenBSD: uvm_page.h,v 1.67 2022/01/29 06:25:33 aoyama Exp $ */
+/* $OpenBSD: uvm_page.h,v 1.68 2022/05/12 12:48:36 mpi Exp $ */
/* $NetBSD: uvm_page.h,v 1.19 2000/12/28 08:24:55 chs Exp $ */
/*
#endif
void uvm_pageactivate(struct vm_page *);
+void uvm_pagedequeue(struct vm_page *);
vaddr_t uvm_pageboot_alloc(vsize_t);
void uvm_pagecopy(struct vm_page *, struct vm_page *);
void uvm_pagedeactivate(struct vm_page *);