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.)
This commit is contained in:
uebayasi 2010-02-01 05:48:19 +00:00
parent bb5dfe40ba
commit 62e5fa15ec

View File

@ -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> #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" #include "opt_uvmhist.h"
@ -780,7 +780,7 @@ uvm_fault_upper_lookup_done:
amap, uobj, anons_store, anons, &anon_spare, amap, uobj, anons_store, anons, &anon_spare,
pages, uobjpage); pages, uobjpage);
if (error == -ERESTART) if (error == ERESTART)
goto ReFault; goto ReFault;
done: done:
@ -1144,7 +1144,7 @@ uvm_fault_lower_special(
/* locked: nothing, pgo_fault has unlocked everything */ /* locked: nothing, pgo_fault has unlocked everything */
if (error == ERESTART) if (error == ERESTART)
error = -ERESTART; /* try again! */ error = ERESTART; /* try again! */
/* /*
* object fault routine responsible for pmap_update(). * object fault routine responsible for pmap_update().
*/ */
@ -1399,11 +1399,11 @@ uvm_fault_upper(
break; break;
case ERESTART: case ERESTART:
return -ERESTART; return ERESTART;
case EAGAIN: case EAGAIN:
kpause("fltagain1", false, hz/2, NULL); kpause("fltagain1", false, hz/2, NULL);
return -ERESTART; return ERESTART;
default: default:
return error; return error;
@ -1459,7 +1459,7 @@ uvm_fault_upper(
uvmfault_unlockall(ufi, amap, uobj, uvmfault_unlockall(ufi, amap, uobj,
anon); anon);
uvm_wait("flt_noram2"); uvm_wait("flt_noram2");
return -ERESTART; return ERESTART;
} }
/* /*
@ -1535,7 +1535,7 @@ uvm_fault_upper(
case 0: case 0:
break; break;
case ERESTART: case ERESTART:
return -ERESTART; return ERESTART;
default: default:
return error; return error;
} }
@ -1601,7 +1601,7 @@ uvm_fault_upper(
} }
/* XXX instrumentation */ /* XXX instrumentation */
uvm_wait("flt_pmfail1"); uvm_wait("flt_pmfail1");
return -ERESTART; return ERESTART;
} }
/* /*
@ -1634,8 +1634,7 @@ uvm_fault_upper(
mutex_exit(&anon->an_lock); mutex_exit(&anon->an_lock);
uvmfault_unlockall(ufi, amap, uobj, oanon); uvmfault_unlockall(ufi, amap, uobj, oanon);
pmap_update(ufi->orig_map->pmap); pmap_update(ufi->orig_map->pmap);
error = 0; return 0;
return error;
} }
static int static int
@ -1723,9 +1722,17 @@ uvm_fault_lower_generic2(
UVMHIST_LOG(maphist, UVMHIST_LOG(maphist,
" pgo_get says TRY AGAIN!",0,0,0,0); " pgo_get says TRY AGAIN!",0,0,0,0);
kpause("fltagain2", false, hz/2, NULL); 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)", UVMHIST_LOG(maphist, "<- pgo_get failed (code %d)",
error, 0,0,0); error, 0,0,0);
return error; return error;
@ -1779,12 +1786,12 @@ uvm_fault_lower_generic2(
if (uobjpage->flags & PG_RELEASED) { if (uobjpage->flags & PG_RELEASED) {
uvmexp.fltpgrele++; uvmexp.fltpgrele++;
uvm_pagefree(uobjpage); uvm_pagefree(uobjpage);
return -ERESTART; return ERESTART;
} }
uobjpage->flags &= ~(PG_BUSY|PG_WANTED); uobjpage->flags &= ~(PG_BUSY|PG_WANTED);
UVM_PAGE_OWN(uobjpage, NULL); UVM_PAGE_OWN(uobjpage, NULL);
mutex_exit(&uobj->vmobjlock); mutex_exit(&uobj->vmobjlock);
return -ERESTART; return ERESTART;
} }
/* /*
@ -1871,7 +1878,7 @@ uvm_fault_lower_generic2(
0,0,0,0); 0,0,0,0);
uvmexp.fltnoram++; uvmexp.fltnoram++;
uvm_wait("flt_noram4"); uvm_wait("flt_noram4");
return -ERESTART; return ERESTART;
} }
uobjpage = pg; uobjpage = pg;
} }
@ -1892,7 +1899,7 @@ uvm_fault_lower_generic2(
case 0: case 0:
break; break;
case ERESTART: case ERESTART:
return -ERESTART; return ERESTART;
default: default:
return error; return error;
} }
@ -2005,7 +2012,7 @@ uvm_fault_lower_generic2(
} }
/* XXX instrumentation */ /* XXX instrumentation */
uvm_wait("flt_pmfail2"); uvm_wait("flt_pmfail2");
return -ERESTART; return ERESTART;
} }
mutex_enter(&uvm_pageqlock); mutex_enter(&uvm_pageqlock);
@ -2042,8 +2049,7 @@ uvm_fault_lower_generic2(
uvmfault_unlockall(ufi, amap, uobj, anon); uvmfault_unlockall(ufi, amap, uobj, anon);
pmap_update(ufi->orig_map->pmap); pmap_update(ufi->orig_map->pmap);
UVMHIST_LOG(maphist, "<- done (SUCCESS!)",0,0,0,0); UVMHIST_LOG(maphist, "<- done (SUCCESS!)",0,0,0,0);
error = 0; return 0;
return error;
} }