Index: sys/kern/kern_tc.c =================================================================== --- sys/kern/kern_tc.c +++ sys/kern/kern_tc.c @@ -84,10 +84,27 @@ struct timehands *th_next; }; -static struct timehands th0; -static struct timehands th1 = { - .th_next = &th0 +#define TH(curr, next) \ +static struct timehands th##next; \ +static struct timehands th##curr = { \ + .th_next = &th##next \ }; +TH(1, 2); +TH(2, 3); +TH(3, 4); +TH(4, 5); +TH(5, 6); +TH(6, 7); +TH(7, 8); +TH(8, 9); +TH(9, 10); +TH(10, 11); +TH(11, 12); +TH(12, 13); +TH(13, 14); +TH(14, 15); +TH(15, 0); +#undef TH static struct timehands th0 = { .th_counter = &dummy_timecounter, .th_scale = (uint64_t)-1 / 1000000, @@ -117,6 +134,10 @@ SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RW, ×tepwarnings, 0, "Log time steps"); +static int timehands_count = 2; +SYSCTL_INT(_kern_timecounter, OID_AUTO, timehands_count, CTLFLAG_RDTUN, + &timehands_count, 0, "Count of timehands in rotation"); + struct bintime bt_timethreshold; struct bintime bt_tickthreshold; sbintime_t sbt_timethreshold; @@ -1902,8 +1923,9 @@ static void inittimecounter(void *dummy) { + struct timehands *thp; u_int p; - int tick_rate; + int i, tick_rate; /* * Set the initial timeout to @@ -1929,6 +1951,16 @@ #ifdef FFCLOCK ffclock_init(); #endif + + /* Set up the requested number of timehands. */ + if (timehands_count < 1) + timehands_count = 1; + if (timehands_count > 16) + timehands_count = 16; + for (i = 1, thp = &th0; i < timehands_count; i++, thp = thp->th_next) + ; + thp->th_next = &th0; + /* warm up new timecounter (again) and get rolling. */ (void)timecounter->tc_get_timecount(timecounter); (void)timecounter->tc_get_timecount(timecounter);