Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Jun 2012 15:29:27 +0000 (UTC)
From:      Davide Italiano <davide@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r236682 - projects/calloutng/sys/kern
Message-ID:  <201206061529.q56FTRRF022440@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: davide
Date: Wed Jun  6 15:29:27 2012
New Revision: 236682
URL: http://svn.freebsd.org/changeset/base/236682

Log:
  There's no need to add one second to the event time in callout_cc_add()
  if this one is scheduled in the past. This was a braino derived from my
  previous experiments. Moreover, there's no need to call binuptime(), but,
  in turn, event times in the past may be silently converted to
  cc_softticks, avoiding the bintime() overhead.
  
  As an added bonus, we can avoid to start our scan of the wheel 1/HZ
  backward in the past, gaining in terms of performances.
  
  Reported by:		mav

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

Modified: projects/calloutng/sys/kern/kern_timeout.c
==============================================================================
--- projects/calloutng/sys/kern/kern_timeout.c	Wed Jun  6 14:31:14 2012	(r236681)
+++ projects/calloutng/sys/kern/kern_timeout.c	Wed Jun  6 15:29:27 2012	(r236682)
@@ -363,7 +363,6 @@ callout_tick(void)
 	struct callout_cpu *cc;
 	struct callout_tailq *sc;
 	struct bintime now;
-	struct bintime bt;
 	struct bintime limit;
 	struct bintime next;
 	int cpu, first, flag, future, last, need_softclock; 
@@ -376,13 +375,6 @@ callout_tick(void)
 	cc = CC_SELF();
 	mtx_lock_spin_flags(&cc->cc_lock, MTX_QUIET);
 	binuptime(&now);
-	/* 
-	 * getbinuptime() may be inaccurate and return time up to 1/HZ in the past. 
-	 * In order to avoid the possible loss of one or more events look back 1/HZ
-	 * in the past from the time we last checked.
-	 */	
-	FREQ2BT(hz,&bt);
-	bintime_sub(&cc->cc_softticks,&bt);
 	first = callout_hash(&cc->cc_softticks);
 	last = callout_hash(&now);
 	/* 
@@ -477,16 +469,10 @@ callout_cc_add(struct callout *c, struct
     struct bintime to_bintime, void (*func)(void *), void *arg, int cpu)
 {
 	int bucket;	
-	struct bintime now;
-	struct bintime tmp;
 	
-	tmp.sec = 1;
-	tmp.frac = 0;
 	CC_LOCK_ASSERT(cc);
-	binuptime(&now);
-	if (bintime_cmp(&to_bintime, &now, <)) {
-		bintime_add(&now, &tmp);
-		to_bintime = now;
+	if (bintime_cmp(&to_bintime, &cc->cc_softticks, <)) {
+		to_bintime = cc->cc_softticks;
 	}
 	c->c_arg = arg;
 	c->c_flags |= (CALLOUT_ACTIVE | CALLOUT_PENDING);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206061529.q56FTRRF022440>