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 When computing TSC skew make 8 measurements...



details:   https://anonhg.NetBSD.org/src/rev/fde94fd533b8
branches:  trunk
changeset: 1009461:fde94fd533b8
user:      ad <ad%NetBSD.org@localhost>
date:      Thu Apr 23 20:38:33 2020 +0000

description:
When computing TSC skew make 8 measurements and use the average.

diffstat:

 sys/arch/x86/x86/tsc.c |  20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diffs (54 lines):

diff -r 3dd389368fbf -r fde94fd533b8 sys/arch/x86/x86/tsc.c
--- a/sys/arch/x86/x86/tsc.c    Thu Apr 23 20:33:57 2020 +0000
+++ b/sys/arch/x86/x86/tsc.c    Thu Apr 23 20:38:33 2020 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: tsc.c,v 1.41 2020/04/21 02:56:37 msaitoh Exp $ */
+/*     $NetBSD: tsc.c,v 1.42 2020/04/23 20:38:33 ad Exp $      */
 
 /*-
- * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.41 2020/04/21 02:56:37 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.42 2020/04/23 20:38:33 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -229,13 +229,17 @@
 void
 tsc_sync_bp(struct cpu_info *ci)
 {
-       uint64_t bptsc, aptsc;
+       int64_t bptsc, aptsc, bsum = 0, asum = 0;
 
        tsc_read_bp(ci, &bptsc, &aptsc); /* discarded - cache effects */
-       tsc_read_bp(ci, &bptsc, &aptsc);
+       for (int i = 0; i < 8; i++) {
+               tsc_read_bp(ci, &bptsc, &aptsc);
+               bsum += bptsc;
+               asum += aptsc;
+       }
 
        /* Compute final value to adjust for skew. */
-       ci->ci_data.cpu_cc_skew = bptsc - aptsc;
+       ci->ci_data.cpu_cc_skew = (bsum - asum) >> 3;
 }
 
 /*
@@ -270,7 +274,9 @@
 {
 
        tsc_post_ap(ci);
-       tsc_post_ap(ci);
+       for (int i = 0; i < 8; i++) {
+               tsc_post_ap(ci);
+       }
 }
 
 static void



Home | Main Index | Thread Index | Old Index