Browse Source

de-anonymize more of port

Change-Id: Ia523a79d5db5386fa7827037a1ce75f21cd4c161
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 8 years ago
parent
commit
e0877aefb6
5 changed files with 37 additions and 37 deletions
  1. 5 5
      sys/src/9/k10/mmu.c
  2. 4 4
      sys/src/9/port/alarm.c
  3. 3 3
      sys/src/9/port/fault.c
  4. 23 23
      sys/src/9/port/page.c
  5. 2 2
      sys/src/9/port/portdat.h

+ 5 - 5
sys/src/9/k10/mmu.c

@@ -161,11 +161,11 @@ mmuptpalloc(void)
 	 * Could keep a cache and free excess.
 	 * Have to maintain any fiction for pexit?
 	 */
-	lock(&mmuptpfreelist);
+	lock(&mmuptpfreelist.l);
 	if((page = mmuptpfreelist.next) != nil){
 		mmuptpfreelist.next = page->next;
 		mmuptpfreelist.ref--;
-		unlock(&mmuptpfreelist);
+		unlock(&mmuptpfreelist.l);
 
 		if(page->ref++ != 0)
 			panic("mmuptpalloc ref\n");
@@ -176,7 +176,7 @@ mmuptpalloc(void)
 			panic("mmuptpalloc: free page with pa == 0");
 		return page;
 	}
-	unlock(&mmuptpfreelist);
+	unlock(&mmuptpfreelist.l);
 
 	if((page = malloc(sizeof(Page))) == nil){
 		print("mmuptpalloc Page\n");
@@ -246,12 +246,12 @@ mmurelease(Proc* proc)
 		next = page->next;
 		if(--page->ref)
 			panic("mmurelease: page->ref %d\n", page->ref);
-		lock(&mmuptpfreelist);
+		lock(&mmuptpfreelist.l);
 		page->next = mmuptpfreelist.next;
 		mmuptpfreelist.next = page;
 		mmuptpfreelist.ref++;
 		page->prev = nil;
-		unlock(&mmuptpfreelist);
+		unlock(&mmuptpfreelist.l);
 	}
 	if(proc->mmuptp[0] && pga.r.l.p)
 		wakeup(&pga.r);

+ 4 - 4
sys/src/9/port/alarm.c

@@ -25,7 +25,7 @@ alarmkproc(void* v)
 
 	for(;;){
 		now = sys->ticks;
-		qlock(&alarms);
+		qlock(&alarms.ql);
 		while((rp = alarms._head) && rp->alarm <= now){
 			if(rp->alarm != 0L){
 				if(canqlock(&rp->debug)){
@@ -40,7 +40,7 @@ alarmkproc(void* v)
 			}
 			alarms._head = rp->palarm;
 		}
-		qunlock(&alarms);
+		qunlock(&alarms.ql);
 
 		sleep(&alarmr, return0, 0);
 	}
@@ -79,7 +79,7 @@ procalarm(uint32_t time)
 	}
 	when = ms2tk(time)+sys->ticks;
 
