Module Name:    src
Committed By:   jruoho
Date:           Tue Oct 25 11:35:49 UTC 2011

Modified Files:
        src/sys/kern: subr_cpufreq.c
        src/sys/sys: cpufreq.h

Log Message:
Use microsecond rather than nanosecond resolution when sampling latencies.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/kern/subr_cpufreq.c
cvs rdiff -u -r1.3 -r1.4 src/sys/sys/cpufreq.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_cpufreq.c
diff -u src/sys/kern/subr_cpufreq.c:1.5 src/sys/kern/subr_cpufreq.c:1.6
--- src/sys/kern/subr_cpufreq.c:1.5	Thu Oct 20 06:48:24 2011
+++ src/sys/kern/subr_cpufreq.c	Tue Oct 25 11:35:49 2011
@@ -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 @@ static int
 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_latency(void)
 				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;
 		}
 
 		/*

Index: src/sys/sys/cpufreq.h
diff -u src/sys/sys/cpufreq.h:1.3 src/sys/sys/cpufreq.h:1.4
--- src/sys/sys/cpufreq.h:1.3	Fri Sep 30 04:01:21 2011
+++ src/sys/sys/cpufreq.h	Tue Oct 25 11:35:49 2011
@@ -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];
 };

Reply via email to