summaryrefslogtreecommitdiff
path: root/sys/src/9/port/page.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-07-09 00:01:50 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-07-09 00:01:50 +0200
commit8ed25f24b7831eab394f14697766d55065b18822 (patch)
tree58fade4cfccb0e0e081e7687a3860406c80d54e1 /sys/src/9/port/page.c
parentfcb9abccbbc73a4f449d55c2c7fb369db2ad139d (diff)
kernel: various cleanups of imagereclaim(), pagereclaim(), freepages(), putimage()
imagereclaim(), pagereclaim(): - move imagereclaim() and pagereclaim() declarations to portfns.h - consistently use ulong type for page counts - name number of pages to free "pages" instead of "min" - check for pages == 0 on entry freepages(): - move pagechaindone() call to wakeup newpage() consumers inside palloc critical section. putimage(): - use long type for refcount
Diffstat (limited to 'sys/src/9/port/page.c')
-rw-r--r--sys/src/9/port/page.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/sys/src/9/port/page.c b/sys/src/9/port/page.c
index 2b0c10eeb..85406f4af 100644
--- a/sys/src/9/port/page.c
+++ b/sys/src/9/port/page.c
@@ -83,22 +83,25 @@ pagechaindone(void)
}
static void
-freepages(Page *head, Page *tail, int n)
+freepages(Page *head, Page *tail, ulong np)
{
lock(&palloc);
tail->next = palloc.head;
palloc.head = head;
- palloc.freecount += n;
- unlock(&palloc);
+ palloc.freecount += np;
pagechaindone();
+ unlock(&palloc);
}
-int
-pagereclaim(Image *i, int min)
+ulong
+pagereclaim(Image *i, ulong pages)
{
Page **h, **l, **x, *p;
Page *fh, *ft;
- int n;
+ ulong np;
+
+ if(pages == 0)
+ return 0;
lock(i);
if(i->pgref == 0){
@@ -107,7 +110,7 @@ pagereclaim(Image *i, int min)
}
incref(i);
- n = 0;
+ np = 0;
fh = ft = nil;
for(h = i->pghash; h < &i->pghash[PGHSIZE]; h++){
l = h;
@@ -133,16 +136,16 @@ pagereclaim(Image *i, int min)
else
ft->next = p;
ft = p;
- if(++n >= min)
+ if(++np >= pages)
break;
}
unlock(i);
putimage(i);
- if(n > 0)
- freepages(fh, ft, n);
+ if(np > 0)
+ freepages(fh, ft, np);
- return n;
+ return np;
}
static int