-	qlock(&alarms);
+	qlock(&alarms.ql);
 	l = &alarms._head;
 	for(f = *l; f; f = f->palarm) {
 		if(up == f){
@@ -106,7 +106,7 @@ procalarm(uint32_t time)
 		alarms._head = up;
 done:
 	up->alarm = when;
-	qunlock(&alarms);
+	qunlock(&alarms.ql);
 
 	return old;
 }

+ 3 - 3
sys/src/9/port/fault.c

@@ -215,13 +215,13 @@ fixfault(Segment *s, uintptr_t addr, int ftype, int dommuput, int color)
 		if((s->type & SG_TYPE) != SG_SHARED){
 
 			lkp = *pg;
-			lock(lkp);
+			lock(&lkp->l);
 
 			ref = lkp->ref;
 
 			if(ref > 1) {	/* page is shared but segment is not: copy for write */
 				int pgref = lkp->ref;
-				unlock(lkp);
+				unlock(&lkp->l);
 
 				DBG("fixfault %d: copy on %s, %s(%c%c%c) 0x%p segref %d pgref %d\n",
 					up->pid,
@@ -246,7 +246,7 @@ fixfault(Segment *s, uintptr_t addr, int ftype, int dommuput, int color)
 				if(lkp->image != nil)
 					duppage(lkp);
 
-				unlock(lkp);
+				unlock(&lkp->l);
 			}
 		}
 		mmuattr = PTEVALID|PTEWRITE;

+ 23 - 23
sys/src/9/port/page.c

@@ -286,7 +286,7 @@ newpage(int clear, Segment **s, uintptr_t va, usize size, int color)
 
 	pageunchain(p);
 
-	lock(p);
+	lock(&p->l);
 	if(p->ref != 0)
 		panic("newpage pa %#ullx", p->pa);
 
@@ -296,7 +296,7 @@ newpage(int clear, Segment **s, uintptr_t va, usize size, int color)
 	p->modref = 0;
 	for(i = 0; i < nelem(p->cachectl); i++)
 		p->cachectl[i] = ct;
-	unlock(p);
+	unlock(&p->l);
 	unlock(&pga);
 
 	if(clear) {
@@ -331,13 +331,13 @@ putpage(Page *p)
 	int rlse;
 
 	lock(&pga);
-	lock(p);
+	lock(&p->l);
 
 	if(p->ref == 0)
 		panic("putpage");
 
 	if(--p->ref > 0) {
-		unlock(p);
+		unlock(&p->l);
 		unlock(&pga);
 		return;
 	}
@@ -356,7 +356,7 @@ putpage(Page *p)
 	}
 	if(&pga.r.l != nil)
 		wakeup(&pga.r);
-	unlock(p);
+	unlock(&p->l);
 	if(rlse)
 		pgfree(p);
 	unlock(&pga);
@@ -384,12 +384,12 @@ auxpage(usize size)
 		return nil;
 	}
 	pageunchain(p);
-	lock(p);
+	lock(&p->l);
 	if(p->ref != 0)
 		panic("auxpage");
 	p->ref++;
 	uncachepage(p);
-	unlock(p);
+	unlock(&p->l);
 	unlock(&pga);
 
 	return p;
@@ -425,15 +425,15 @@ retry:
 
 	/*
 	 *  normal lock ordering is to call
-	 *  lock(&pga) before lock(p).
+	 *  lock(&pga) before lock(&p->l).
 	 *  To avoid deadlock, we have to drop
 	 *  our locks and try again.
 	 */
 	if(!canlock(&pga)){
-		unlock(p);
+		unlock(&p->l);
 		if(up)
 			sched();
-		lock(p);
+		lock(&p->l);
 		goto retry;
 	}
 
@@ -474,7 +474,7 @@ retry:
 	 * doing it at the end, to prevent the race, leads to a
 	 * deadlock, even following the pga, pg lock ordering. -nemo
 	 */
-	lock(np);
+	lock(&np->l);
 	unlock(&pga);
 
 	/* Cache the new version */
@@ -483,7 +483,7 @@ retry:
 	np->daddr = p->daddr;
 	copypage(p, np);
 	cachepage(np, p->image);
-	unlock(np);
+	unlock(&np->l);
 	uncachepage(p);
 
 	return 0;
@@ -557,14 +557,14 @@ cachedel(Image *i, uint32_t daddr)
 	l = &pghash(daddr);
 	for(f = *l; f; f = f->hash){
 		if(f->image == i && f->daddr == daddr){
-			lock(f);
+			lock(&f->l);
 			if(f->image == i && f->daddr == daddr){
 				*l = f->hash;
 				putimage(f->image);
 				f->image = nil;
 				f->daddr = 0;
 			}
-			unlock(f);
+			unlock(&f->l);
 			break;
 		}
 		l = &f->hash;
@@ -583,16 +583,16 @@ lookpage(Image *i, uint32_t daddr)
 			unlock(&pga.hashlock);
 
 			lock(&pga);
-			lock(f);
+			lock(&f->l);
 			if(f->image != i || f->daddr != daddr){
-				unlock(f);
+				unlock(&f->l);
 				unlock(&pga);
 				return 0;
 			}
 			if(++f->ref == 1)
 				pageunchain(f);
 			unlock(&pga);
-			unlock(f);
+			unlock(&f->l);
 
 			return f;
 		}
@@ -622,11 +622,11 @@ pagereclaim(Image *i)
 	 * backward.
 	 */
 	for(p = pga.pgsza[0].tail; p && p->image == i; p = p->prev){
-		if(p->ref == 0 && canlock(p)){
+		if(p->ref == 0 && canlock(&p->l)){
 			if(p->ref == 0) {
 				uncachepage(p);
 			}
-			unlock(p);
+			unlock(&p->l);
 		}
 	}
 	ticks = fastticks(nil) - ticks;
@@ -649,9 +649,9 @@ ptecpy(Segment *s, Pte *old)
 			if(onswap(*src))
 				panic("ptecpy: no swap");
 			else{
-				lock(*src);
+				lock(&(*src)->l);
 				(*src)->ref++;
-				unlock(*src);
+				unlock(&(*src)->l);
 			}
 			new->last = dst;
 			*dst = *src;
@@ -695,9 +695,9 @@ freepte(Segment *s, Pte *p)
 			pt = *pg;
 			if(pt == 0)
 				continue;
-			lock(pt);
+			lock(&pt->l);
 			ref = --pt->ref;
-			unlock(pt);
+			unlock(&pt->l);
 			if(ref == 0)
 				free(pt);
 		}

+ 2 - 2
sys/src/9/port/portdat.h

@@ -156,7 +156,7 @@ struct RWlock
 
 struct Alarms
 {
-	QLock;
+	QLock ql;
 	Proc	*_head;
 };
 
@@ -374,7 +374,7 @@ enum
 
 struct Page
 {
-	Lock;
+	Lock l;
 	uintmem	pa;			/* Physical address in memory */
 	uintptr_t	va;			/* Virtual address for user */
 	uint32_t	daddr;			/* Disc address on swap */