Index: sys/kern/kern_synch.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_synch.c,v retrieving revision 1.309 diff -p -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 8 Nov 2015 23:16:19 -0000 @@ -453,6 +453,31 @@ updatertime(lwp_t *l, const struct binti if (__predict_false(l->l_flag & LW_IDLE)) return; +#if defined(__sparc__) + { + /* + * "now - stime" becomes negative sometimes, which it shouldn't. + * try to figure out where it comes from, because we don't ever + * add a negative value from the timecounter side. + */ + struct bintime delta = *now; + bintime_sub(&delta, &l->l_stime); + if (delta.sec < 0) { + log(LOG_DEBUG, "cpu%u: (%u.%u:%s) " + "delta.sec = %lld, delta.frac = %llu, " + "now.sec = %lld, now.frac = %llu, " + "l_stime.sec = %lld, l_stime.frac = %llu, " + "RA = %p\n", + cpu_number(), l->l_proc->p_pid, l->l_lid, + l->l_name ? l->l_name : l->l_proc->p_comm, + (long long)delta.sec, (unsigned long long)delta.frac, + (long long)now->sec, (unsigned long long)now->frac, + (long long)l->l_stime.sec, + (unsigned long long)l->l_stime.frac, + __builtin_return_address(0)); + } + } +#endif /* rtime += now - stime */ bintime_add(&l->l_rtime, now); bintime_sub(&l->l_rtime, &l->l_stime); Index: sys/kern/kern_tc.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_tc.c,v retrieving revision 1.46 diff -p -u -r1.46 kern_tc.c --- sys/kern/kern_tc.c 14 Sep 2013 20:52:43 -0000 1.46 +++ sys/kern/kern_tc.c 8 Nov 2015 23:16:19 -0000 @@ -739,6 +739,12 @@ tc_windup(void) ncount = 0; th->th_offset_count += delta; bintime_addx(&th->th_offset, th->th_scale * delta); +#ifdef __sparc__ +if (delta & 0x80000000) + log(LOG_DEBUG, "cpu%u: (%u.%u:%s) tc_delta() gave: %x (th_offset_count now %llx)\n", + cpu_number(), curlwp->l_proc->p_pid, curlwp->l_lid, curlwp->l_name ? curlwp->l_name : curlwp->l_proc->p_comm, + delta, (unsigned long long)th->th_offset_count); +#endif /* * Hardware latching timecounters may not generate interrupts on