diff options
| -rw-r--r-- | sys/src/9/port/page.c | 2 | ||||
| -rw-r--r-- | sys/src/9/port/portfns.h | 1 | ||||
| -rw-r--r-- | sys/src/9/port/segment.c | 9 |
3 files changed, 9 insertions, 3 deletions
diff --git a/sys/src/9/port/page.c b/sys/src/9/port/page.c index d76fc4038..60cbee12e 100644 --- a/sys/src/9/port/page.c +++ b/sys/src/9/port/page.c @@ -64,7 +64,7 @@ pageinit(void) print("%ldM swap\n", vkb/1024); } -static void +void pageunchain(Page *p) { if(canlock(&palloc)) diff --git a/sys/src/9/port/portfns.h b/sys/src/9/port/portfns.h index 41b4b105d..96071501c 100644 --- a/sys/src/9/port/portfns.h +++ b/sys/src/9/port/portfns.h @@ -202,6 +202,7 @@ int okaddr(uintptr, ulong, int); int openmode(ulong); Block* packblock(Block*); Block* padblock(Block*, int); +void pageunchain(Page*); void pagechainhead(Page*); void pageinit(void); ulong pagenumber(Page*); diff --git a/sys/src/9/port/segment.c b/sys/src/9/port/segment.c index cd48d52b4..c73698b9e 100644 --- a/sys/src/9/port/segment.c +++ b/sys/src/9/port/segment.c @@ -313,7 +313,7 @@ static void imagereclaim(void) { int n; - Page *p; + Page *p, *x; uvlong ticks; irstats.calls++; @@ -329,11 +329,16 @@ imagereclaim(void) * end of the list (see putpage) so start there and work * backward. */ - for(p = palloc.tail; p && p->image && (n<1000 || !imagealloc.free); p = p->prev) { + for(p = palloc.tail; p && p->image && (n<1000 || !imagealloc.free); p = x) { + x = p->prev; if(p->ref == 0 && canlock(p)) { if(p->ref == 0 && p->image && !p->image->notext) { n++; uncachepage(p); + + /* move to head to maintain the invariant above */ + pageunchain(p); + pagechainhead(p); } unlock(p); } |
