Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm introduce UVMHIST_LOANHIST and sprinkle UVMHIST_LOGs.



details:   https://anonhg.NetBSD.org/src/rev/1d3ca058d61d
branches:  trunk
changeset: 571416:1d3ca058d61d
user:      yamt <yamt%NetBSD.org@localhost>
date:      Tue Nov 23 04:51:56 2004 +0000

description:
introduce UVMHIST_LOANHIST and sprinkle UVMHIST_LOGs.

diffstat:

 sys/uvm/uvm.h      |   3 ++-
 sys/uvm/uvm_loan.c |  38 ++++++++++++++++++++++++++++++++++----
 sys/uvm/uvm_stat.c |   7 +++++--
 sys/uvm/uvm_stat.h |   3 ++-
 4 files changed, 43 insertions(+), 8 deletions(-)

diffs (258 lines):

diff -r df480a0b0e5a -r 1d3ca058d61d sys/uvm/uvm.h
--- a/sys/uvm/uvm.h     Tue Nov 23 04:38:19 2004 +0000
+++ b/sys/uvm/uvm.h     Tue Nov 23 04:51:56 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm.h,v 1.37 2004/02/10 01:30:49 matt Exp $    */
+/*     $NetBSD: uvm.h,v 1.38 2004/11/23 04:51:56 yamt Exp $    */
 
 /*
  *
@@ -155,6 +155,7 @@
 UVMHIST_DECL(maphist);
 UVMHIST_DECL(pdhist);
 UVMHIST_DECL(ubchist);
+UVMHIST_DECL(loanhist);
 #endif
 
 /*
diff -r df480a0b0e5a -r 1d3ca058d61d sys/uvm/uvm_loan.c
--- a/sys/uvm/uvm_loan.c        Tue Nov 23 04:38:19 2004 +0000
+++ b/sys/uvm/uvm_loan.c        Tue Nov 23 04:51:56 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_loan.c,v 1.51 2004/11/21 06:45:49 yamt Exp $       */
+/*     $NetBSD: uvm_loan.c,v 1.52 2004/11/23 04:51:56 yamt Exp $       */
 
 /*
  *
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.51 2004/11/21 06:45:49 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.52 2004/11/23 04:51:56 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -149,6 +149,8 @@
        struct vm_anon *anon;
        int rv, result = 0;
 
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(loanhist);
+
        /*
         * lock us the rest of the way down (we unlock before return)
         */
@@ -190,12 +192,17 @@
                    !simple_lock_held(&uobj->vmobjlock));
 
                /* total failure */
-               if (rv < 0)
+               if (rv < 0) {
+                       UVMHIST_LOG(loanhist, "failure %d", rv, 0,0,0);
                        return (-1);
+               }
 
                /* relock failed, need to do another lookup */
-               if (rv == 0)
+               if (rv == 0) {
+                       UVMHIST_LOG(loanhist, "relock failure %d", result
+                           ,0,0,0);
                        return (result);
+               }
 
                /*
                 * got it... advance to next page
@@ -215,6 +222,7 @@
        if (uobj)
                simple_unlock(&uobj->vmobjlock);
        uvmfault_unlockmaps(ufi, FALSE);
+       UVMHIST_LOG(loanhist, "done %d", result, 0,0,0);
        return (result);
 }
 
@@ -246,6 +254,8 @@
        void **result, **output;
        int rv, error;
 
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(loanhist);
+
        /*
         * ensure that one and only one of the flags is set
         */
@@ -310,6 +320,7 @@
                        start += rv;
                }
        }
+       UVMHIST_LOG(loanhist, "success", 0,0,0,0);
        return 0;
 
 fail:
@@ -327,6 +338,7 @@
                            output - result);
                }
        }
+       UVMHIST_LOG(loanhist, "error %d", error,0,0,0);
        return (error);
 }
 
