changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: kernel: get rid of checkpagerefs() debugging

changeset 7183: 6b46879a272e
parent 7182: f7fd59ea46c5
child 7184: 681e7449529d
author: cinap_lenrek@felloff.net
date: Wed, 01 May 2019 12:40:27 +0200
files: sys/src/9/mtx/mmu.c sys/src/9/pc64/mmu.c sys/src/9/port/page.c sys/src/9/port/portfns.h sys/src/9/port/sysproc.c sys/src/9/ppc/mmu.c sys/src/9/sgi/mmu.c sys/src/9/xen/mmu.c sys/src/9/zynq/mmu.c
description: kernel: get rid of checkpagerefs() debugging

was only implemented by the pc kernel. does not
account pages used by the mount cache.
     1.1--- a/sys/src/9/mtx/mmu.c
     1.2+++ b/sys/src/9/mtx/mmu.c
     1.3@@ -229,11 +229,6 @@ checkmmu(uintptr, uintptr)
     1.4 {
     1.5 }
     1.6 
     1.7-void
     1.8-countpagerefs(ulong*, int)
     1.9-{
    1.10-}
    1.11-
    1.12 /*
    1.13  * Return the number of bytes that can be accessed via KADDR(pa).
    1.14  * If pa is not a valid argument to KADDR, return 0.
     2.1--- a/sys/src/9/pc64/mmu.c
     2.2+++ b/sys/src/9/pc64/mmu.c
     2.3@@ -468,12 +468,6 @@ cankaddr(uintptr pa)
     2.4 	return -KZERO - pa;
     2.5 }
     2.6 
     2.7-void
     2.8-countpagerefs(ulong *ref, int print)
     2.9-{
    2.10-	USED(ref, print);
    2.11-}
    2.12-
    2.13 KMap*
    2.14 kmap(Page *page)
    2.15 {
     3.1--- a/sys/src/9/port/page.c
     3.2+++ b/sys/src/9/port/page.c
     3.3@@ -399,119 +399,3 @@ freepte(Segment *s, Pte *p)
     3.4 	}
     3.5 	free(p);
     3.6 }
     3.7-
     3.8-ulong
     3.9-pagenumber(Page *p)
    3.10-{
    3.11-	return p-palloc.pages;
    3.12-}
    3.13-
    3.14-void
    3.15-checkpagerefs(void)
    3.16-{
    3.17-	int s;
    3.18-	ulong i, np, nwrong;
    3.19-	ulong *ref;
    3.20-	
    3.21-	np = palloc.user;
    3.22-	ref = malloc(np*sizeof ref[0]);
    3.23-	if(ref == nil){
    3.24-		print("checkpagerefs: out of memory\n");
    3.25-		return;
    3.26-	}
    3.27-	
    3.28-	/*
    3.29-	 * This may not be exact if there are other processes
    3.30-	 * holding refs to pages on their stacks.  The hope is
    3.31-	 * that if you run it on a quiescent system it will still
    3.32-	 * be useful.
    3.33-	 */
    3.34-	s = splhi();
    3.35-	lock(&palloc);
    3.36-	countpagerefs(ref, 0);
    3.37-	portcountpagerefs(ref, 0);
    3.38-	nwrong = 0;
    3.39-	for(i=0; i<np; i++){
    3.40-		if(palloc.pages[i].ref != ref[i]){
    3.41-			iprint("page %#p ref %ld actual %lud\n", 
    3.42-				palloc.pages[i].pa, palloc.pages[i].ref, ref[i]);
    3.43-			ref[i] = 1;
    3.44-			nwrong++;
    3.45-		}else
    3.46-			ref[i] = 0;
    3.47-	}
    3.48-	countpagerefs(ref, 1);
    3.49-	portcountpagerefs(ref, 1);
    3.50-	iprint("%lud mistakes found\n", nwrong);
    3.51-	unlock(&palloc);
    3.52-	splx(s);
    3.53-	free(ref);
    3.54-}
    3.55-
    3.56-void
    3.57-portcountpagerefs(ulong *ref, int print)
    3.58-{
    3.59-	ulong i, j, k, ns, n;
    3.60-	Page **pg, *entry;
    3.61-	Proc *p;
    3.62-	Pte *pte;
    3.63-	Segment *s;
    3.64-
    3.65-	/*
    3.66-	 * Pages in segments.  s->mark avoids double-counting.
    3.67-	 */
    3.68-	n = 0;
    3.69-	ns = 0;
    3.70-	for(i=0; i<conf.nproc; i++){
    3.71-		p = proctab(i);
    3.72-		for(j=0; j<NSEG; j++){
    3.73-			s = p->seg[j];
    3.74-			if(s != nil)
    3.75-				s->mark = 0;
    3.76-		}
    3.77-	}
    3.78-	for(i=0; i<conf.nproc; i++){
    3.79-		p = proctab(i);
    3.80-		for(j=0; j<NSEG; j++){
    3.81-			s = p->seg[j];
    3.82-			if(s == nil || s->mark++)
    3.83-				continue;
    3.84-			if((s->type&SG_TYPE) == SG_PHYSICAL)
    3.85-				continue;
    3.86-			ns++;
    3.87-			for(k=0; k<s->mapsize; k++){
    3.88-				pte = s->map[k];
    3.89-				if(pte == nil)
    3.90-					continue;
    3.91-				for(pg = pte->first; pg <= pte->last; pg++){
    3.92-					entry = *pg;
    3.93-					if(pagedout(entry))
    3.94-						continue;
    3.95-					if(print){
    3.96-						if(ref[pagenumber(entry)])
    3.97-							iprint("page %#p in segment %#p\n", entry->pa, s);
    3.98-						continue;
    3.99-					}
   3.100-					if(ref[pagenumber(entry)]++ == 0)
   3.101-						n++;
   3.102-				}
   3.103-			}
   3.104-		}
   3.105-	}
   3.106-	if(!print){
   3.107-		iprint("%lud pages in %lud segments\n", n, ns);
   3.108-		for(i=0; i<conf.nproc; i++){
   3.109-			p = proctab(i);
   3.110-			for(j=0; j<NSEG; j++){
   3.111-				s = p->seg[j];
   3.112-				if(s == nil)
   3.113-					continue;
   3.114-				if(s->ref != s->mark){
   3.115-					iprint("segment %#p (used by proc %lud pid %lud) has bad ref count %lud actual %lud\n",
   3.116-						s, i, p->pid, s->ref, s->mark);
   3.117-				}
   3.118-			}
   3.119-		}
   3.120-	}
   3.121-}
   3.122-
     4.1--- a/sys/src/9/port/portfns.h
     4.2+++ b/sys/src/9/port/portfns.h
     4.3@@ -207,7 +207,6 @@ Block*		padblock(Block*, int);
     4.4 void		pagechaindone(void);
     4.5 void		pagechainhead(Page*);
     4.6 void		pageinit(void);
     4.7-ulong		pagenumber(Page*);
     4.8 ulong		pagereclaim(Image*, ulong);
     4.9 void		panic(char*, ...);
    4.10 Cmdbuf*		parsecmd(char *a, int n);
     5.1--- a/sys/src/9/port/sysproc.c
     5.2+++ b/sys/src/9/port/sysproc.c
     5.3@@ -9,15 +9,11 @@
     5.4 
     5.5 #include	<a.out.h>
     5.6 
     5.7-extern void checkpages(void);
     5.8-extern void checkpagerefs(void);
     5.9-
    5.10 uintptr
    5.11 sysr1(va_list)
    5.12 {
    5.13 	if(!iseve())
    5.14 		error(Eperm);
    5.15-	checkpagerefs();
    5.16 	return 0;
    5.17 }
    5.18 
     6.1--- a/sys/src/9/ppc/mmu.c
     6.2+++ b/sys/src/9/ppc/mmu.c
     6.3@@ -255,11 +255,6 @@ checkmmu(uintptr, uintptr)
     6.4 {
     6.5 }
     6.6 
     6.7-void
     6.8-countpagerefs(ulong*, int)
     6.9-{
    6.10-}
    6.11-
    6.12 /*
    6.13  * Return the number of bytes that can be accessed via KADDR(pa).
    6.14  * If pa is not a valid argument to KADDR, return 0.
     7.1--- a/sys/src/9/sgi/mmu.c
     7.2+++ b/sys/src/9/sgi/mmu.c
     7.3@@ -461,11 +461,6 @@ checkmmu(ulong, ulong)
     7.4 {
     7.5 }
     7.6 
     7.7-void
     7.8-countpagerefs(ulong*, int)
     7.9-{
    7.10-}
    7.11-
    7.12 /*
    7.13  * Return the number of bytes that can be accessed via KADDR(pa).
    7.14  * If pa is not a valid argument to KADDR, return 0.
     8.1--- a/sys/src/9/xen/mmu.c
     8.2+++ b/sys/src/9/xen/mmu.c
     8.3@@ -509,16 +509,6 @@ mmukmapsync(ulong va)
     8.4 }
     8.5 
     8.6 /*
     8.7- * More debugging.
     8.8- */
     8.9-void
    8.10-countpagerefs(ulong *ref, int print)
    8.11-{
    8.12-	USED(ref);
    8.13-	USED(print);
    8.14-}
    8.15-
    8.16-/*
    8.17  * Return the number of bytes that can be accessed via KADDR(pa).
    8.18  * If pa is not a valid argument to KADDR, return 0.
    8.19  */
     9.1--- a/sys/src/9/zynq/mmu.c
     9.2+++ b/sys/src/9/zynq/mmu.c
     9.3@@ -242,12 +242,6 @@ mmurelease(Proc *proc)
     9.4 	proc->mmufree = nil;
     9.5 }
     9.6 
     9.7-void
     9.8-countpagerefs(ulong *, int)
     9.9-{
    9.10-	print("countpagerefs\n");
    9.11-}
    9.12-
    9.13 uintptr
    9.14 paddr(void *v)
    9.15 {