From owner-svn-src-projects@FreeBSD.ORG Sun Jul 1 09:17:18 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 54283106566B; Sun, 1 Jul 2012 09:17:18 +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 3F1568FC0C; Sun, 1 Jul 2012 09:17:18 +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 q619HI1I079759; Sun, 1 Jul 2012 09:17:18 GMT (envelope-from davide@svn.freebsd.org) Received: (from davide@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q619HIGe079756; Sun, 1 Jul 2012 09:17:18 GMT (envelope-from davide@svn.freebsd.org) Message-Id: <201207010917.q619HIGe079756@svn.freebsd.org> From: Davide Italiano Date: Sun, 1 Jul 2012 09:17:18 +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: r237915 - 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: Sun, 01 Jul 2012 09:17:18 -0000 Author: davide Date: Sun Jul 1 09:17:17 2012 New Revision: 237915 URL: http://svn.freebsd.org/changeset/base/237915 Log: The variable 'limit' appears unused right now. Macroize the 0x2 value into C_PRECISION to make code a bit more readable. Fix random style bugs. Discussed with: mav Modified: projects/calloutng/sys/kern/kern_timeout.c Modified: projects/calloutng/sys/kern/kern_timeout.c ============================================================================== --- projects/calloutng/sys/kern/kern_timeout.c Sun Jul 1 09:03:37 2012 (r237914) +++ projects/calloutng/sys/kern/kern_timeout.c Sun Jul 1 09:17:17 2012 (r237915) @@ -143,6 +143,7 @@ struct callout_cpu cc_cpu; #define CC_LOCK(cc) mtx_lock_spin(&(cc)->cc_lock) #define CC_UNLOCK(cc) mtx_unlock_spin(&(cc)->cc_lock) #define CC_LOCK_ASSERT(cc) mtx_assert(&(cc)->cc_lock, MA_OWNED) +#define C_PRECISION 0x2 #define FREQ2BT(freq, bt) \ { \ @@ -336,19 +337,21 @@ SYSINIT(start_softclock, SI_SUB_SOFTINTR static inline int callout_hash(struct bintime *bt) { + return (int) ((bt->sec<<10)+(bt->frac>>54)); } static inline int get_bucket(struct bintime *bt) { + return callout_hash(bt) & callwheelmask; } void callout_process(void) { - struct bintime limit, max, min, next, now, tmp_max, tmp_min; + struct bintime max, min, next, now, tmp_max, tmp_min; struct callout *tmp; struct callout_cpu *cc; struct callout_tailq *sc; @@ -384,8 +387,7 @@ callout_process(void) tmp->c_func(tmp->c_arg); TAILQ_REMOVE(sc, tmp, c_links.tqe); tmp->c_flags &= ~CALLOUT_PENDING; - } - else { + } else { TAILQ_INSERT_TAIL(&cc->cc_expireq, tmp, c_staiter); TAILQ_REMOVE(sc, tmp, c_links.tqe); @@ -398,12 +400,9 @@ callout_process(void) break; first = (first + 1) & callwheelmask; } - future = ((last + hz/4) & callwheelmask); + future = (last + hz / 4) & callwheelmask; max.sec = min.sec = TIME_T_MAX; max.frac = min.frac = UINT64_MAX; - limit.sec = 0; - limit.frac = (uint64_t)1 << (64 - 2); - bintime_add(&limit, &now); /* * Look for the first bucket in the future that contains some event, * up to some point, so that we can look for aggregation. @@ -445,12 +444,11 @@ callout_process(void) next.sec = 0; next.frac = (uint64_t)1 << (64 - 2); bintime_add(&next, &now); - } - /* - * Now that we found something to aggregate, schedule an interrupt in - * the middle of the previously calculated range. - */ - else { + } else { + /* + * Now that we found something to aggregate, schedule an + * interrupt in the middle of the previously calculated range. + */ bintime_add(&max, &min); next = max; next.frac >>= 1; @@ -504,9 +502,8 @@ callout_cc_add(struct callout *c, struct int bucket, r_shift, r_val; CC_LOCK_ASSERT(cc); - if (bintime_cmp(&to_bintime, &cc->cc_lastscan, <)) { + if (bintime_cmp(&to_bintime, &cc->cc_lastscan, <)) to_bintime = cc->cc_lastscan; - } c->c_arg = arg; c->c_flags |= (CALLOUT_ACTIVE | CALLOUT_PENDING); if (flags & C_DIRECT_EXEC) @@ -515,7 +512,7 @@ callout_cc_add(struct callout *c, struct c->c_func = func; c->c_time = to_bintime; bintime_clear(&c->c_precision); - if (flags & 0x2) { + if (flags & C_PRECISION) { r_shift = ((flags >> 2) & PRECISION_RANGE); r_val = (r_shift != 0) ? (uint64_t)1 << (64 - r_shift) : 0; /* @@ -538,7 +535,7 @@ callout_cc_add(struct callout *c, struct } } c->c_precision.frac = r_val; - CTR6(KTR_CALLOUT, "rounding %d.%u%u to %d.%u%u", + CTR6(KTR_CALLOUT, "rounding %d.%08x%08x to %d.%08x%08x", to_bintime.sec, (u_int) (to_bintime.frac >> 32), (u_int) (to_bintime.frac & 0xffffffff), c->c_time.sec, (u_int) (c->c_time.frac >> 32), @@ -899,8 +896,7 @@ _callout_reset_on(struct callout *c, str getbinuptime(&now); bintime_mul(&to_bt,to_ticks); bintime_add(&to_bt,&now); - } - else + } else to_bt = *bt; /* * Don't allow migration of pre-allocated callouts lest they