@@ -351,6 +363,8 @@
        struct vm_page *pg;
        int error;
 
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(loanhist);
+
        /*
         * if we are loaning to "another" anon then it is easy, we just
         * bump the reference count on the current anon and return a
@@ -362,6 +376,7 @@
                pg = anon->u.an_page;
                if (pg && (pg->pqflags & PQ_ANON) != 0 && anon->an_ref == 1) {
                        if (pg->wire_count > 0) {
+                               UVMHIST_LOG(loanhist, "->A wired %p", pg,0,0,0);
                                uvmfault_unlockall(ufi,
                                    ufi->entry->aref.ar_amap,
                                    ufi->entry->object.uvm_obj, anon);
@@ -373,6 +388,7 @@
                **output = anon;
                (*output)++;
                simple_unlock(&anon->an_lock);
+               UVMHIST_LOG(loanhist, "->A done", 0,0,0,0);
                return (1);
        }
 
@@ -391,6 +407,7 @@
         */
 
        if (error) {
+               UVMHIST_LOG(loanhist, "error %d", error,0,0,0);
 
                /* need to refault (i.e. refresh our lookup) ? */
                if (error == ERESTART) {
@@ -415,6 +432,7 @@
        uvm_lock_pageq();
        if (pg->wire_count > 0) {
                uvm_unlock_pageq();
+               UVMHIST_LOG(loanhist, "->K wired %p", pg,0,0,0);
                KASSERT(pg->uobject == NULL);
                uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap,
                    ufi->entry->object.uvm_obj, anon);
@@ -433,6 +451,7 @@
        if (pg->uobject)        /* XXXCDC: what if this is our uobj? bad */
                simple_unlock(&pg->uobject->vmobjlock);
        simple_unlock(&anon->an_lock);
+       UVMHIST_LOG(loanhist, "->K done", 0,0,0,0);
        return (1);
 }
 
@@ -453,6 +472,8 @@
        int i;
        int error = 0;
 
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(loanhist);
+
        for (i = 0; i < npages; i++) {
                struct vm_page *pg = pgpp[i];
 
@@ -465,6 +486,7 @@
                uvm_lock_pageq();
                if (pg->wire_count > 0) {
                        uvm_unlock_pageq();
+                       UVMHIST_LOG(loanhist, "wired %p", pg,0,0,0);
                        error = EBUSY;
                        break;
                }
@@ -489,6 +511,7 @@
                simple_lock(slock);
        }
 
+       UVMHIST_LOG(loanhist, "done %d", error,0,0,0);
        return error;
 }
 
@@ -629,6 +652,8 @@
        int error, npages;
        boolean_t locked;
 
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(loanhist);
+
        /*
         * first we must make sure the page is resident.
         *
@@ -775,6 +800,7 @@
        uvm_lock_pageq();
        if (pg->wire_count > 0) {
                uvm_unlock_pageq();
+               UVMHIST_LOG(loanhist, "wired %p", pg,0,0,0);
                pg->uanon = NULL;
                anon->u.an_page = NULL;
                anon->an_ref--;
@@ -799,6 +825,7 @@
        return (1);
 
 fail:
+       UVMHIST_LOG(loanhist, "fail", 0,0,0,0);
        /*
         * unlock everything and bail out.
         */
@@ -835,6 +862,7 @@
        struct uvm_object *uobj = ufi->entry->object.uvm_obj;
        struct vm_amap *amap = ufi->entry->aref.ar_amap;
 
+       UVMHIST_FUNC(__func__); UVMHIST_CALLED(loanhist);
 again:
        simple_lock(&uvm_loanzero_object.vmobjlock);
 
@@ -1102,6 +1130,8 @@
        simple_lock_init(&uvm_loanzero_object.vmobjlock);
        TAILQ_INIT(&uvm_loanzero_object.memq);
        uvm_loanzero_object.pgops = &ulz_pager;
+
+       UVMHIST_INIT(loanhist, 300);
 }
 
 /*
diff -r df480a0b0e5a -r 1d3ca058d61d sys/uvm/uvm_stat.c
--- a/sys/uvm/uvm_stat.c        Tue Nov 23 04:38:19 2004 +0000
+++ b/sys/uvm/uvm_stat.c        Tue Nov 23 04:51:56 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_stat.c,v 1.24 2004/05/01 19:40:39 petrov Exp $      */
+/*     $NetBSD: uvm_stat.c,v 1.25 2004/11/23 04:51:56 yamt Exp $        */
 
 /*
  *
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v 1.24 2004/05/01 19:40:39 petrov Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_stat.c,v 1.25 2004/11/23 04:51:56 yamt Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_ddb.h"
@@ -184,6 +184,9 @@
        if ((bitmask & UVMHIST_UBCHIST) || bitmask == 0)
                hists[i++] = &ubchist;
 
+       if ((bitmask & UVMHIST_LOANHIST) || bitmask == 0)
+               hists[i++] = &loanhist;
+
        hists[i] = NULL;
 
        uvmhist_dump_histories(hists);
diff -r df480a0b0e5a -r 1d3ca058d61d sys/uvm/uvm_stat.h
--- a/sys/uvm/uvm_stat.h        Tue Nov 23 04:38:19 2004 +0000
+++ b/sys/uvm/uvm_stat.h        Tue Nov 23 04:51:56 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_stat.h,v 1.32 2004/05/01 19:40:39 petrov Exp $     */
+/*     $NetBSD: uvm_stat.h,v 1.33 2004/11/23 04:51:56 yamt Exp $       */
 
 /*
  *
@@ -88,6 +88,7 @@
 #define        UVMHIST_MAPHIST         0x00000001      /* maphist */
 #define        UVMHIST_PDHIST          0x00000002      /* pdhist */
 #define        UVMHIST_UBCHIST         0x00000004      /* ubchist */
+#define        UVMHIST_LOANHIST        0x00000008      /* loanhist */
 
 #ifdef _KERNEL
 



Home | Main Index | Thread Index | Old Index