Module Name:    src
Committed By:   ryo
Date:           Fri Jul 24 05:19:14 UTC 2015

Modified Files:
        src/sys/arch/arm/cortex: a9tmr.c

Log Message:
- fix sc_ev_missing_ticks over-counting.
- don't use 64bit division, because it has expensive cost on gcc/arm
  whether it is a constant or not.

'delta' is usually taken a value around sc_autoinc depending on timing
of read. therefore 'delta / sc->sc_autoinc' would be count too much.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/cortex/a9tmr.c

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

Modified files:

Index: src/sys/arch/arm/cortex/a9tmr.c
diff -u src/sys/arch/arm/cortex/a9tmr.c:1.12 src/sys/arch/arm/cortex/a9tmr.c:1.13
--- src/sys/arch/arm/cortex/a9tmr.c:1.12	Wed Mar  4 23:18:21 2015
+++ src/sys/arch/arm/cortex/a9tmr.c	Fri Jul 24 05:19:13 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: a9tmr.c,v 1.12 2015/03/04 23:18:21 jmcneill Exp $	*/
+/*	$NetBSD: a9tmr.c,v 1.13 2015/07/24 05:19:13 ryo Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: a9tmr.c,v 1.12 2015/03/04 23:18:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: a9tmr.c,v 1.13 2015/07/24 05:19:13 ryo Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -329,7 +329,7 @@ clockhandler(void *arg)
 	printf("%s(%p): %s: now %#"PRIx64" delta %"PRIu64"\n", 
 	     __func__, cf, ci->ci_data.cpu_name, now, delta);
 #endif
-	KASSERTMSG(delta > sc->sc_autoinc / 100,
+	KASSERTMSG(delta > sc->sc_autoinc / 64,
 	    "%s: interrupting too quickly (delta=%"PRIu64")",
 	    ci->ci_data.cpu_name, delta);
 
@@ -337,20 +337,22 @@ clockhandler(void *arg)
 
 	hardclock(cf);
 
+	if (delta > sc->sc_autoinc) {
+		u_int ticks = hz;
+		for (delta -= sc->sc_autoinc;
+		     delta >= sc->sc_autoinc && ticks > 0;
+		     delta -= sc->sc_autoinc, ticks--) {
 #if 0
-	/*
-	 * Try to make up up to a seconds amount of missed clock interrupts
-	 */
-	u_int ticks = hz;
-	for (delta -= sc->sc_autoinc;
-	     ticks > 0 && delta >= sc->sc_autoinc;
-	     delta -= sc->sc_autoinc, ticks--) {
-		hardclock(cf);
-	}
+			/*
+			 * Try to make up up to a seconds amount of
+			 * missed clock interrupts
+			 */
+			hardclock(cf);
 #else
-	if (delta > sc->sc_autoinc)
-		sc->sc_ev_missing_ticks.ev_count += delta / sc->sc_autoinc;
+			sc->sc_ev_missing_ticks.ev_count++;
 #endif
+		}
+	}
 
 	return 1;
 }

Reply via email to