Why is tc_get_timecount() called two times in tc_init()?
Warner Losh
imp at bsdimp.com
Thu Oct 3 15:10:30 UTC 2019
I think this is a good fix. I recall phk saying it was more paranoia for
edge cases than really needed in a private email to me, but it's in the
'gap' of email that I lost in a disk crash 12 years ago so I can't find it
for sure.
Warner
On Thu, Oct 3, 2019 at 2:40 AM Konstantin Belousov <kostikbel at gmail.com>
wrote:
> On Thu, Oct 03, 2019 at 03:12:26AM +1000, Bruce Evans wrote:
> > On Wed, 2 Oct 2019, Konstantin Belousov wrote:
> >
> > > On Thu, Oct 03, 2019 at 02:25:46AM +1000, Bruce Evans wrote:
> > >> On Wed, 2 Oct 2019, Konstantin Belousov wrote:
> > > So the conclusion is that the second call can be removed, am I right ?
> >
> > Yes.
> >
> > All tc_get_timecount() functions should be checked for doing sufficient
> > initialization in one call (so that deltas for subsequent calls are
> > correct).
>
> This should be it.
>
> But, is even a single call to tc_get_timecount() needed for "warmup" ?
>
> diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
> index 382d139617d..28d0d738a58 100644
> --- a/sys/dev/acpica/acpi.c
> +++ b/sys/dev/acpica/acpi.c
> @@ -3191,7 +3191,6 @@ acpi_resync_clock(struct acpi_softc *sc)
> * Warm up timecounter again and reset system clock.
> */
> (void)timecounter->tc_get_timecount(timecounter);
> - (void)timecounter->tc_get_timecount(timecounter);
> inittodr(time_second + sc->acpi_sleep_delay);
> }
>
> diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c
> index 34a832089a2..d768397a785 100644
> --- a/sys/dev/acpica/acpi_timer.c
> +++ b/sys/dev/acpica/acpi_timer.c
> @@ -274,7 +274,6 @@ acpi_timer_resume_handler(struct timecounter *newtc)
> "restoring timecounter, %s -> %s\n",
> tc->tc_name, newtc->tc_name);
> (void)newtc->tc_get_timecount(newtc);
> - (void)newtc->tc_get_timecount(newtc);
> timecounter = newtc;
> }
> }
> diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c
> index 98ab5bf3a6b..1e132f4d866 100644
> --- a/sys/dev/xen/control/control.c
> +++ b/sys/dev/xen/control/control.c
> @@ -303,7 +303,6 @@ xctrl_suspend()
> * Warm up timecounter again and reset system clock.
> */
> timecounter->tc_get_timecount(timecounter);
> - timecounter->tc_get_timecount(timecounter);
> inittodr(time_second);
>
> #ifdef EARLY_AP_STARTUP
> diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
> index 9920a9a9304..847fbbbf35d 100644
> --- a/sys/kern/kern_tc.c
> +++ b/sys/kern/kern_tc.c
> @@ -1257,7 +1257,6 @@ tc_init(struct timecounter *tc)
> tc->tc_frequency < timecounter->tc_frequency)
> return;
> (void)tc->tc_get_timecount(tc);
> - (void)tc->tc_get_timecount(tc);
> timecounter = tc;
> }
>
> @@ -1519,7 +1518,6 @@ sysctl_kern_timecounter_hardware(SYSCTL_HANDLER_ARGS)
>
> /* Warm up new timecounter. */
> (void)newtc->tc_get_timecount(newtc);
> - (void)newtc->tc_get_timecount(newtc);
>
> timecounter = newtc;
>
> @@ -2011,7 +2009,6 @@ inittimecounter(void *dummy)
>
> /* warm up new timecounter (again) and get rolling. */
> (void)timecounter->tc_get_timecount(timecounter);
> - (void)timecounter->tc_get_timecount(timecounter);
> mtx_lock_spin(&tc_setclock_mtx);
> tc_windup(NULL);
> mtx_unlock_spin(&tc_setclock_mtx);
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>
More information about the freebsd-hackers
mailing list