diff -r 50813cd186d3 sys/src/9/port/proc.c --- a/sys/src/9/port/proc.c Wed Dec 04 22:04:12 2019 +0100 +++ b/sys/src/9/port/proc.c Thu Dec 05 00:32:32 2019 +0100 @@ -1331,12 +1331,14 @@ static void procflushmmu(int (*match)(Proc*, void*), void *a) { + char await[MAXMACH]; int i, nm, nwait; Proc *p; /* * tell all matching processes to flush their mmu's */ + memset(await, 0, conf.nmach); nwait = 0; for(i=0; iproc == p){ MACHP(nm)->flushmmu = 1; - nwait++; + if(await[nm] == 0){ + await[nm] = 1; + nwait++; + } } } } } - if(nwait == 0) - return; - /* * wait for all other processors to take a clock interrupt * and flush their mmu's */ - for(nm = 0; nm < conf.nmach; nm++) - while(m->machno != nm && MACHP(nm)->flushmmu) - sched(); + for(;;){ + if(nwait == 0 || nwait == 1 && await[m->machno]) + break; + + sched(); + + for(nm = 0; nm < conf.nmach; nm++){ + if(await[nm] && MACHP(nm)->flushmmu == 0){ + await[nm] = 0; + nwait--; + } + } + } } static int