Re: TSC as timecounter makes system lag

From: Jia-Shiun Li <jiashiun_at_gmail.com>
Date: Fri, 24 Feb 2017 12:15:26 +0800
On Fri, Feb 24, 2017 at 12:55 AM, John Baldwin <jhb_at_freebsd.org> wrote:

> On Thursday, February 23, 2017 11:04:58 PM Jia-Shiun Li wrote:
> >
> >
> > This does not work.
> >
> > I added a printf before the outer if clause, and it says
> >
> > init_TSC_tc:546: deepest 00000000 vendor 00008086 amd_pminfo 00000000
> >
> > full boot dmesg attached. Looks init_TSC_tc() is called too early before
> > acpi_cpu_attach() initializing cpu_deepest_sleep. Maybe it should be put
> > after
> > driver initialization, since it depends on probed ACPI C states?
>
> We don't actually need cpu_deepest_sleep.  We could just set C2STOP always.
> It doesn't hurt to have the flag set if the system only supports C1 except
> that you get the printf in a verbose boot.
>
> Try this slight variation of Konstantin's patch.  If this works we can
> remove
> cpu_deepest_sleep entirely as a followup since it will no longer be used:
>
> Index: tsc.c
> ===================================================================
> --- tsc.c       (revision 314113)
> +++ tsc.c       (working copy)
> _at__at_ -542,9 +542,11 _at__at_ init_TSC_tc(void)
>          * result incorrect runtimes for kernel idle threads (but not
>          * for any non-idle threads).
>          */
> -       if (cpu_deepest_sleep >= 2 && cpu_vendor_id == CPU_VENDOR_INTEL &&
> +       if (cpu_vendor_id == CPU_VENDOR_INTEL &&
>             (amd_pminfo & AMDPM_TSC_INVARIANT) == 0) {
>                 tsc_timecounter.tc_flags |= TC_FLAGS_C2STOP;
> +               if (timecounter == &tsc_timecounter)
> +                       cpu_disable_c2_sleep++;
>                 if (bootverbose)
>                         printf("TSC timecounter disables C2 and C3.\n");
>         }
>

Tested working on E7400 against r313909. And changing timecounter from/to
TSC
correctly enables/disables C2.

The latter part cpu_disable_c2_sleep++ is not needed. When
init_TSC_tc() got called timecounter is not yet tsc_timecounter.
inittimecounter() later will do the work calling tc_windup().


-Jia-Shiun.
Received on Fri Feb 24 2017 - 03:15:57 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:10 UTC