This commit is contained in:
Ori Bernstein 2019-12-08 11:58:19 -08:00
commit 36af840552
4 changed files with 35 additions and 30 deletions

View file

@ -643,10 +643,7 @@ vmapalloc(ulong size)
void void
vunmap(void *v, int size) vunmap(void *v, int size)
{ {
int i;
ulong va, o; ulong va, o;
Mach *nm;
Proc *p;
/* /*
* might not be aligned * might not be aligned
@ -675,25 +672,8 @@ vunmap(void *v, int size)
putcr3(PADDR(MACHP(0)->pdb)); putcr3(PADDR(MACHP(0)->pdb));
return; return;
} }
for(i=0; i<conf.nproc; i++){ procflushothers();
p = proctab(i);
if(p->state == Dead)
continue;
if(p != up)
p->newtlb = 1;
}
for(i=0; i<conf.nmach; i++){
nm = MACHP(i);
if(nm != m)
nm->flushmmu = 1;
}
flushmmu(); flushmmu();
for(i=0; i<conf.nmach; i++){
nm = MACHP(i);
if(nm != m)
while(active.machs[nm->machno] && nm->flushmmu)
;
}
} }
/* /*

View file

@ -148,7 +148,7 @@ hzclock(Ureg *ur)
m->proc->pc = ur->pc; m->proc->pc = ur->pc;
if(m->flushmmu){ if(m->flushmmu){
if(up) if(up && up->newtlb)
flushmmu(); flushmmu();
m->flushmmu = 0; m->flushmmu = 0;
} }

View file

@ -229,6 +229,7 @@ void procdump(void);
int procfdprint(Chan*, int, char*, int); int procfdprint(Chan*, int, char*, int);
void procflushseg(Segment*); void procflushseg(Segment*);
void procflushpseg(Physseg*); void procflushpseg(Physseg*);
void procflushothers(void);
int procindex(ulong); int procindex(ulong);
void procinit0(void); void procinit0(void);
ulong procpagecount(Proc*); ulong procpagecount(Proc*);

View file

@ -1331,12 +1331,14 @@ procdump(void)
static void static void
procflushmmu(int (*match)(Proc*, void*), void *a) procflushmmu(int (*match)(Proc*, void*), void *a)
{ {
Proc *await[MAXMACH];
int i, nm, nwait; int i, nm, nwait;
Proc *p; Proc *p;
/* /*
* tell all matching processes to flush their mmu's * tell all matching processes to flush their mmu's
*/ */
memset(await, 0, conf.nmach*sizeof(await[0]));
nwait = 0; nwait = 0;
for(i = 0; i < conf.nproc; i++){ for(i = 0; i < conf.nproc; i++){
p = &procalloc.arena[i]; p = &procalloc.arena[i];
@ -1344,23 +1346,34 @@ procflushmmu(int (*match)(Proc*, void*), void *a)
p->newtlb = 1; p->newtlb = 1;
for(nm = 0; nm < conf.nmach; nm++){ for(nm = 0; nm < conf.nmach; nm++){
if(MACHP(nm)->proc == p){ if(MACHP(nm)->proc == p){
coherence();
MACHP(nm)->flushmmu = 1; MACHP(nm)->flushmmu = 1;
if(await[nm] == nil)
nwait++; nwait++;
await[nm] = p;
} }
} }
} }
} }
if(nwait == 0)
return;
/* /*
* wait for all other processors to take a clock interrupt * wait for all other processors to take a clock interrupt
* and flush their mmu's * and flush their mmu's
*/ */
for(nm = 0; nm < conf.nmach; nm++) for(;;){
while(m->machno != nm && MACHP(nm)->flushmmu) if(nwait == 0 || nwait == 1 && await[m->machno] != nil)
break;
sched(); sched();
for(nm = 0; nm < conf.nmach; nm++){
p = await[nm];
if(p != nil && (MACHP(nm)->proc != p || MACHP(nm)->flushmmu == 0)){
await[nm] = nil;
nwait--;
}
}
}
} }
static int static int
@ -1399,6 +1412,17 @@ procflushpseg(Physseg *ps)
procflushmmu(matchpseg, ps); procflushmmu(matchpseg, ps);
} }
static int
matchother(Proc *p, void *a)
{
return p != a;
}
void
procflushothers(void)
{
procflushmmu(matchother, up);
}
void void
scheddump(void) scheddump(void)
{ {