Date: Mon, 16 Sep 2019 06:15:23 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r352380 - stable/12/sys/kern Message-ID: <201909160615.x8G6FN1U096263@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Mon Sep 16 06:15:22 2019 New Revision: 352380 URL: https://svnweb.freebsd.org/changeset/base/352380 Log: MFC r352059, r352060: Make timehands count selectable at boottime. Modified: stable/12/sys/kern/kern_tc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/kern_tc.c ============================================================================== --- stable/12/sys/kern/kern_tc.c Mon Sep 16 06:13:29 2019 (r352379) +++ stable/12/sys/kern/kern_tc.c Mon Sep 16 06:15:22 2019 (r352380) @@ -83,19 +83,16 @@ struct timehands { struct timehands *th_next; }; -static struct timehands th0; -static struct timehands th1 = { - .th_next = &th0 -}; -static struct timehands th0 = { +static struct timehands ths[16] = { + [0] = { .th_counter = &dummy_timecounter, .th_scale = (uint64_t)-1 / 1000000, .th_offset = { .sec = 1 }, .th_generation = 1, - .th_next = &th1 + }, }; -static struct timehands *volatile timehands = &th0; +static struct timehands *volatile timehands = &ths[0]; struct timecounter *timecounter = &dummy_timecounter; static struct timecounter *timecounters = &dummy_timecounter; @@ -115,6 +112,11 @@ static int timestepwarnings; 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 | CTLFLAG_NOFETCH, + &timehands_count, 0, "Count of timehands in rotation"); + struct bintime bt_timethreshold; struct bintime bt_tickthreshold; sbintime_t sbt_timethreshold; @@ -1956,7 +1958,26 @@ done: return (0); } +/* Set up the requested number of timehands. */ static void +inittimehands(void *dummy) +{ + struct timehands *thp; + int i; + + TUNABLE_INT_FETCH("kern.timecounter.timehands_count", + &timehands_count); + if (timehands_count < 1) + timehands_count = 1; + if (timehands_count > nitems(ths)) + timehands_count = nitems(ths); + for (i = 1, thp = &ths[0]; i < timehands_count; thp = &ths[i++]) + thp->th_next = &ths[i]; + thp->th_next = &ths[0]; +} +SYSINIT(timehands, SI_SUB_TUNABLES, SI_ORDER_ANY, inittimehands, NULL); + +static void inittimecounter(void *dummy) { u_int p; @@ -1986,6 +2007,7 @@ inittimecounter(void *dummy) #ifdef FFCLOCK ffclock_init(); #endif + /* warm up new timecounter (again) and get rolling. */ (void)timecounter->tc_get_timecount(timecounter); (void)timecounter->tc_get_timecount(timecounter);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909160615.x8G6FN1U096263>