> Date: Sun, 25 Aug 2019 18:55:50 +0200
> From: prx <[email protected]>
> 
> Hi,
> Patch applied.
> After a ``reboot``, everything seems fine.
> Then I shut down the system with "shutdown -hp now". After a few minute,
> I restart the computer, and the issue is still here.
> 

Here is a diff that might make more of a difference.

It isn't entirely clear what causes the non-primary CPUs to show that
bogus clock frequency.  And this diff probably won't help fixing that.
But it should stop is from going through the timecounter
initialization logic multiple times with a wrong CPU clock frequency.

This diff isn't quite right yet.  The drift stuff is effectively
bypassed this way.  But it doesn't work with the current code either
since changing the quality of a timecounter after tc_init() has been
called is pointless.

Can you test this diff on your machine?


Index: arch/amd64/amd64/tsc.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/amd64/tsc.c,v
retrieving revision 1.13
diff -u -p -r1.13 tsc.c
--- arch/amd64/amd64/tsc.c      9 Aug 2019 15:20:05 -0000       1.13
+++ arch/amd64/amd64/tsc.c      25 Aug 2019 20:59:47 -0000
@@ -216,7 +216,11 @@ tsc_get_timecount(struct timecounter *tc
 void
 tsc_timecounter_init(struct cpu_info *ci, uint64_t cpufreq)
 {
-       if (!(ci->ci_flags & CPUF_CONST_TSC) ||
+       printf("%s: TSC skew=%lld observed drift=%lld\n", __func__,
+           (long long)ci->ci_tsc_skew, (long long)tsc_drift_observed);
+
+       if (!(ci->ci_flags & CPUF_PRIMARY) ||
+           !(ci->ci_flags & CPUF_CONST_TSC) ||
            !(ci->ci_flags & CPUF_INVAR_TSC))
                return;
 
@@ -241,11 +245,7 @@ tsc_timecounter_init(struct cpu_info *ci
                tsc_is_invariant = 0;
        }
 
-       printf("%s: TSC skew=%lld observed drift=%lld\n", __func__,
-           (long long)ci->ci_tsc_skew, (long long)tsc_drift_observed);
-
-       if (ci->ci_flags & CPUF_PRIMARY)
-               tc_init(&tsc_timecounter);
+       tc_init(&tsc_timecounter);
 }
 
 /*


Reply via email to