Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86 x86: Reset cached tsc in every lwp to 0 on susp...



details:   https://anonhg.NetBSD.org/src/rev/3d053fba87c5
branches:  trunk
changeset: 1021501:3d053fba87c5
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Jun 01 21:29:24 2021 +0000

description:
x86: Reset cached tsc in every lwp to 0 on suspend/resume.

This avoids spuriously warning about tsc going backwards, which is to
be expected after a suspend/resume cycle.

diffstat:

 sys/arch/x86/acpi/acpi_wakeup.c |   5 +++--
 sys/arch/x86/x86/tsc.c          |  19 +++++++++++++++++--
 sys/arch/x86/x86/tsc.h          |   8 +++++++-
 3 files changed, 27 insertions(+), 5 deletions(-)

diffs (89 lines):

diff -r 64599107b3cf -r 3d053fba87c5 sys/arch/x86/acpi/acpi_wakeup.c
--- a/sys/arch/x86/acpi/acpi_wakeup.c   Tue Jun 01 21:27:36 2021 +0000
+++ b/sys/arch/x86/acpi/acpi_wakeup.c   Tue Jun 01 21:29:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_wakeup.c,v 1.53 2020/05/21 21:12:30 ad Exp $      */
+/*     $NetBSD: acpi_wakeup.c,v 1.54 2021/06/01 21:29:24 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2002, 2011 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.53 2020/05/21 21:12:30 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.54 2021/06/01 21:29:24 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -341,6 +341,7 @@
         */
 
        /* We just woke up (cpu0), execution is resumed here */
+       tsc_tc_reset();
        cpu_init_msrs(&cpu_info_primary, false);
        fpuinit(&cpu_info_primary);
        if (rcr4() & CR4_OSXSAVE)
diff -r 64599107b3cf -r 3d053fba87c5 sys/arch/x86/x86/tsc.c
--- a/sys/arch/x86/x86/tsc.c    Tue Jun 01 21:27:36 2021 +0000
+++ b/sys/arch/x86/x86/tsc.c    Tue Jun 01 21:29:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tsc.c,v 1.54 2021/02/19 02:15:58 christos Exp $        */
+/*     $NetBSD: tsc.c,v 1.55 2021/06/01 21:29:24 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.54 2021/02/19 02:15:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.55 2021/06/01 21:29:24 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -440,3 +440,18 @@
        return cpu_counter32();
 #endif
 }
+
+/*
+ * tsc has been reset; zero the cached tsc of every lwp in the system
+ * so we don't spuriously report that the tsc has gone backward.
+ * Caller must ensure all LWPs are quiescent (except the current one,
+ * obviously) and interrupts are blocked while we update this.
+ */
+void
+tsc_tc_reset(void)
+{
+       struct lwp *l;
+
+       LIST_FOREACH(l, &alllwp, l_list)
+               l->l_md.md_tsc = 0;
+}
diff -r 64599107b3cf -r 3d053fba87c5 sys/arch/x86/x86/tsc.h
--- a/sys/arch/x86/x86/tsc.h    Tue Jun 01 21:27:36 2021 +0000
+++ b/sys/arch/x86/x86/tsc.h    Tue Jun 01 21:29:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tsc.h,v 1.7 2020/06/15 09:09:24 msaitoh Exp $  */
+/*     $NetBSD: tsc.h,v 1.8 2021/06/01 21:29:24 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -26,6 +26,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef        _X86_TSC_H_
+#define        _X86_TSC_H_
+
 bool   tsc_is_invariant(void);
 void   tsc_setfunc(struct cpu_info *);
 void   tsc_tc_init(void);
@@ -34,3 +37,6 @@
 void   tsc_sync_drift(int64_t);
 void   tsc_user_enable(void);
 void   tsc_user_disable(void);
+void   tsc_tc_reset(void);
+
+#endif /* _X86_TSC_H_ */



Home | Main Index | Thread Index | Old Index