From owner-svn-src-projects@FreeBSD.ORG Wed Jun 6 15:29:27 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C4408106567F; Wed, 6 Jun 2012 15:29:27 +0000 (UTC) (envelope-from davide@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 96BFB8FC08; Wed, 6 Jun 2012 15:29:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q56FTRnH022442; Wed, 6 Jun 2012 15:29:27 GMT (envelope-from davide@svn.freebsd.org) Received: (from davide@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q56FTRRF022440; Wed, 6 Jun 2012 15:29:27 GMT (envelope-from davide@svn.freebsd.org) Message-Id: <201206061529.q56FTRRF022440@svn.freebsd.org> From: Davide Italiano Date: Wed, 6 Jun 2012 15:29:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236682 - projects/calloutng/sys/kern X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jun 2012 15:29:27 -0000 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);