ref: fe594760ebddac23e673d189d2152062ef75d8b8
parent: b452f8857f22089adca137f32b9456a208554800
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed May 1 08:40:27 EDT 2019
kernel: get rid of checkpagerefs() debugging was only implemented by the pc kernel. does not account pages used by the mount cache.
--- a/sys/src/9/mtx/mmu.c
+++ b/sys/src/9/mtx/mmu.c
@@ -229,11 +229,6 @@
{
}
-void
-countpagerefs(ulong*, int)
-{
-}
-
/*
* Return the number of bytes that can be accessed via KADDR(pa).
* If pa is not a valid argument to KADDR, return 0.
--- a/sys/src/9/pc64/mmu.c
+++ b/sys/src/9/pc64/mmu.c
@@ -468,12 +468,6 @@
return -KZERO - pa;
}
-void
-countpagerefs(ulong *ref, int print)
-{
- USED(ref, print);
-}
-
KMap*
kmap(Page *page)
{
--- a/sys/src/9/port/page.c
+++ b/sys/src/9/port/page.c
@@ -399,119 +399,3 @@
}
free(p);
}
-
-ulong
-pagenumber(Page *p)
-{
- return p-palloc.pages;
-}
-
-void
-checkpagerefs(void)
-{
- int s;
- ulong i, np, nwrong;
- ulong *ref;
-
- np = palloc.user;
- ref = malloc(np*sizeof ref[0]);
- if(ref == nil){
- print("checkpagerefs: out of memory\n");
- return;
- }
-
- /*
- * This may not be exact if there are other processes
- * holding refs to pages on their stacks. The hope is
- * that if you run it on a quiescent system it will still
- * be useful.
- */
- s = splhi();
- lock(&palloc);
- countpagerefs(ref, 0);
- portcountpagerefs(ref, 0);
- nwrong = 0;
- for(i=0; i<np; i++){
- if(palloc.pages[i].ref != ref[i]){
- iprint("page %#p ref %ld actual %lud\n",
- palloc.pages[i].pa, palloc.pages[i].ref, ref[i]);
- ref[i] = 1;
- nwrong++;
- }else
- ref[i] = 0;
- }
- countpagerefs(ref, 1);
- portcountpagerefs(ref, 1);
- iprint("%lud mistakes found\n", nwrong);
- unlock(&palloc);
- splx(s);
- free(ref);
-}
-
-void
-portcountpagerefs(ulong *ref, int print)
-{
- ulong i, j, k, ns, n;
- Page **pg, *entry;
- Proc *p;
- Pte *pte;
- Segment *s;
-
- /*
- * Pages in segments. s->mark avoids double-counting.
- */
- n = 0;
- ns = 0;
- for(i=0; i<conf.nproc; i++){
- p = proctab(i);
- for(j=0; j<NSEG; j++){
- s = p->seg[j];
- if(s != nil)
- s->mark = 0;
- }
- }
- for(i=0; i<conf.nproc; i++){
- p = proctab(i);
- for(j=0; j<NSEG; j++){
- s = p->seg[j];
- if(s == nil || s->mark++)
- continue;
- if((s->type&SG_TYPE) == SG_PHYSICAL)
- continue;
- ns++;
- for(k=0; k<s->mapsize; k++){
- pte = s->map[k];
- if(pte == nil)
- continue;
- for(pg = pte->first; pg <= pte->last; pg++){
- entry = *pg;
- if(pagedout(entry))
- continue;
- if(print){
- if(ref[pagenumber(entry)])
- iprint("page %#p in segment %#p\n", entry->pa, s);
- continue;
- }
- if(ref[pagenumber(entry)]++ == 0)
- n++;
- }
- }
- }
- }
- if(!print){
- iprint("%lud pages in %lud segments\n", n, ns);
- for(i=0; i<conf.nproc; i++){
- p = proctab(i);
- for(j=0; j<NSEG; j++){
- s = p->seg[j];
- if(s == nil)
- continue;
- if(s->ref != s->mark){
- iprint("segment %#p (used by proc %lud pid %lud) has bad ref count %lud actual %lud\n",
- s, i, p->pid, s->ref, s->mark);
- }
- }
- }
- }
-}
-
--- a/sys/src/9/port/portfns.h
+++ b/sys/src/9/port/portfns.h
@@ -207,7 +207,6 @@
void pagechaindone(void);
void pagechainhead(Page*);
void pageinit(void);
-ulong pagenumber(Page*);
ulong pagereclaim(Image*, ulong);
void panic(char*, ...);
Cmdbuf* parsecmd(char *a, int n);
--- a/sys/src/9/port/sysproc.c
+++ b/sys/src/9/port/sysproc.c
@@ -9,15 +9,11 @@
#include <a.out.h>
-extern void checkpages(void);
-extern void checkpagerefs(void);
-
uintptr
sysr1(va_list)
{
if(!iseve())
error(Eperm);
- checkpagerefs();
return 0;
}
--- a/sys/src/9/ppc/mmu.c
+++ b/sys/src/9/ppc/mmu.c
@@ -255,11 +255,6 @@
{
}
-void
-countpagerefs(ulong*, int)
-{
-}
-
/*
* Return the number of bytes that can be accessed via KADDR(pa).
* If pa is not a valid argument to KADDR, return 0.
--- a/sys/src/9/sgi/mmu.c
+++ b/sys/src/9/sgi/mmu.c
@@ -461,11 +461,6 @@
{
}
-void
-countpagerefs(ulong*, int)
-{
-}
-
/*
* Return the number of bytes that can be accessed via KADDR(pa).
* If pa is not a valid argument to KADDR, return 0.
--- a/sys/src/9/xen/mmu.c
+++ b/sys/src/9/xen/mmu.c
@@ -509,16 +509,6 @@
}
/*
- * More debugging.
- */
-void
-countpagerefs(ulong *ref, int print)
-{
- USED(ref);
- USED(print);
-}
-
-/*
* Return the number of bytes that can be accessed via KADDR(pa).
* If pa is not a valid argument to KADDR, return 0.
*/
--- a/sys/src/9/zynq/mmu.c
+++ b/sys/src/9/zynq/mmu.c
@@ -242,12 +242,6 @@
proc->mmufree = nil;
}
-void
-countpagerefs(ulong *, int)
-{
- print("countpagerefs\n");
-}
-
uintptr
paddr(void *v)
{