ref: b452f8857f22089adca137f32b9456a208554800
parent: a6ee23a739716493e4635cb9c4eb55248f2d43cf
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed May 1 06:07:39 EDT 2019
kernel: export freepages() function so it can be used in mmurelease()
--- a/sys/src/9/port/page.c
+++ b/sys/src/9/port/page.c
@@ -82,15 +82,14 @@
wakeup(&palloc.pwait[1]);
}
-static void
+void
freepages(Page *head, Page *tail, ulong np)
{
- lock(&palloc);
+ assert(palloc.Lock.p == up);
tail->next = palloc.head;
palloc.head = head;
palloc.freecount += np;
pagechaindone();
- unlock(&palloc);
}
ulong
@@ -142,8 +141,11 @@
unlock(i);
putimage(i);
- if(np > 0)
+ if(np > 0){
+ lock(&palloc);
freepages(fh, ft, np);
+ unlock(&palloc);
+ }
return np;
}
@@ -238,8 +240,11 @@
decref(p);
return;
}
- if(decref(p) == 0)
+ if(decref(p) == 0){
+ lock(&palloc);
freepages(p, p, 1);
+ unlock(&palloc);
+ }
}
void
--- a/sys/src/9/port/portfns.h
+++ b/sys/src/9/port/portfns.h
@@ -117,6 +117,7 @@
void freeb(Block*);
void freeblist(Block*);
int freebroken(void);
+void freepages(Page*, Page*, ulong);
void freepte(Segment*, Pte*);
void getcolor(ulong, ulong*, ulong*, ulong*);
uintptr getmalloctag(void*);