Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm ERESTART is already negative. Give up negating erro...



details:   https://anonhg.NetBSD.org/src/rev/48a943dc5e5e
branches:  trunk
changeset: 751338:48a943dc5e5e
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Mon Feb 01 05:48:19 2010 +0000

description:
ERESTART is already negative.  Give up negating error values to not override
the original values.  Pointed out by rmind@, thanks.

In the lower fault case, if (*pgo_get)() can return ERESTART and we should
re-fault for that remains a question.  The original code just returned the
error, so keep that behaviour for now.  In case (*pgo_get)() really returns
ERESTART, pass EIO to tell the uvm_fault caller that (*pgo_get)() failed.

(As far as I grep callers don't check if the return value is ERESTART or not.
So assuming (*pgo_get)() never returns ERESTART should be a safe bet.)

diffstat:

 sys/uvm/uvm_fault.c |  44 +++++++++++++++++++++++++-------------------
 1 files changed, 25 insertions(+), 19 deletions(-)

diffs (158 lines):

diff -r 5adc79f39809 -r 48a943dc5e5e sys/uvm/uvm_fault.c
--- a/sys/uvm/uvm_fault.c       Mon Feb 01 05:38:36 2010 +0000
+++ b/sys/uvm/uvm_fault.c       Mon Feb 01 05:48:19 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_fault.c,v 1.138 2010/01/31 17:13:38 uebayasi Exp $ */
+/*     $NetBSD: uvm_fault.c,v 1.139 2010/02/01 05:48:19 uebayasi Exp $ */
 
 /*
  *
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.138 2010/01/31 17:13:38 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.139 2010/02/01 05:48:19 uebayasi Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -780,7 +780,7 @@
                        amap, uobj, anons_store, anons, &anon_spare,
                        pages, uobjpage);
 
-       if (error == -ERESTART)
+       if (error == ERESTART)
                goto ReFault;
 
 done:
@@ -1144,7 +1144,7 @@
                /* locked: nothing, pgo_fault has unlocked everything */
 
                if (error == ERESTART)
-                       error = -ERESTART;              /* try again! */
+                       error = ERESTART;               /* try again! */
                /*
                 * object fault routine responsible for pmap_update().
                 */
@@ -1399,11 +1399,11 @@
                break;
 
        case ERESTART:
-               return -ERESTART;
+               return ERESTART;
 
        case EAGAIN:
                kpause("fltagain1", false, hz/2, NULL);
-               return -ERESTART;
+               return ERESTART;
 
        default:
                return error;
@@ -1459,7 +1459,7 @@
                                        uvmfault_unlockall(ufi, amap, uobj,
                                            anon);
                                        uvm_wait("flt_noram2");
-                                       return -ERESTART;
+                                       return ERESTART;
                                }
 
                                /*
@@ -1535,7 +1535,7 @@
                case 0:
                        break;
                case ERESTART:
-                       return -ERESTART;
+                       return ERESTART;
                default:
                        return error;
                }
@@ -1601,7 +1601,7 @@
                }
                /* XXX instrumentation */
                uvm_wait("flt_pmfail1");
-               return -ERESTART;
+               return ERESTART;
        }
 
        /*
@@ -1634,8 +1634,7 @@
                mutex_exit(&anon->an_lock);
        uvmfault_unlockall(ufi, amap, uobj, oanon);
        pmap_update(ufi->orig_map->pmap);
-       error = 0;
-       return error;
+       return 0;
 }
 
 static int
@@ -1723,9 +1722,17 @@
                                UVMHIST_LOG(maphist,
                                    "  pgo_get says TRY AGAIN!",0,0,0,0);
                                kpause("fltagain2", false, hz/2, NULL);
-                               return -ERESTART;
+                               return ERESTART;
                        }
 
+#if 0
+                       KASSERT(error != ERESTART);
+#else
+                       /* XXXUEBS don't re-fault? */
+                       if (error == ERESTART)
+                               error = EIO;
+#endif
+
                        UVMHIST_LOG(maphist, "<- pgo_get failed (code %d)",
                            error, 0,0,0);
                        return error;
@@ -1779,12 +1786,12 @@
                        if (uobjpage->flags & PG_RELEASED) {
                                uvmexp.fltpgrele++;
                                uvm_pagefree(uobjpage);
-                               return -ERESTART;
+                               return ERESTART;
                        }
                        uobjpage->flags &= ~(PG_BUSY|PG_WANTED);
                        UVM_PAGE_OWN(uobjpage, NULL);
                        mutex_exit(&uobj->vmobjlock);
-                       return -ERESTART;
+                       return ERESTART;
                }
 
                /*
@@ -1871,7 +1878,7 @@
                                          0,0,0,0);
                                        uvmexp.fltnoram++;
                                        uvm_wait("flt_noram4");
-                                       return -ERESTART;
+                                       return ERESTART;
                                }
                                uobjpage = pg;
                        }
@@ -1892,7 +1899,7 @@
                case 0:
                        break;
                case ERESTART:
-                       return -ERESTART;
+                       return ERESTART;
                default:
                        return error;
                }
@@ -2005,7 +2012,7 @@
                }
                /* XXX instrumentation */
                uvm_wait("flt_pmfail2");
-               return -ERESTART;
+               return ERESTART;
        }
 
        mutex_enter(&uvm_pageqlock);
@@ -2042,8 +2049,7 @@
        uvmfault_unlockall(ufi, amap, uobj, anon);
        pmap_update(ufi->orig_map->pmap);
        UVMHIST_LOG(maphist, "<- done (SUCCESS!)",0,0,0,0);
-       error = 0;
-       return error;
+       return 0;
 }
 
 



Home | Main Index | Thread Index | Old Index