svn commit: r236893 - projects/calloutng/sys/kern

Davide Italiano davide at FreeBSD.org
Mon Jun 11 16:35:48 UTC 2012


Author: davide
Date: Mon Jun 11 16:35:47 2012
New Revision: 236893
URL: http://svn.freebsd.org/changeset/base/236893

Log:
  The cc_firsttick field in struct callout_cpu keeps track of the time at
  which the nearest event in future should be fired. In case we're adding an
  event which time associated is greater than cc_firsttick, there's no need
  to call callout_new_inserted. While here, fix a style indentation bug
  pointed out by Bruce Evans (bde@).

Modified:
  projects/calloutng/sys/kern/kern_timeout.c

Modified: projects/calloutng/sys/kern/kern_timeout.c
==============================================================================
--- projects/calloutng/sys/kern/kern_timeout.c	Mon Jun 11 16:18:39 2012	(r236892)
+++ projects/calloutng/sys/kern/kern_timeout.c	Mon Jun 11 16:35:47 2012	(r236893)
@@ -434,9 +434,9 @@ callout_tick(void)
 	}
 	if (next.sec == -1)  
 		next = limit;
+	cc->cc_firsttick = next;
 	if (callout_new_inserted != NULL) 
-	(*callout_new_inserted)(cpu,
-	    next);
+		(*callout_new_inserted)(cpu, next);
 	cc->cc_softticks = now;
 	mtx_unlock_spin_flags(&cc->cc_lock, MTX_QUIET);
 	/*
@@ -496,9 +496,12 @@ callout_cc_add(struct callout *c, struct
 	 * Inform the eventtimers(4) subsystem there's a new callout 
 	 * that has been inserted.
 	 */
-	if (callout_new_inserted != NULL)
-	(*callout_new_inserted)(cpu,
-	    to_bintime);
+	if (callout_new_inserted != NULL && 
+	    (bintime_cmp(&to_bintime, &cc->cc_firsttick, <) ||
+	    (cc->cc_firsttick.sec == 0 && cc->cc_firsttick.frac == 0))) {
+		cc->cc_firsttick = to_bintime;
+		(*callout_new_inserted)(cpu, to_bintime);
+	}
 }
 
 static void


More information about the svn-src-projects mailing list