Source-Changes-HG archive

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

[src/trunk]: src/sys Use microsecond rather than nanosecond resolution when s...



details:   https://anonhg.NetBSD.org/src/rev/911c8db1e7d5
branches:  trunk
changeset: 770610:911c8db1e7d5
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Tue Oct 25 11:35:49 2011 +0000

description:
Use microsecond rather than nanosecond resolution when sampling latencies.

diffstat:

 sys/kern/subr_cpufreq.c |  20 ++++++++++----------
 sys/sys/cpufreq.h       |   6 +++---
 2 files changed, 13 insertions(+), 13 deletions(-)

diffs (84 lines):

diff -r c36e8c72a414 -r 911c8db1e7d5 sys/kern/subr_cpufreq.c
--- a/sys/kern/subr_cpufreq.c   Tue Oct 25 09:33:55 2011 +0000
+++ b/sys/kern/subr_cpufreq.c   Tue Oct 25 11:35:49 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_cpufreq.c,v 1.5 2011/10/20 06:48:24 jruoho Exp $ */
+/*     $NetBSD: subr_cpufreq.c,v 1.6 2011/10/25 11:35:49 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_cpufreq.c,v 1.5 2011/10/20 06:48:24 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cpufreq.c,v 1.6 2011/10/25 11:35:49 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -156,7 +156,7 @@
 cpufreq_latency(void)
 {
        struct cpufreq *cf = cf_backend;
-       struct timespec nta, ntb;
+       struct timeval nta, ntb;
        const uint32_t n = 10;
        uint32_t i, j, l, m;
        uint64_t s;
@@ -182,22 +182,22 @@
                                cpufreq_set_all_raw(m);
                        }
 
-                       nta.tv_sec = nta.tv_nsec = 0;
-                       ntb.tv_sec = ntb.tv_nsec = 0;
+                       nta.tv_sec = nta.tv_usec = 0;
+                       ntb.tv_sec = ntb.tv_usec = 0;
 
-                       nanotime(&nta);
+                       microtime(&nta);
                        cpufreq_set_all_raw(cf->cf_state[i].cfs_freq);
-                       nanotime(&ntb);
-                       timespecsub(&ntb, &nta, &ntb);
+                       microtime(&ntb);
+                       timersub(&ntb, &nta, &ntb);
 
                        if (ntb.tv_sec != 0 ||
-                           ntb.tv_nsec > CPUFREQ_LATENCY_MAX)
+                           ntb.tv_usec > CPUFREQ_LATENCY_MAX)
                                continue;
 
                        if (s >= UINT64_MAX - CPUFREQ_LATENCY_MAX)
                                break;
 
-                       s += ntb.tv_nsec;
+                       s += ntb.tv_usec;
                }
 
                /*
diff -r c36e8c72a414 -r 911c8db1e7d5 sys/sys/cpufreq.h
--- a/sys/sys/cpufreq.h Tue Oct 25 09:33:55 2011 +0000
+++ b/sys/sys/cpufreq.h Tue Oct 25 11:35:49 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufreq.h,v 1.3 2011/09/30 04:01:21 jruoho Exp $ */
+/*     $NetBSD: cpufreq.h,v 1.4 2011/10/25 11:35:49 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
 
 #define CPUFREQ_NAME_MAX        16
 #define CPUFREQ_STATE_MAX       32
-#define CPUFREQ_LATENCY_MAX     UINT16_MAX       /* Maximum per-CPU latency */
+#define CPUFREQ_LATENCY_MAX     UINT16_MAX
 
 #define CPUFREQ_STATE_ENABLED   UINT32_MAX
 #define CPUFREQ_STATE_DISABLED  UINT32_MAX - 1
@@ -52,7 +52,7 @@
 struct cpufreq_state {
        uint32_t                 cfs_freq;        /* MHz  */
        uint32_t                 cfs_power;       /* mW   */
-       uint32_t                 cfs_latency;     /* nsec */
+       uint32_t                 cfs_latency;     /* usec */
        uint32_t                 cfs_index;
        uint32_t                 cfs_reserved[5];
 };



Home | Main Index | Thread Index | Old Index