kernel: avoid repeated calls to reclaim(), dont miss last page in Pte

when we are skipping a process because we could not acquire
its segment lock, dont call reclaim() again (which is pointless
as we didnt pageout any pages), instead try the next process.

the Pte.last pointer is inclusive, so don't miss the last page
in pageout().
This commit is contained in:
cinap_lenrek 2015-03-16 05:23:38 +01:00
parent c1717aebf7
commit d0b1db98bc

View file

@ -7,7 +7,6 @@
static int canflush(Proc*, Segment*); static int canflush(Proc*, Segment*);
static void executeio(void); static void executeio(void);
static int needpages(void*);
static void pageout(Proc*, Segment*); static void pageout(Proc*, Segment*);
static void pagepte(int, Page**); static void pagepte(int, Page**);
static void pager(void*); static void pager(void*);
@ -166,24 +165,21 @@ pager(void*)
} }
if(swapimage.c == nil || swapalloc.free == 0){ if(swapimage.c == nil || swapalloc.free == 0){
Killbig:
killbig("out of memory"); killbig("out of memory");
freebroken(); /* can use the memory */ freebroken(); /* can use the memory */
sched(); sched();
continue; continue;
} }
p++; i = ageclock;
if(p >= ep){ do {
p = proctab(0); if(++p >= ep){
ageclock++; if(++ageclock == i)
} goto Killbig;
p = proctab(0);
if(p->state == Dead || p->noswap) }
continue; } while(p->state == Dead || p->noswap || !canqlock(&p->seglock));
if(!canqlock(&p->seglock))
continue; /* process changing its segments */
up->psstate = "Pageout"; up->psstate = "Pageout";
for(i = 0; i < NSEG; i++) { for(i = 0; i < NSEG; i++) {
if((s = p->seg[i]) != nil) { if((s = p->seg[i]) != nil) {
@ -239,9 +235,9 @@ pageout(Proc *p, Segment *s)
size = s->mapsize; size = s->mapsize;
for(i = 0; i < size; i++) { for(i = 0; i < size; i++) {
l = s->map[i]; l = s->map[i];
if(l == 0) if(l == nil)
continue; continue;
for(pg = l->first; pg < l->last; pg++) { for(pg = l->first; pg <= l->last; pg++) {
entry = *pg; entry = *pg;
if(pagedout(entry)) if(pagedout(entry))
continue; continue;
@ -389,7 +385,7 @@ executeio(void)
ioptr = 0; ioptr = 0;
} }
static int int
needpages(void*) needpages(void*)
{ {
return palloc.freecount < swapalloc.headroom; return palloc.freecount < swapalloc.headroom;