ref: 64ed3658d2abe3829f0619e8243c60edcc1d3815
parent: bce2696b17f4891e819958ed9e8f1adf8bdd97dc
author: cinap_lenrek <[email protected]>
date: Mon Jun 15 13:40:47 EDT 2015
kernel: add pagechaindone() to wakeup processes waiting for memory we keep the details about palloc in page.c, providing pagechaindone() for mmu code to be called after a series of pagechainhead() calls.
--- a/sys/src/9/alphapc/mmu.c
+++ b/sys/src/9/alphapc/mmu.c
@@ -110,8 +110,8 @@
panic("mmurelease: page->ref %d\n", page->ref);
pagechainhead(page);
}
- if(proc->mmufree && palloc.r.p)
- wakeup(&palloc.r);
+ if(proc->mmufree)
+ pagechaindone();
proc->mmufree = 0;
}
--- a/sys/src/9/bcm/mmu.c
+++ b/sys/src/9/bcm/mmu.c
@@ -183,11 +183,11 @@
for(page = proc->mmul2cache; page != nil; page = next){
next = page->next;
if(--page->ref)
- panic("mmurelease: page->ref %d", page->ref);
+ panic("mmurelease: page->ref %lud", page->ref);
pagechainhead(page);
}
- if(proc->mmul2cache && palloc.r.p)
- wakeup(&palloc.r);
+ if(proc->mmul2cache != nil)
+ pagechaindone();
proc->mmul2cache = nil;
mmul1empty();
--- a/sys/src/9/bitsy/mmu.c
+++ b/sys/src/9/bitsy/mmu.c
@@ -447,14 +447,14 @@
mmuptefree(p);
- for(pg = p->mmufree; pg; pg = next){
+ for(pg = p->mmufree; pg != nil; pg = next){
next = pg->next;
if(--pg->ref)
panic("mmurelease: pg->ref %d\n", pg->ref);
pagechainhead(pg);
}
- if(p->mmufree && palloc.r.p)
- wakeup(&palloc.r);
+ if(p->mmufree != nil)
+ pagechaindone();
p->mmufree = nil;
memset(l1table, 0, sizeof(p->l1table));
--- a/sys/src/9/kw/mmu.c
+++ b/sys/src/9/kw/mmu.c
@@ -264,8 +264,8 @@
panic("mmurelease: page->ref %lud", page->ref);
pagechainhead(page);
}
- if(proc->mmul2cache && palloc.r.p)
- wakeup(&palloc.r);
+ if(proc->mmul2cache != nil)
+ pagechaindone();
proc->mmul2cache = nil;
mmul1empty();
--- a/sys/src/9/pc/mmu.c
+++ b/sys/src/9/pc/mmu.c
@@ -365,8 +365,8 @@
panic("mmurelease: page->ref %ld", page->ref);
pagechainhead(page);
}
- if(proc->mmufree != nil && palloc.r.p != nil)
- wakeup(&palloc.r);
+ if(proc->mmufree != nil)
+ pagechaindone();
proc->mmufree = nil;
if(proc->ldt != nil){
free(proc->ldt);
--- a/sys/src/9/port/page.c
+++ b/sys/src/9/port/page.c
@@ -71,6 +71,15 @@
palloc.freecount++;
}
+void
+pagechaindone(void)
+{
+ if(palloc.pwait[0].p != nil && wakeup(&palloc.pwait[0]) != nil)
+ return;
+ if(palloc.pwait[1].p != nil)
+ wakeup(&palloc.pwait[1]);
+}
+
static void
freepages(Page *head, Page *tail, int n)
{
@@ -79,11 +88,7 @@
palloc.head = head;
palloc.freecount += n;
unlock(&palloc);
-
- if(palloc.pwait[0].p != nil && wakeup(&palloc.pwait[0]) != nil)
- return;
- if(palloc.pwait[1].p != nil)
- wakeup(&palloc.pwait[1]);
+ pagechaindone();
}
int
--- a/sys/src/9/port/portfns.h
+++ b/sys/src/9/port/portfns.h
@@ -201,6 +201,7 @@
int openmode(ulong);
Block* packblock(Block*);
Block* padblock(Block*, int);
+void pagechaindone(void);
void pagechainhead(Page*);
void pageinit(void);
ulong pagenumber(Page*);
--- a/sys/src/9/teg2/mmu.c
+++ b/sys/src/9/teg2/mmu.c
@@ -487,8 +487,8 @@
panic("mmurelease: page->ref %d", page->ref);
pagechainhead(page);
}
- if(proc->mmul2cache && palloc.r.p)
- wakeup(&palloc.r);
+ if(proc->mmul2cache != nil)
+ pagechaindone();
proc->mmul2cache = nil;
mmul1empty();
--- a/sys/src/9/xen/mmu.c
+++ b/sys/src/9/xen/mmu.c
@@ -288,8 +288,8 @@
panic("mmurelease: page->ref %ld\n", page->ref);
pagechainhead(page);
}
- if(proc->mmufree && palloc.r.p)
- wakeup(&palloc.r);
+ if(proc->mmufree)
+ pagechaindone();
proc->mmufree = 0;
}
--- a/sys/src/9/zynq/mmu.c
+++ b/sys/src/9/zynq/mmu.c
@@ -237,8 +237,8 @@
panic("mmurelease: p->ref %ld", p->ref);
pagechainhead(p);
}
- if(proc->mmufree != nil && palloc.r.p != nil)
- wakeup(&palloc.r);
+ if(proc->mmufree != nil)
+ pagechaindone();
proc->mmufree = nil;
}