Date: Thu, 15 Nov 2012 19:23:39 +0000 (UTC) From: Davide Italiano <davide@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r243096 - in projects/calloutng/sys: kern sys Message-ID: <201211151923.qAFJNdlL043381@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: davide Date: Thu Nov 15 19:23:39 2012 New Revision: 243096 URL: http://svnweb.freebsd.org/changeset/base/243096 Log: - After a discussion with mav@, we decided it's probably better to provide KPI functions to specify both relative and absolute value of precision. - Fix a bug introduced in inittimecounter() in last commit. Reviewed by: mav Modified: projects/calloutng/sys/kern/kern_tc.c projects/calloutng/sys/kern/kern_timeout.c projects/calloutng/sys/sys/callout.h projects/calloutng/sys/sys/time.h Modified: projects/calloutng/sys/kern/kern_tc.c ============================================================================== --- projects/calloutng/sys/kern/kern_tc.c Thu Nov 15 18:49:17 2012 (r243095) +++ projects/calloutng/sys/kern/kern_tc.c Thu Nov 15 19:23:39 2012 (r243096) @@ -120,9 +120,10 @@ SYSCTL_INT(_kern_timecounter, OID_AUTO, ×tepwarnings, 0, "Log time steps"); int tc_timethreshold; +int tc_timepercentage; struct bintime tick_bt; -SYSCTL_INT(_kern, OID_AUTO, tc_timethreshold, CTLFLAG_RW, - &tc_timethreshold, 0, "Precision threshold for timing measurements"); +SYSCTL_INT(_kern, OID_AUTO, tc_timepercentage, CTLFLAG_RW, + &tc_timepercentage, 0, "Precision percentage tolerance"); static void tc_windup(void); static void cpu_tick_calibrate(int); @@ -1728,10 +1729,10 @@ inittimecounter(void *dummy) tc_tick = (hz + 500) / 1000; else tc_tick = 1; - p = (tc_tick * 1000000) / hz; - tc_timethreshold = 20 * imin(1000000000 / hz, 1000000); - tick_rate = imax(hz, tc_tick); + tick_rate = hz / tc_tick; + tc_timethreshold = (100 / tc_timepercentage) * (1000000000 / tick_rate); FREQ2BT(tick_rate, &tick_bt); + p = (tc_tick * 1000000) / hz; printf("Timecounters tick every %d.%03u msec\n", p / 1000, p % 1000); #ifdef FFCLOCK Modified: projects/calloutng/sys/kern/kern_timeout.c ============================================================================== --- projects/calloutng/sys/kern/kern_timeout.c Thu Nov 15 18:49:17 2012 (r243095) +++ projects/calloutng/sys/kern/kern_timeout.c Thu Nov 15 19:23:39 2012 (r243096) @@ -583,7 +583,7 @@ callout_cc_add(struct callout *c, struct c->c_func = func; c->c_time = to_bintime; bintime_clear(&c->c_precision); - r_val = C_PREC2BT(flags); + r_val = C_PABS2BT(flags); c->c_precision.frac = r_val; CTR3(KTR_CALLOUT, "precision set for %p: 0.%08x%08", c, (u_int) (r_val >> 32), (u_int) (r_val & 0xffffffff)); Modified: projects/calloutng/sys/sys/callout.h ============================================================================== --- projects/calloutng/sys/sys/callout.h Thu Nov 15 18:49:17 2012 (r243095) +++ projects/calloutng/sys/sys/callout.h Thu Nov 15 19:23:39 2012 (r243096) @@ -51,19 +51,24 @@ #define CALLOUT_DIRECT 0x0100 /* allow exec from hw int context */ #define C_DIRECT_EXEC 0x0001 /* direct execution of callout */ -#define C_PRECISIONBITS 24 -#define C_PRECISIONRANGE ((1 << C_PRECISIONBITS) - 1) -#define C_PRECISIONMASK (1 << ((32 - C_PRECISIONBITS) - 1)) -#define C_US2PREC(x) (((x) * 4294) & C_PRECISIONMASK) -#define C_BT2PREC(x) (((x) >> 32) & C_PRECISIONMASK) -#define C_PREC2BT(x) ((uint64_t)(flags & C_PRECISIONMASK) << 32) +#define C_PABSBITS 24 +#define C_PABSMASK (~((1 << (32 - C_PABSBITS)) - 1)) +#define C_PABSRANGE ((1 << C_PABSBITS) - 1) +#define C_BT2PABS(x) ((x) >> 40) +#define C_SETPABS(x) (((x) & C_PABSRANGE) << 8) +#define C_US2PABS(x) (((x) * 4294) & ~C_PABSMASK) +#define C_PABS2BT(x) ((uint64_t)(flags & C_PABSMASK) << 32) +#define C_PRELBITS 5 +#define C_PRELRANGE ((1 << C_PRELBITS) - 1) +#define C_PRELSET(x) (((x) & C_PRELRANGE) << 1) +#define C_PRELGET(x) (((x) >> 1) & C_PRELRANGE) /* * Common values specified for precision. */ -#define C_P1MS C_US2PREC(1000) -#define C_P10MS C_US2PREC(10000) -#define C_P100MS C_US2PREC(100000) +#define C_P1MS C_US2PABS(1000) +#define C_P10MS C_US2PABS(10000) +#define C_P100MS C_US2PABS(100000) struct callout_handle { struct callout *callout; Modified: projects/calloutng/sys/sys/time.h ============================================================================== --- projects/calloutng/sys/sys/time.h Thu Nov 15 18:49:17 2012 (r243095) +++ projects/calloutng/sys/sys/time.h Thu Nov 15 19:23:39 2012 (r243096) @@ -58,6 +58,8 @@ struct bintime { extern int tc_timethreshold; extern struct bintime tick_bt; +#define TC_DEFAULTPERC 5 + #define FREQ2BT(freq, bt) \ { \ (bt)->sec = 0; \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211151923.qAFJNdlL043381>