you'r right. the smartness of duppage() isnt really neccesary. we
can just leave the cache alone. when memory is low, newpage() will
uncache pages for us.
fixfault():
...
lkp = *pg;
lock(lkp);
if(lkp->ref == 0)
panic("fault %#p ref == 0", lkp);
if(lkp->ref == 1 && lkp->image == nil) {
unlock(lkp);
} else if(lkp->image == &swapimage && (lkp->ref +
swapcount(lkp->daddr)) == 1) {
uncachepage(lkp);
unlock(lkp);
} else {
unlock(lkp);
new = newpage(0, &s, addr);
if(s == 0)
return -1;
*pg = new;
copypage(lkp, *pg);
putpage(lkp);
}
mmuphys = PPN((*pg)->pa) | PTEWRITE | PTEVALID;
(*pg)->modref = PG_MOD|PG_REF;
break;
--
cinap