Index: kern/kern_synch.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_synch.c,v retrieving revision 1.308 diff -p -r1.308 kern_synch.c *** kern/kern_synch.c 28 Feb 2014 10:16:51 -0000 1.308 --- kern/kern_synch.c 29 Jan 2015 02:55:55 -0000 *************** updatertime(lwp_t *l, const struct binti *** 453,458 **** --- 453,483 ---- 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: kern/kern_tc.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_tc.c,v retrieving revision 1.46 diff -p -r1.46 kern_tc.c *** kern/kern_tc.c 14 Sep 2013 20:52:43 -0000 1.46 --- kern/kern_tc.c 29 Jan 2015 02:55:55 -0000 *************** tc_windup(void) *** 739,744 **** --- 739,750 ---- 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