Index: sys/kern/kern_synch.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_synch.c,v retrieving revision 1.309 diff -u -r1.309 kern_synch.c --- sys/kern/kern_synch.c 13 Oct 2015 00:25:51 -0000 1.309 +++ sys/kern/kern_synch.c 5 Mar 2016 20:51:16 -0000 @@ -277,6 +277,7 @@ KASSERT(lwp_locked(l, l->l_cpu->ci_schedstate.spc_lwplock)); KASSERT(l->l_stat == LSONPROC); l->l_kpriority = false; + /*printf("yield() before mi_switch()\n"); */ (void)mi_switch(l); KERNEL_LOCK(l->l_biglocks, l); } @@ -296,6 +297,7 @@ KASSERT(l->l_stat == LSONPROC); l->l_kpriority = false; l->l_nivcsw++; + /*printf("preempt() before mi_switch()\n");*/ (void)mi_switch(l); KERNEL_LOCK(l->l_biglocks, l); } @@ -376,6 +378,7 @@ kpreempt_ev_immed.ev_count++; } lwp_lock(l); + /*printf("kpreempt() before mi_switch()\n");*/ mi_switch(l); l->l_nopreempt++; splx(s); @@ -506,6 +509,9 @@ int mi_switch(lwp_t *l) { +#if 1 +printf("mi_switch() %p (%s)\n", (void*)l, l->l_name); +#endif struct cpu_info *ci; struct schedstate_percpu *spc; struct lwp *newl; @@ -716,7 +722,38 @@ KASSERT(curlwp == ci->ci_curlwp); #endif KASSERTMSG(l == curlwp, "l %p curlwp %p", l, curlwp); +#if 1 +printf("mi_switch() %p before cpu_switchto() from %s to %s\n", (void*)newl, l->l_name, newl->l_name); +#endif +#if 1 + struct pcb* opcb = (struct pcb*)l->l_addr; +printf("mi_switch() l->l_pcb %p\n", (void*)opcb); + struct pcb* pcb = (struct pcb*)newl->l_addr; +printf("mi_switch() newl->l_pcb %p\n", (void*)pcb); +#if 0 + unsigned char* tmp = (unsigned char*)pcb; + for (int i=0; i < USPACE; i++) { + if ( i % 32 == 0 ) + printf("\n%p ", (void*)(tmp+i)); + printf("%02x ", tmp[i]); + } + printf("\n"); +#endif +printf("mi_switch() newl->l_pcb->pcb_sp %lx\n", (long unsigned int)pcb->pcb_sp); +printf("mi_switch() newl->l_pcb->pcb_pc %lx\n", (long unsigned int)pcb->pcb_pc); +#if 0 + Debugger(); +#endif +#endif prevlwp = cpu_switchto(l, newl, returning); +#if 0 +#if 1 + Debugger(); +#endif +#if 0 +printf("mi_switch() %p after cpu_switchto()\n", (void*)newl); +#endif +#endif ci = curcpu(); #ifdef MULTIPROCESSOR KASSERT(curlwp == ci->ci_curlwp); @@ -729,8 +766,8 @@ * Restore VM context and IPL. */ pmap_activate(l); - uvm_emap_switch(l); - pcu_switchpoint(l); + uvm_emap_switch(l); /* FIXME check this for sun4v */ + pcu_switchpoint(l); /* FIXME check this for sun4v */ if (prevlwp != NULL) { /* Normalize the count of the spin-mutexes */