kernel: get rid of checkpagerefs() debugging

was only implemented by the pc kernel. does not
account pages used by the mount cache.
This commit is contained in:
cinap_lenrek 2019-05-01 12:40:27 +02:00
parent b452f8857f
commit fe594760eb
9 changed files with 0 additions and 158 deletions

View file

@ -229,11 +229,6 @@ checkmmu(uintptr, uintptr)
{
}
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.

View file

@ -468,12 +468,6 @@ cankaddr(uintptr pa)
return -KZERO - pa;
}
void
countpagerefs(ulong *ref, int print)
{
USED(ref, print);
}
KMap*
kmap(Page *page)
{

View file

@ -399,119 +399,3 @@ freepte(Segment *s, Pte *p)
}
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);
}
}
}
}
}

View file

@ -207,7 +207,6 @@ Block* padblock(Block*, int);
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);

View file

@ -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;
}

View file

@ -255,11 +255,6 @@ checkmmu(uintptr, uintptr)
{
}
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.

View file

@ -461,11 +461,6 @@ checkmmu(ulong, ulong)
{
}
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.

View file

@ -508,16 +508,6 @@ mmukmapsync(ulong va)
return 0;
}
/*
* 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.

View file

@ -242,12 +242,6 @@ mmurelease(Proc *proc)
proc->mmufree = nil;
}
void
countpagerefs(ulong *, int)
{
print("countpagerefs\n");
}
uintptr
paddr(void *v)
{