Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/uvm add the KASSERT() for loan_count wrap-around to all ...



details:   https://anonhg.NetBSD.org/src/rev/e55d12895866
branches:  trunk
changeset: 319317:e55d12895866
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri May 25 20:11:03 2018 +0000

description:
add the KASSERT() for loan_count wrap-around to all places which increase it

diffstat:

 sys/uvm/uvm_loan.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (50 lines):

diff -r edd59aff581c -r e55d12895866 sys/uvm/uvm_loan.c
--- a/sys/uvm/uvm_loan.c        Fri May 25 19:56:47 2018 +0000
+++ b/sys/uvm/uvm_loan.c        Fri May 25 20:11:03 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_loan.c,v 1.86 2018/05/19 11:02:33 jdolecek Exp $   */
+/*     $NetBSD: uvm_loan.c,v 1.87 2018/05/25 20:11:03 jdolecek Exp $   */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.86 2018/05/19 11:02:33 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.87 2018/05/25 20:11:03 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -475,6 +475,7 @@
                        pmap_page_protect(pg, VM_PROT_READ);
                }
                pg->loan_count++;
+               KASSERT(pg->loan_count > 0);    /* detect wrap-around */
                uvm_pageactivate(pg);
                mutex_exit(&uvm_pageqlock);
        }
@@ -788,6 +789,7 @@
                pmap_page_protect(pg, VM_PROT_READ);
        }
        pg->loan_count++;
+       KASSERT(pg->loan_count > 0);    /* detect wrap-around */
        pg->uanon = anon;
        anon->an_page = pg;
        anon->an_lock = /* TODO: share amap lock */
@@ -879,6 +881,7 @@
        if ((flags & UVM_LOAN_TOANON) == 0) {   /* loaning to kernel-page */
                mutex_enter(&uvm_pageqlock);
                pg->loan_count++;
+               KASSERT(pg->loan_count > 0);    /* detect wrap-around */
                mutex_exit(&uvm_pageqlock);
                mutex_exit(uvm_loanzero_object.vmobjlock);
                **output = pg;
@@ -919,6 +922,7 @@
        pg->uanon = anon;
        mutex_enter(&uvm_pageqlock);
        pg->loan_count++;
+       KASSERT(pg->loan_count > 0);    /* detect wrap-around */
        uvm_pageactivate(pg);
        mutex_exit(&uvm_pageqlock);
        mutex_exit(&anon->an_lock);



Home | Main Index | Thread Index | Old Index