Index: sys/sys/callout.h =================================================================== --- sys/sys/callout.h (revision 242924) +++ sys/sys/callout.h (working copy) @@ -51,19 +51,24 @@ #define CALLOUT_DIRECT 0x0100 /* allow exec from hw int context */ #define C_DIRECT_EXEC 0x0001 /* direct execution of callout */ -#define C_PRECISIONBITS 24 -#define C_PRECISIONRANGE ((1 << C_PRECISIONBITS) - 1) -#define C_PRECISIONMASK (1 << ((32 - C_PRECISIONBITS) - 1)) -#define C_US2PREC(x) (((x) * 4294) & C_PRECISIONMASK) -#define C_BT2PREC(x) (((x) >> 32) & C_PRECISIONMASK) -#define C_PREC2BT(x) ((uint64_t)(flags & C_PRECISIONMASK) << 32) +#define C_PABSBITS 24 +#define C_PABSMASK (~((1 << (32 - C_PABSBITS)) - 1)) +#define C_PABSRANGE ((1 << C_PABSBITS) - 1) +#define C_BT2PABS(x) ((x) >> 40) +#define C_SETPABS(x) (((x) & C_PABSRANGE) << 8) +#define C_US2PABS(x) (((x) * 4294) & ~C_PABSMASK) +#define C_PABS2BT(x) ((uint64_t)(flags & C_PABSMASK) << 32) +#define C_PRELBITS 5 +#define C_PRELRANGE ((1 << C_PRELBITS) - 1) +#define C_PRELSET (((x) & C_PRELRANGE) << 1) +#define C_PRELGET(x) (((x) >> 1) & C_PRELRANGE) /* * Common values specified for precision. */ -#define C_P1MS C_US2PREC(1000) -#define C_P10MS C_US2PREC(10000) -#define C_P100MS C_US2PREC(100000) +#define C_P1MS C_US2PABS(1000) +#define C_P10MS C_US2PABS(10000) +#define C_P100MS C_US2PABS(100000) struct callout_handle { struct callout *callout; Index: sys/sys/time.h =================================================================== --- sys/sys/time.h (revision 242942) +++ sys/sys/time.h (working copy) @@ -58,6 +58,8 @@ struct bintime { extern int tc_timethreshold; extern struct bintime tick_bt; +#define TC_DEFAULTPERC 5 + #define FREQ2BT(freq, bt) \ { \ (bt)->sec = 0; \ Index: sys/kern/kern_tc.c =================================================================== --- sys/kern/kern_tc.c (revision 242942) +++ sys/kern/kern_tc.c (working copy) @@ -120,9 +120,10 @@ SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnin ×tepwarnings, 0, "Log time steps"); int tc_timethreshold; +int tc_timepercentage; struct bintime tick_bt; -SYSCTL_INT(_kern, OID_AUTO, tc_timethreshold, CTLFLAG_RW, - &tc_timethreshold, 0, "Precision threshold for timing measurements"); +SYSCTL_INT(_kern, OID_AUTO, tc_timepercentage, CTLFLAG_RW, + &tc_timepercentage, 0, "Precision percentage tolerance"); static void tc_windup(void); static void cpu_tick_calibrate(int); @@ -1728,10 +1729,10 @@ inittimecounter(void *dummy) tc_tick = (hz + 500) / 1000; else tc_tick = 1; + tick_rate = hz / tc_tick; + tc_timethreshold = (100 / tc_timepercentage) * (1000000000 / tick_rate); + FREQ2BT(tick_rate, &tick_bt); p = (tc_tick * 1000000) / hz; - tc_timethreshold = 20 * imin(1000000000 / hz, 1000000); - tick_rate = imax(hz, tc_tick); - FREQ2BT(tick_rate, &tick_bt); printf("Timecounters tick every %d.%03u msec\n", p / 1000, p % 1000); #ifdef FFCLOCK Index: sys/kern/kern_timeout.c =================================================================== --- sys/kern/kern_timeout.c (revision 242942) +++ sys/kern/kern_timeout.c (working copy) @@ -583,7 +583,7 @@ callout_cc_add(struct callout *c, struct callout_c c->c_func = func; c->c_time = to_bintime; bintime_clear(&c->c_precision); - r_val = C_PREC2BT(flags); + r_val = C_PABS2BT(flags); c->c_precision.frac = r_val; CTR3(KTR_CALLOUT, "precision set for %p: 0.%08x%08", c, (u_int) (r_val >> 32), (u_int) (r_val & 0xffffffff));