From owner-svn-src-user@FreeBSD.ORG Mon Mar 4 13:17:56 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 952AD9B7; Mon, 4 Mar 2013 13:17:56 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6A74317D5; Mon, 4 Mar 2013 13:17:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r24DHuH2062253; Mon, 4 Mar 2013 13:17:56 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r24DHrOK062224; Mon, 4 Mar 2013 13:17:53 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201303041317.r24DHrOK062224@svn.freebsd.org> From: Attilio Rao Date: Mon, 4 Mar 2013 13:17:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r247790 - in user/attilio/vmc-playground: contrib/libyaml lib lib/libyaml sbin/devd share/mk sys/arm/arm sys/compat/linprocfs sys/compat/linux sys/conf sys/dev/ath sys/dev/ath/ath_hal s... X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Mar 2013 13:17:56 -0000 Author: attilio Date: Mon Mar 4 13:17:52 2013 New Revision: 247790 URL: http://svnweb.freebsd.org/changeset/base/247790 Log: Merge from vmcontention Added: user/attilio/vmc-playground/contrib/libyaml/ - copied from r247789, user/attilio/vmcontention/contrib/libyaml/ user/attilio/vmc-playground/lib/libyaml/ - copied from r247789, user/attilio/vmcontention/lib/libyaml/ Modified: user/attilio/vmc-playground/lib/Makefile user/attilio/vmc-playground/sbin/devd/devd.cc user/attilio/vmc-playground/sbin/devd/devd.hh user/attilio/vmc-playground/share/mk/bsd.libnames.mk user/attilio/vmc-playground/sys/arm/arm/busdma_machdep-v6.c user/attilio/vmc-playground/sys/compat/linprocfs/linprocfs.c user/attilio/vmc-playground/sys/compat/linux/linux_file.c user/attilio/vmc-playground/sys/compat/linux/linux_socket.c user/attilio/vmc-playground/sys/conf/NOTES user/attilio/vmc-playground/sys/conf/options user/attilio/vmc-playground/sys/dev/ath/ath_hal/ah.h user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416.h user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c user/attilio/vmc-playground/sys/dev/ath/if_athvar.h user/attilio/vmc-playground/sys/kern/kern_clock.c user/attilio/vmc-playground/sys/kern/kern_clocksource.c user/attilio/vmc-playground/sys/kern/kern_condvar.c user/attilio/vmc-playground/sys/kern/kern_intr.c user/attilio/vmc-playground/sys/kern/kern_synch.c user/attilio/vmc-playground/sys/kern/kern_tc.c user/attilio/vmc-playground/sys/kern/kern_timeout.c user/attilio/vmc-playground/sys/kern/subr_param.c user/attilio/vmc-playground/sys/kern/subr_sleepqueue.c user/attilio/vmc-playground/sys/netinet/tcp_timer.c user/attilio/vmc-playground/sys/sys/_callout.h user/attilio/vmc-playground/sys/sys/callout.h user/attilio/vmc-playground/sys/sys/condvar.h user/attilio/vmc-playground/sys/sys/mutex.h user/attilio/vmc-playground/sys/sys/rwlock.h user/attilio/vmc-playground/sys/sys/sleepqueue.h user/attilio/vmc-playground/sys/sys/sx.h user/attilio/vmc-playground/sys/sys/systm.h user/attilio/vmc-playground/sys/sys/time.h user/attilio/vmc-playground/tools/make_libdeps.sh user/attilio/vmc-playground/usr.bin/calendar/calendars/calendar.birthday user/attilio/vmc-playground/usr.bin/hexdump/conv.c user/attilio/vmc-playground/usr.sbin/tzsetup/tzsetup.c Directory Properties: user/attilio/vmc-playground/ (props changed) user/attilio/vmc-playground/sbin/ (props changed) user/attilio/vmc-playground/sys/ (props changed) user/attilio/vmc-playground/sys/conf/ (props changed) user/attilio/vmc-playground/usr.bin/calendar/ (props changed) Modified: user/attilio/vmc-playground/lib/Makefile ============================================================================== --- user/attilio/vmc-playground/lib/Makefile Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/lib/Makefile Mon Mar 4 13:17:52 2013 (r247790) @@ -119,6 +119,7 @@ SUBDIR= ${SUBDIR_ORDERED} \ ${_libvmmapi} \ libwrap \ liby \ + libyaml \ libz \ ${_atf} \ ${_bind} \ Modified: user/attilio/vmc-playground/sbin/devd/devd.cc ============================================================================== --- user/attilio/vmc-playground/sbin/devd/devd.cc Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sbin/devd/devd.cc Mon Mar 4 13:17:52 2013 (r247790) @@ -116,7 +116,7 @@ static struct pidfh *pfh; int Dflag; int dflag; int nflag; -int romeo_must_die = 0; +static volatile sig_atomic_t romeo_must_die = 0; static const char *configfile = CF; @@ -319,7 +319,7 @@ media::do_match(config &c) // the name of interest, first try device-name and fall back // to subsystem if none exists. value = c.get_variable("device-name"); - if (value.length() == 0) + if (value.empty()) value = c.get_variable("subsystem"); if (Dflag) fprintf(stderr, "Testing media type of %s against 0x%x\n", @@ -460,7 +460,7 @@ config::open_pidfile() { pid_t otherpid; - if (_pidfile == "") + if (_pidfile.empty()) return; pfh = pidfile_open(_pidfile.c_str(), 0600, &otherpid); if (pfh == NULL) { @@ -528,7 +528,7 @@ config::add_notify(int prio, event_proc void config::set_pidfile(const char *fn) { - _pidfile = string(fn); + _pidfile = fn; } void @@ -585,7 +585,7 @@ config::expand_one(const char *&src, str src++; // $$ -> $ if (*src == '$') { - dst.append(src++, 1); + dst += *src++; return; } @@ -593,7 +593,7 @@ config::expand_one(const char *&src, str // Not sure if I want to support this or not, so for now we just pass // it through. if (*src == '(') { - dst.append("$"); + dst += '$'; count = 1; /* If the string ends before ) is matched , return. */ while (count > 0 && *src) { @@ -601,23 +601,23 @@ config::expand_one(const char *&src, str count--; else if (*src == '(') count++; - dst.append(src++, 1); + dst += *src++; } return; } - // ${^A-Za-z] -> $\1 + // $[^A-Za-z] -> $\1 if (!isalpha(*src)) { - dst.append("$"); - dst.append(src++, 1); + dst += '$'; + dst += *src++; return; } // $var -> replace with value do { - buffer.append(src++, 1); + buffer += *src++; } while (is_id_char(*src)); - dst.append(get_variable(buffer.c_str())); + dst.append(get_variable(buffer)); } const string @@ -653,7 +653,7 @@ config::expand_string(const char *src, c } bool -config::chop_var(char *&buffer, char *&lhs, char *&rhs) +config::chop_var(char *&buffer, char *&lhs, char *&rhs) const { char *walker; @@ -912,9 +912,7 @@ event_loop(void) server_fd = create_socket(PIPE); accepting = 1; max_fd = max(fd, server_fd) + 1; - while (1) { - if (romeo_must_die) - break; + while (!romeo_must_die) { if (!once && !dflag && !nflag) { // Check to see if we have any events pending. tv.tv_sec = 0; @@ -1076,8 +1074,7 @@ set_variable(const char *var, const char static void gensighand(int) { - romeo_must_die++; - _exit(0); + romeo_must_die = 1; } static void Modified: user/attilio/vmc-playground/sbin/devd/devd.hh ============================================================================== --- user/attilio/vmc-playground/sbin/devd/devd.hh Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sbin/devd/devd.hh Mon Mar 4 13:17:52 2013 (r247790) @@ -41,8 +41,6 @@ class config; class var_list { public: - var_list() {} - virtual ~var_list() {} /** Set a variable in this var list. */ void set_variable(const std::string &var, const std::string &val); @@ -68,7 +66,6 @@ private: struct eps { public: - eps() {} virtual ~eps() {} /** Does this eps match the current config? */ @@ -144,7 +141,7 @@ private: class config { public: - config() : _pidfile("") { push_var_table(); } + config() { push_var_table(); } virtual ~config() { reset(); } void add_attach(int, event_proc *); void add_detach(int, event_proc *); @@ -172,7 +169,7 @@ protected: void parse_files_in_dir(const char *dirname); void expand_one(const char *&src, std::string &dst); bool is_id_char(char) const; - bool chop_var(char *&buffer, char *&lhs, char *&rhs); + bool chop_var(char *&buffer, char *&lhs, char *&rhs) const; private: std::vector _dir_list; std::string _pidfile; Modified: user/attilio/vmc-playground/share/mk/bsd.libnames.mk ============================================================================== --- user/attilio/vmc-playground/share/mk/bsd.libnames.mk Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/share/mk/bsd.libnames.mk Mon Mar 4 13:17:52 2013 (r247790) @@ -25,6 +25,7 @@ LIBBIND9?= ${DESTDIR}${LIBDIR}/libbind9. .endif LIBBLUETOOTH?= ${DESTDIR}${LIBDIR}/libbluetooth.a LIBBSDXML?= ${DESTDIR}${LIBDIR}/libbsdxml.a +LIBBSDYML?= ${DESTDIR}${LIBDIR}/libbsdyml.a LIBBSM?= ${DESTDIR}${LIBDIR}/libbsm.a LIBBSNMP?= ${DESTDIR}${LIBDIR}/libbsnmp.a LIBBZ2?= ${DESTDIR}${LIBDIR}/libbz2.a Modified: user/attilio/vmc-playground/sys/arm/arm/busdma_machdep-v6.c ============================================================================== --- user/attilio/vmc-playground/sys/arm/arm/busdma_machdep-v6.c Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/arm/arm/busdma_machdep-v6.c Mon Mar 4 13:17:52 2013 (r247790) @@ -1007,6 +1007,9 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dm } else { sl = &map->slist[map->sync_count - 1]; if (map->sync_count == 0 || +#ifdef ARM_L2_PIPT + curaddr != sl->busaddr + sl->datacount || +#endif vaddr != sl->vaddr + sl->datacount) { if (++map->sync_count > dmat->nsegments) goto cleanup; Modified: user/attilio/vmc-playground/sys/compat/linprocfs/linprocfs.c ============================================================================== --- user/attilio/vmc-playground/sys/compat/linprocfs/linprocfs.c Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/compat/linprocfs/linprocfs.c Mon Mar 4 13:17:52 2013 (r247790) @@ -386,8 +386,7 @@ linprocfs_domtab(PFS_FILL_ARGS) sbuf_printf(sb, " 0 0\n"); } mtx_unlock(&mountlist_mtx); - if (flep != NULL) - free(flep, M_TEMP); + free(flep, M_TEMP); return (error); } @@ -447,8 +446,7 @@ linprocfs_dopartitions(PFS_FILL_ARGS) } g_topology_unlock(); - if (flep != NULL) - free(flep, M_TEMP); + free(flep, M_TEMP); return (error); } Modified: user/attilio/vmc-playground/sys/compat/linux/linux_file.c ============================================================================== --- user/attilio/vmc-playground/sys/compat/linux/linux_file.c Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/compat/linux/linux_file.c Mon Mar 4 13:17:52 2013 (r247790) @@ -517,8 +517,7 @@ eof: td->td_retval[0] = nbytes - resid; out: - if (cookies) - free(cookies, M_TEMP); + free(cookies, M_TEMP); VOP_UNLOCK(vp, 0); foffset_unlock(fp, off, 0); Modified: user/attilio/vmc-playground/sys/compat/linux/linux_socket.c ============================================================================== --- user/attilio/vmc-playground/sys/compat/linux/linux_socket.c Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/compat/linux/linux_socket.c Mon Mar 4 13:17:52 2013 (r247790) @@ -1443,10 +1443,8 @@ out: bad: free(iov, M_IOV); - if (control != NULL) - m_freem(control); - if (linux_cmsg != NULL) - free(linux_cmsg, M_TEMP); + m_freem(control); + free(linux_cmsg, M_TEMP); return (error); } Modified: user/attilio/vmc-playground/sys/conf/NOTES ============================================================================== --- user/attilio/vmc-playground/sys/conf/NOTES Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/conf/NOTES Mon Mar 4 13:17:52 2013 (r247790) @@ -259,6 +259,8 @@ options SX_NOINLINE # SMP Debugging Options: # +# CALLOUT_PROFILING enables rudimentary profiling of the callwheel data +# structure used as backend in callout(9). # PREEMPTION allows the threads that are in the kernel to be preempted by # higher priority [interrupt] threads. It helps with interactivity # and allows interrupt threads to run sooner rather than waiting. @@ -297,6 +299,9 @@ options LOCK_PROFILING options MPROF_BUFFERS="1536" options MPROF_HASH_SIZE="1543" +# Profiling for the callout(9) backend. +options CALLOUT_PROFILING + # Profiling for internal hash tables. options SLEEPQUEUE_PROFILING options TURNSTILE_PROFILING Modified: user/attilio/vmc-playground/sys/conf/options ============================================================================== --- user/attilio/vmc-playground/sys/conf/options Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/conf/options Mon Mar 4 13:17:52 2013 (r247790) @@ -68,6 +68,7 @@ TEXTDUMP_VERBOSE opt_ddb.h ADAPTIVE_LOCKMGRS ALQ AUDIT opt_global.h +CALLOUT_PROFILING CAPABILITIES opt_capsicum.h CAPABILITY_MODE opt_capsicum.h COMPAT_43 opt_compat.h Modified: user/attilio/vmc-playground/sys/dev/ath/ath_hal/ah.h ============================================================================== --- user/attilio/vmc-playground/sys/dev/ath/ath_hal/ah.h Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/dev/ath/ath_hal/ah.h Mon Mar 4 13:17:52 2013 (r247790) @@ -1527,11 +1527,13 @@ struct ath_hal { struct ath_desc *, u_int); void __ahdecl(*ah_set11nAggrLast)(struct ath_hal *, struct ath_desc *); - void __ahdecl(*ah_clr11nAggr)(struct ath_hal *, struct ath_desc *); void __ahdecl(*ah_set11nBurstDuration)(struct ath_hal *, struct ath_desc *, u_int); + void __ahdecl(*ah_set11nVirtMoreFrag)(struct ath_hal *, + struct ath_desc *, u_int); + HAL_BOOL __ahdecl(*ah_getMibCycleCounts) (struct ath_hal *, HAL_SURVEY_SAMPLE *); Modified: user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416.h ============================================================================== --- user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416.h Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416.h Mon Mar 4 13:17:52 2013 (r247790) @@ -409,8 +409,9 @@ extern void ar5416Set11nAggrFirst(struct u_int aggrLen, u_int numDelims); extern void ar5416Set11nAggrMiddle(struct ath_hal *ah, struct ath_desc *ds, u_int numDelims); extern void ar5416Set11nAggrLast(struct ath_hal *ah, struct ath_desc *ds); - extern void ar5416Clr11nAggr(struct ath_hal *ah, struct ath_desc *ds); +extern void ar5416Set11nVirtualMoreFrag(struct ath_hal *ah, + struct ath_desc *ds, u_int vmf); extern void ar5416Set11nBurstDuration(struct ath_hal *ah, struct ath_desc *ds, u_int burstDuration); Modified: user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c ============================================================================== --- user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c Mon Mar 4 13:17:52 2013 (r247790) @@ -194,6 +194,7 @@ ar5416InitState(struct ath_hal_5416 *ahp ah->ah_set11nMac2040 = ar5416Set11nMac2040; ah->ah_get11nRxClear = ar5416Get11nRxClear; ah->ah_set11nRxClear = ar5416Set11nRxClear; + ah->ah_set11nVirtMoreFrag = ar5416Set11nVirtualMoreFrag; /* Interrupt functions */ ah->ah_isInterruptPending = ar5416IsInterruptPending; Modified: user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c ============================================================================== --- user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c Mon Mar 4 13:17:52 2013 (r247790) @@ -825,6 +825,17 @@ ar5416Clr11nAggr(struct ath_hal *ah, str ads->ds_ctl6 &= ~AR_AggrLen; } +void +ar5416Set11nVirtualMoreFrag(struct ath_hal *ah, struct ath_desc *ds, + u_int vmf) +{ + struct ar5416_desc *ads = AR5416DESC(ds); + if (vmf) + ads->ds_ctl0 |= AR_VirtMoreFrag; + else + ads->ds_ctl0 &= ~AR_VirtMoreFrag; +} + /* * Program the burst duration, with the included BA delta if it's * applicable. Modified: user/attilio/vmc-playground/sys/dev/ath/if_athvar.h ============================================================================== --- user/attilio/vmc-playground/sys/dev/ath/if_athvar.h Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/dev/ath/if_athvar.h Mon Mar 4 13:17:52 2013 (r247790) @@ -1297,6 +1297,8 @@ void ath_intr(void *); ((*(_ah)->ah_set11nBurstDuration)((_ah), (_ds), (_dur))) #define ath_hal_clr11n_aggr(_ah, _ds) \ ((*(_ah)->ah_clr11nAggr)((_ah), (_ds))) +#define ath_hal_set11n_virtmorefrag(_ah, _ds, _v) \ + ((*(_ah)->ah_set11nVirtMoreFrag)((_ah), (_ds), (_v))) #define ath_hal_gpioCfgOutput(_ah, _gpio, _type) \ ((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio), (_type))) Modified: user/attilio/vmc-playground/sys/kern/kern_clock.c ============================================================================== --- user/attilio/vmc-playground/sys/kern/kern_clock.c Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/kern/kern_clock.c Mon Mar 4 13:17:52 2013 (r247790) @@ -460,7 +460,7 @@ hardclock_cpu(int usermode) if (td->td_intr_frame != NULL) PMC_SOFT_CALL_TF( , , clock, hard, td->td_intr_frame); #endif - callout_tick(); + callout_process(sbinuptime()); } /* @@ -550,7 +550,6 @@ hardclock_cnt(int cnt, int usermode) if (td->td_intr_frame != NULL) PMC_SOFT_CALL_TF( , , clock, hard, td->td_intr_frame); #endif - callout_tick(); /* We are in charge to handle this tick duty. */ if (newticks > 0) { /* Dangerous and no need to call these things concurrently. */ Modified: user/attilio/vmc-playground/sys/kern/kern_clocksource.c ============================================================================== --- user/attilio/vmc-playground/sys/kern/kern_clocksource.c Mon Mar 4 13:14:59 2013 (r247789) +++ user/attilio/vmc-playground/sys/kern/kern_clocksource.c Mon Mar 4 13:17:52 2013 (r247790) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2010-2012 Alexander Motin + * Copyright (c) 2010-2013 Alexander Motin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -63,17 +64,14 @@ int cpu_can_deep_sleep = 0; /* C3 stat int cpu_disable_deep_sleep = 0; /* Timer dies in C3. */ static void setuptimer(void); -static void loadtimer(struct bintime *now, int first); +static void loadtimer(sbintime_t now, int first); static int doconfigtimer(void); static void configtimer(int start); static int round_freq(struct eventtimer *et, int freq); -static void getnextcpuevent(struct bintime *event, int idle); -static void getnextevent(struct bintime *event); -static int handleevents(struct bintime *now, int fake); -#ifdef SMP -static void cpu_new_callout(int cpu, int ticks); -#endif +static sbintime_t getnextcpuevent(int idle); +static sbintime_t getnextevent(void); +static int handleevents(sbintime_t now, int fake); static struct mtx et_hw_mtx; @@ -94,13 +92,11 @@ static struct mtx et_hw_mtx; } static struct eventtimer *timer = NULL; -static struct bintime timerperiod; /* Timer period for periodic mode. */ -static struct bintime hardperiod; /* hardclock() events period. */ -static struct bintime statperiod; /* statclock() events period. */ -static struct bintime profperiod; /* profclock() events period. */ -static struct bintime nexttick; /* Next global timer tick time. */ -static struct bintime nexthard; /* Next global hardlock() event. */ -static u_int busy = 0; /* Reconfiguration is in progress. */ +static sbintime_t timerperiod; /* Timer period for periodic mode. */ +static sbintime_t statperiod; /* statclock() events period. */ +static sbintime_t profperiod; /* profclock() events period. */ +static sbintime_t nexttick; /* Next global timer tick time. */ +static u_int busy = 1; /* Reconfiguration is in progress. */ static int profiling = 0; /* Profiling events enabled. */ static char timername[32]; /* Wanted timer. */ @@ -116,11 +112,6 @@ TUNABLE_INT("kern.eventtimer.idletick", SYSCTL_UINT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RW, &idletick, 0, "Run periodic events when idle"); -static u_int activetick = 1; /* Run all periodic events when active. */ -TUNABLE_INT("kern.eventtimer.activetick", &activetick); -SYSCTL_UINT(_kern_eventtimer, OID_AUTO, activetick, CTLFLAG_RW, &activetick, - 0, "Run all periodic events when active"); - static int periodic = 0; /* Periodic or one-shot mode. */ static int want_periodic = 0; /* What mode to prefer. */ TUNABLE_INT("kern.eventtimer.periodic", &want_periodic); @@ -129,31 +120,23 @@ struct pcpu_state { struct mtx et_hw_mtx; /* Per-CPU timer mutex. */ u_int action; /* Reconfiguration requests. */ u_int handle; /* Immediate handle resuests. */ - struct bintime now; /* Last tick time. */ - struct bintime nextevent; /* Next scheduled event on this CPU. */ - struct bintime nexttick; /* Next timer tick time. */ - struct bintime nexthard; /* Next hardlock() event. */ - struct bintime nextstat; /* Next statclock() event. */ - struct bintime nextprof; /* Next profclock() event. */ + sbintime_t now; /* Last tick time. */ + sbintime_t nextevent; /* Next scheduled event on this CPU. */ + sbintime_t nexttick; /* Next timer tick time. */ + sbintime_t nexthard; /* Next hardlock() event. */ + sbintime_t nextstat; /* Next statclock() event. */ + sbintime_t nextprof; /* Next profclock() event. */ + sbintime_t nextcall; /* Next callout event. */ + sbintime_t nextcallopt; /* Next optional callout event. */ #ifdef KDTRACE_HOOKS - struct bintime nextcyc; /* Next OpenSolaris cyclics event. */ + sbintime_t nextcyc; /* Next OpenSolaris cyclics event. */ #endif int ipi; /* This CPU needs IPI. */ int idle; /* This CPU is in idle mode. */ }; static DPCPU_DEFINE(struct pcpu_state, timerstate); - -#define FREQ2BT(freq, bt) \ -{ \ - (bt)->sec = 0; \ - (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \ -} -#define BT2FREQ(bt) \ - (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \ - ((bt)->frac >> 1)) - -#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt)) +DPCPU_DEFINE(sbintime_t, hardclocktime); /* * Timer broadcast IPI handler. @@ -161,7 +144,7 @@ static DPCPU_DEFINE(struct pcpu_state, t int hardclockintr(void) { - struct bintime now; + sbintime_t now; struct pcpu_state *state; int done; @@ -169,10 +152,9 @@ hardclockintr(void) return (FILTER_HANDLED); state = DPCPU_PTR(timerstate); now = state->now; - CTR4(KTR_SPARE2, "ipi at %d: now %d.%08x%08x", - curcpu, now.sec, (u_int)(now.frac >> 32), - (u_int)(now.frac & 0xffffffff)); - done = handleevents(&now, 0); + CTR3(KTR_SPARE2, "ipi at %d: now %d.%08x", + curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff)); + done = handleevents(now, 0); return (done ? FILTER_HANDLED : FILTER_STRAY); } @@ -180,48 +162,43 @@ hardclockintr(void) * Handle all events for specified time on this CPU */ static int -handleevents(struct bintime *now, int fake) +handleevents(sbintime_t now, int fake) { - struct bintime t; + sbintime_t t, *hct; struct trapframe *frame; struct pcpu_state *state; - uintfptr_t pc; int usermode; int done, runs; - CTR4(KTR_SPARE2, "handle at %d: now %d.%08x%08x", - curcpu, now->sec, (u_int)(now->frac >> 32), - (u_int)(now->frac & 0xffffffff)); + CTR3(KTR_SPARE2, "handle at %d: now %d.%08x", + curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff)); done = 0; if (fake) { frame = NULL; usermode = 0; - pc = 0; } else { frame = curthread->td_intr_frame; usermode = TRAPF_USERMODE(frame); - pc = TRAPF_PC(frame); } state = DPCPU_PTR(timerstate); runs = 0; - while (bintime_cmp(now, &state->nexthard, >=)) { - bintime_addx(&state->nexthard, hardperiod.frac); + while (now >= state->nexthard) { + state->nexthard += tick_sbt; runs++; } if (runs) { - if ((timer->et_flags & ET_FLAGS_PERCPU) == 0 && - bintime_cmp(&state->nexthard, &nexthard, >)) - nexthard = state->nexthard; + hct = DPCPU_PTR(hardclocktime); + *hct = state->nexthard - tick_sbt; if (fake < 2) { hardclock_cnt(runs, usermode); done = 1; } } runs = 0; - while (bintime_cmp(now, &state->nextstat, >=)) { - bintime_addx(&state->nextstat, statperiod.frac); + while (now >= state->nextstat) { + state->nextstat += statperiod; runs++; } if (runs && fake < 2) { @@ -230,31 +207,29 @@ handleevents(struct bintime *now, int fa } if (profiling) { runs = 0; - while (bintime_cmp(now, &state->nextprof, >=)) { - bintime_addx(&state->nextprof, profperiod.frac); + while (now >= state->nextprof) { + state->nextprof += profperiod; runs++; } if (runs && !fake) { - profclock_cnt(runs, usermode, pc); + profclock_cnt(runs, usermode, TRAPF_PC(frame)); done = 1; } } else state->nextprof = state->nextstat; + if (now >= state->nextcallopt) { + state->nextcall = state->nextcallopt = INT64_MAX; + callout_process(now); + } #ifdef KDTRACE_HOOKS - if (fake == 0 && cyclic_clock_func != NULL && - state->nextcyc.sec != -1 && - bintime_cmp(now, &state->nextcyc, >=)) { - state->nextcyc.sec = -1; + if (fake == 0 && now >= state->nextcyc && cyclic_clock_func != NULL) { + state->nextcyc = INT64_MAX; (*cyclic_clock_func)(frame); } #endif - getnextcpuevent(&t, 0); - if (fake == 2) { - state->nextevent = t; - return (done); - } + t = getnextcpuevent(0); ET_HW_LOCK(state); if (!busy) { state->idle = 0; @@ -268,84 +243,81 @@ handleevents(struct bintime *now, int fa /* * Schedule binuptime of the next event on current CPU. */ -static void -getnextcpuevent(struct bintime *event, int idle) +static sbintime_t +getnextcpuevent(int idle) { - struct bintime tmp; + sbintime_t event; struct pcpu_state *state; - int skip; + u_int hardfreq; state = DPCPU_PTR(timerstate); - /* Handle hardclock() events. */ - *event = state->nexthard; - if (idle || (!activetick && !profiling && - (timer->et_flags & ET_FLAGS_PERCPU) == 0)) { - skip = idle ? 4 : (stathz / 2); - if (curcpu == CPU_FIRST() && tc_min_ticktock_freq > skip) - skip = tc_min_ticktock_freq; - skip = callout_tickstofirst(hz / skip) - 1; - CTR2(KTR_SPARE2, "skip at %d: %d", curcpu, skip); - tmp = hardperiod; - bintime_mul(&tmp, skip); - bintime_add(event, &tmp); - } + /* Handle hardclock() events, skipping some if CPU is idle. */ + event = state->nexthard; + if (idle) { + hardfreq = (u_int)hz / 2; + if (tc_min_ticktock_freq > 2 +#ifdef SMP + && curcpu == CPU_FIRST() +#endif + ) + hardfreq = hz / tc_min_ticktock_freq; + if (hardfreq > 1) + event += tick_sbt * (hardfreq - 1); + } + /* Handle callout events. */ + if (event > state->nextcall) + event = state->nextcall; if (!idle) { /* If CPU is active - handle other types of events. */ - if (bintime_cmp(event, &state->nextstat, >)) - *event = state->nextstat; - if (profiling && bintime_cmp(event, &state->nextprof, >)) - *event = state->nextprof; + if (event > state->nextstat) + event = state->nextstat; + if (profiling && event > state->nextprof) + event = state->nextprof; } #ifdef KDTRACE_HOOKS - if (state->nextcyc.sec != -1 && bintime_cmp(event, &state->nextcyc, >)) - *event = state->nextcyc; + if (event > state->nextcyc) + event = state->nextcyc; #endif + return (event); } /* * Schedule binuptime of the next event on all CPUs. */ -static void -getnextevent(struct bintime *event) +static sbintime_t +getnextevent(void) { struct pcpu_state *state; + sbintime_t event; #ifdef SMP int cpu; #endif - int c, nonidle; + int c; state = DPCPU_PTR(timerstate); - *event = state->nextevent; - c = curcpu; - nonidle = !state->idle; - if ((timer->et_flags & ET_FLAGS_PERCPU) == 0) { + event = state->nextevent; + c = -1; #ifdef SMP - if (smp_started) { - CPU_FOREACH(cpu) { - if (curcpu == cpu) - continue; - state = DPCPU_ID_PTR(cpu, timerstate); - nonidle += !state->idle; - if (bintime_cmp(event, &state->nextevent, >)) { - *event = state->nextevent; - c = cpu; - } + if ((timer->et_flags & ET_FLAGS_PERCPU) == 0) { + CPU_FOREACH(cpu) { + state = DPCPU_ID_PTR(cpu, timerstate); + if (event > state->nextevent) { + event = state->nextevent; + c = cpu; } } -#endif - if (nonidle != 0 && bintime_cmp(event, &nexthard, >)) - *event = nexthard; } - CTR5(KTR_SPARE2, "next at %d: next %d.%08x%08x by %d", - curcpu, event->sec, (u_int)(event->frac >> 32), - (u_int)(event->frac & 0xffffffff), c); +#endif + CTR4(KTR_SPARE2, "next at %d: next %d.%08x by %d", + curcpu, (int)(event >> 32), (u_int)(event & 0xffffffff), c); + return (event); } /* Hardware timer callback function. */ static void timercb(struct eventtimer *et, void *arg) { - struct bintime now; - struct bintime *next; + sbintime_t now; + sbintime_t *next; struct pcpu_state *state; #ifdef SMP int cpu, bcast; @@ -360,16 +332,14 @@ timercb(struct eventtimer *et, void *arg next = &state->nexttick; } else next = &nexttick; - binuptime(&now); - if (periodic) { - *next = now; - bintime_addx(next, timerperiod.frac); /* Next tick in 1 period. */ - } else - next->sec = -1; /* Next tick is not scheduled yet. */ + now = sbinuptime(); + if (periodic) + *next = now + timerperiod; + else + *next = -1; /* Next tick is not scheduled yet. */ state->now = now; - CTR4(KTR_SPARE2, "intr at %d: now %d.%08x%08x", - curcpu, (int)(now.sec), (u_int)(now.frac >> 32), - (u_int)(now.frac & 0xffffffff)); + CTR3(KTR_SPARE2, "intr at %d: now %d.%08x", + curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff)); #ifdef SMP /* Prepare broadcasting to other CPUs for non-per-CPU timers. */ @@ -379,8 +349,8 @@ timercb(struct eventtimer *et, void *arg state = DPCPU_ID_PTR(cpu, timerstate); ET_HW_LOCK(state); state->now = now; - if (bintime_cmp(&now, &state->nextevent, >=)) { - state->nextevent.sec++; + if (now >= state->nextevent) { + state->nextevent += SBT_1S; if (curcpu != cpu) { state->ipi = 1; bcast = 1; @@ -392,7 +362,7 @@ timercb(struct eventtimer *et, void *arg #endif /* Handle events for this time on this CPU. */ - handleevents(&now, 0); + handleevents(now, 0); #ifdef SMP /* Broadcast interrupt to other CPUs for non-per-CPU timers. */ @@ -414,11 +384,11 @@ timercb(struct eventtimer *et, void *arg * Load new value into hardware timer. */ static void -loadtimer(struct bintime *now, int start) +loadtimer(sbintime_t now, int start) { struct pcpu_state *state; - struct bintime new; - struct bintime *next; + sbintime_t new; + sbintime_t *next; uint64_t tmp; int eq; @@ -433,30 +403,24 @@ loadtimer(struct bintime *now, int start * Try to start all periodic timers aligned * to period to make events synchronous. */ - tmp = ((uint64_t)now->sec << 36) + (now->frac >> 28); - tmp = (tmp % (timerperiod.frac >> 28)) << 28; - new.sec = 0; - new.frac = timerperiod.frac - tmp; - if (new.frac < tmp) /* Left less then passed. */ - bintime_addx(&new, timerperiod.frac); + tmp = now % timerperiod; + new = timerperiod - tmp; + if (new < tmp) /* Left less then passed. */ + new += timerperiod; CTR5(KTR_SPARE2, "load p at %d: now %d.%08x first in %d.%08x", - curcpu, now->sec, (u_int)(now->frac >> 32), - new.sec, (u_int)(new.frac >> 32)); - *next = new; - bintime_add(next, now); - et_start(timer, bttosbt(new), bttosbt(timerperiod)); + curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff), + (int)(new >> 32), (u_int)(new & 0xffffffff)); + *next = new + now; + et_start(timer, new, timerperiod); } } else { - getnextevent(&new); - eq = bintime_cmp(&new, next, ==); - CTR5(KTR_SPARE2, "load at %d: next %d.%08x%08x eq %d", - curcpu, new.sec, (u_int)(new.frac >> 32), - (u_int)(new.frac & 0xffffffff), - eq); + new = getnextevent(); + eq = (new == *next); + CTR4(KTR_SPARE2, "load at %d: next %d.%08x eq %d", + curcpu, (int)(new >> 32), (u_int)(new & 0xffffffff), eq); if (!eq) { *next = new; - bintime_sub(&new, now); - et_start(timer, bttosbt(new), 0); + et_start(timer, new - now, 0); } } } @@ -478,7 +442,7 @@ setuptimer(void) while (freq < (profiling ? profhz : stathz)) freq += hz; freq = round_freq(timer, freq); - FREQ2BT(freq, &timerperiod); + timerperiod = SBT_1S / freq; } /* @@ -487,15 +451,15 @@ setuptimer(void) static int doconfigtimer(void) { - struct bintime now; + sbintime_t now; struct pcpu_state *state; state = DPCPU_PTR(timerstate); switch (atomic_load_acq_int(&state->action)) { case 1: - binuptime(&now); + now = sbinuptime(); ET_HW_LOCK(state); - loadtimer(&now, 1); + loadtimer(now, 1); ET_HW_UNLOCK(state); state->handle = 0; atomic_store_rel_int(&state->action, 0); @@ -509,8 +473,8 @@ doconfigtimer(void) return (1); } if (atomic_readandclear_int(&state->handle) && !busy) { - binuptime(&now); - handleevents(&now, 0); + now = sbinuptime(); + handleevents(now, 0); return (1); } return (0); @@ -523,40 +487,45 @@ doconfigtimer(void) static void configtimer(int start) { - struct bintime now, next; + sbintime_t now, next; struct pcpu_state *state; int cpu; if (start) { setuptimer(); - binuptime(&now); - } + now = sbinuptime(); + } else + now = 0; critical_enter(); ET_HW_LOCK(DPCPU_PTR(timerstate)); if (start) { /* Initialize time machine parameters. */ - next = now; - bintime_addx(&next, timerperiod.frac); + next = now + timerperiod; if (periodic) nexttick = next; else - nexttick.sec = -1; + nexttick = -1; CPU_FOREACH(cpu) { state = DPCPU_ID_PTR(cpu, timerstate); state->now = now; - state->nextevent = next; + if (!smp_started && cpu != CPU_FIRST()) + state->nextevent = INT64_MAX; + else + state->nextevent = next; if (periodic) state->nexttick = next; else - state->nexttick.sec = -1; + state->nexttick = -1; state->nexthard = next; state->nextstat = next; state->nextprof = next; + state->nextcall = next; + state->nextcallopt = next; hardclock_sync(cpu); } busy = 0; /* Start global timer or per-CPU timer of this CPU. */ - loadtimer(&now, 1); + loadtimer(now, 1); } else { busy = 1; /* Stop global timer or per-CPU timer of this CPU. */ @@ -629,12 +598,11 @@ cpu_initclocks_bsp(void) state = DPCPU_ID_PTR(cpu, timerstate); mtx_init(&state->et_hw_mtx, "et_hw_mtx", NULL, MTX_SPIN); #ifdef KDTRACE_HOOKS - state->nextcyc.sec = -1; + state->nextcyc = INT64_MAX; #endif + state->nextcall = INT64_MAX; + state->nextcallopt = INT64_MAX; } -#ifdef SMP - callout_new_inserted = cpu_new_callout; -#endif periodic = want_periodic; /* Grab requested timer or the best of present. */ if (timername[0]) @@ -698,9 +666,10 @@ cpu_initclocks_bsp(void) profhz = round_freq(timer, stathz * 64); } tick = 1000000 / hz; - FREQ2BT(hz, &hardperiod); - FREQ2BT(stathz, &statperiod); - FREQ2BT(profhz, &profperiod); + tick_sbt = SBT_1S / hz; + tick_bt = sbttobt(tick_sbt); + statperiod = SBT_1S / stathz; + profperiod = SBT_1S / profhz; ET_LOCK(); configtimer(1); ET_UNLOCK(); @@ -712,18 +681,22 @@ cpu_initclocks_bsp(void) void cpu_initclocks_ap(void) { - struct bintime now; + sbintime_t now; struct pcpu_state *state; + struct thread *td; state = DPCPU_PTR(timerstate); - binuptime(&now); + now = sbinuptime(); ET_HW_LOCK(state); state->now = now; hardclock_sync(curcpu); - handleevents(&state->now, 2); - if (timer->et_flags & ET_FLAGS_PERCPU) - loadtimer(&now, 1); + spinlock_enter(); ET_HW_UNLOCK(state); + td = curthread; + td->td_intr_nesting_level++; + handleevents(state->now, 2); + td->td_intr_nesting_level--; + spinlock_exit(); } /* @@ -772,7 +745,7 @@ cpu_stopprofclock(void) sbintime_t cpu_idleclock(void) { - struct bintime now, t; + sbintime_t now, t; struct pcpu_state *state; if (idletick || busy || @@ -786,19 +759,17 @@ cpu_idleclock(void) if (periodic) now = state->now; else - binuptime(&now); - CTR4(KTR_SPARE2, "idle at %d: now %d.%08x%08x", - curcpu, now.sec, (u_int)(now.frac >> 32), - (u_int)(now.frac & 0xffffffff)); - getnextcpuevent(&t, 1); + now = sbinuptime(); + CTR3(KTR_SPARE2, "idle at %d: now %d.%08x", + curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff)); + t = getnextcpuevent(1); ET_HW_LOCK(state); state->idle = 1; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***