svn commit: r352059 - head/sys/kern
Conrad Meyer
cem at freebsd.org
Mon Sep 9 18:31:46 UTC 2019
What’s the motivation for using more timehands?
On Mon, Sep 9, 2019 at 04:30 Konstantin Belousov <kib at freebsd.org> wrote:
> Author: kib
> Date: Mon Sep 9 11:29:58 2019
> New Revision: 352059
> URL: https://svnweb.freebsd.org/changeset/base/352059
>
> Log:
> Make timehands count selectable at boottime.
>
> Tested by: O'Connor, Daniel <darius at dons.net.au>
> Sponsored by: The FreeBSD Foundation
> MFC after: 1 week
> Differential revision: https://reviews.freebsd.org/D21563
>
> Modified:
> head/sys/kern/kern_tc.c
>
> Modified: head/sys/kern/kern_tc.c
>
> ==============================================================================
> --- head/sys/kern/kern_tc.c Mon Sep 9 11:22:38 2019 (r352058)
> +++ head/sys/kern/kern_tc.c Mon Sep 9 11:29:58 2019 (r352059)
> @@ -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,10 @@ 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,
> + &timehands_count, 0, "Count of timehands in rotation");
> +
> struct bintime bt_timethreshold;
> struct bintime bt_tickthreshold;
> sbintime_t sbt_timethreshold;
> @@ -1960,8 +1961,9 @@ done:
> static void
> inittimecounter(void *dummy)
> {
> + struct timehands *thp;
> u_int p;
> - int tick_rate;
> + int i, tick_rate;
>
> /*
> * Set the initial timeout to
> @@ -1987,6 +1989,16 @@ inittimecounter(void *dummy)
> #ifdef FFCLOCK
> ffclock_init();
> #endif
> +
> + /* Set up the requested number of timehands. */
> + 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];
> +
> /* warm up new timecounter (again) and get rolling. */
> (void)timecounter->tc_get_timecount(timecounter);
> (void)timecounter->tc_get_timecount(timecounter);
>
>
More information about the svn-src-head
mailing list