Do not clear the PG_BUSY flag before passing the anon to uvm_anon_release().
authormpi <mpi@openbsd.org>
Thu, 10 Mar 2022 10:46:56 +0000 (10:46 +0000)
committermpi <mpi@openbsd.org>
Thu, 10 Mar 2022 10:46:56 +0000 (10:46 +0000)
Should prevent a KASSERT() from tiggering when freeing an anon after swaping-out
its memory.

This code path has been broken since at least January 2021 and is apparently not
so easy to trigger.

Found the hard way by sthen@

ok kettenis@, kn@

sys/uvm/uvm_page.c

index df40cd9..57b7a52 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uvm_page.c,v 1.161 2022/01/19 02:08:24 mpi Exp $      */
+/*     $OpenBSD: uvm_page.c,v 1.162 2022/03/10 10:46:56 mpi Exp $      */
 /*     $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $        */
 
 /*
@@ -1086,8 +1086,6 @@ uvm_page_unbusy(struct vm_page **pgs, int npgs)
                                uvm_pagefree(pg);
                                uvm_unlock_pageq();
                        } else {
-                               atomic_clearbits_int(&pg->pg_flags, PG_BUSY);
-                               UVM_PAGE_OWN(pg, NULL);
                                rw_enter(pg->uanon->an_lock, RW_WRITE);
                                uvm_anon_release(pg->uanon);
                        }