changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: kernel: export freepages() function so it can be used in mmurelease()

changeset 7182: f7fd59ea46c5
parent 7181: 0949b361c51e
child 7183: 6b46879a272e
author: cinap_lenrek@felloff.net
date: Wed, 01 May 2019 10:07:39 +0200
files: sys/src/9/port/page.c sys/src/9/port/portfns.h
description: kernel: export freepages() function so it can be used in mmurelease()
     1.1--- a/sys/src/9/port/page.c
     1.2+++ b/sys/src/9/port/page.c
     1.3@@ -82,15 +82,14 @@ pagechaindone(void)
     1.4 		wakeup(&palloc.pwait[1]);
     1.5 }
     1.6 
     1.7-static void
     1.8+void
     1.9 freepages(Page *head, Page *tail, ulong np)
    1.10 {
    1.11-	lock(&palloc);
    1.12+	assert(palloc.Lock.p == up);
    1.13 	tail->next = palloc.head;
    1.14 	palloc.head = head;
    1.15 	palloc.freecount += np;
    1.16 	pagechaindone();
    1.17-	unlock(&palloc);
    1.18 }
    1.19 
    1.20 ulong
    1.21@@ -142,8 +141,11 @@ pagereclaim(Image *i, ulong pages)
    1.22 	unlock(i);
    1.23 	putimage(i);
    1.24 
    1.25-	if(np > 0)
    1.26+	if(np > 0){
    1.27+		lock(&palloc);
    1.28 		freepages(fh, ft, np);
    1.29+		unlock(&palloc);
    1.30+	}
    1.31 
    1.32 	return np;
    1.33 }
    1.34@@ -238,8 +240,11 @@ putpage(Page *p)
    1.35 		decref(p);
    1.36 		return;
    1.37 	}
    1.38-	if(decref(p) == 0)
    1.39+	if(decref(p) == 0){
    1.40+		lock(&palloc);
    1.41 		freepages(p, p, 1);
    1.42+		unlock(&palloc);
    1.43+	}
    1.44 }
    1.45 
    1.46 void
     2.1--- a/sys/src/9/port/portfns.h
     2.2+++ b/sys/src/9/port/portfns.h
     2.3@@ -117,6 +117,7 @@ void		free(void*);
     2.4 void		freeb(Block*);
     2.5 void		freeblist(Block*);
     2.6 int		freebroken(void);
     2.7+void		freepages(Page*, Page*, ulong);
     2.8 void		freepte(Segment*, Pte*);
     2.9 void		getcolor(ulong, ulong*, ulong*, ulong*);
    2.10 uintptr		getmalloctag(void*);