Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Sep 2019 12:14:19 -0700
From:      Conrad Meyer <cem@freebsd.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>,  svn-src-head <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r352059 - head/sys/kern
Message-ID:  <CAG6CVpX6wo4zNi-OEUjQvWZCZ9FsEV0%2BCXt3ggw_n%2BO9wPPC6w@mail.gmail.com>
In-Reply-To: <20190909184805.GV2559@kib.kiev.ua>
References:  <201909091129.x89BTxvw061871@repo.freebsd.org> <CAG6CVpXyhxDc=D0ZWXoQeFPr6A3CrOK1MNeO7MVmjc4uVYTBvQ@mail.gmail.com> <20190909184805.GV2559@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks!

On Mon, Sep 9, 2019 at 11:48 AM Konstantin Belousov <kostikbel@gmail.com> w=
rote:
>
> On Mon, Sep 09, 2019 at 11:31:32AM -0700, Conrad Meyer wrote:
> > What=E2=80=99s the motivation for using more timehands?
> See the thread titled 'Is it a good idea to use a usb-serial adapter
> for PPS input? Yes, it is.' on arm@ and usb@. In short, there are some
> reports of timecounters misbehaving on single-core systems when only two
> timehands are enabled.
>
> The change eases the experimentation and provides a workaround which does
> not require modifying the sources to apply.
>
> >
> > On Mon, Sep 9, 2019 at 04:30 Konstantin Belousov <kib@freebsd.org> wrot=
e:
> >
> > > 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@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
> > >
> > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
> > > --- head/sys/kern/kern_tc.c     Mon Sep  9 11:22:38 2019        (r352=
058)
> > > +++ head/sys/kern/kern_tc.c     Mon Sep  9 11:29:58 2019        (r352=
059)
> > > @@ -83,19 +83,16 @@ struct timehands {
> > >         struct timehands        *th_next;
> > >  };
> > >
> > > -static struct timehands th0;
> > > -static struct timehands th1 =3D {
> > > -       .th_next =3D &th0
> > > -};
> > > -static struct timehands th0 =3D {
> > > +static struct timehands ths[16] =3D {
> > > +    [0] =3D  {
> > >         .th_counter =3D &dummy_timecounter,
> > >         .th_scale =3D (uint64_t)-1 / 1000000,
> > >         .th_offset =3D { .sec =3D 1 },
> > >         .th_generation =3D 1,
> > > -       .th_next =3D &th1
> > > +    },
> > >  };
> > >
> > > -static struct timehands *volatile timehands =3D &th0;
> > > +static struct timehands *volatile timehands =3D &ths[0];
> > >  struct timecounter *timecounter =3D &dummy_timecounter;
> > >  static struct timecounter *timecounters =3D &dummy_timecounter;
> > >
> > > @@ -115,6 +112,10 @@ static int timestepwarnings;
> > >  SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RW,
> > >      &timestepwarnings, 0, "Log time steps");
> > >
> > > +static int timehands_count =3D 2;
> > > +SYSCTL_INT(_kern_timecounter, OID_AUTO, timehands_count, CTLFLAG_RDT=
UN,
> > > +    &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 =3D 1;
> > > +       if (timehands_count > nitems(ths))
> > > +               timehands_count =3D nitems(ths);
> > > +       for (i =3D 1, thp =3D &ths[0]; i < timehands_count;  thp =3D =
&ths[i++])
> > > +               thp->th_next =3D &ths[i];
> > > +       thp->th_next =3D &ths[0];
> > > +
> > >         /* 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?CAG6CVpX6wo4zNi-OEUjQvWZCZ9FsEV0%2BCXt3ggw_n%2BO9wPPC6w>