ff_kern_timeout: optimize the timecounter.

This timecounter implementation retrieves the current time and reports it
as the equivalent number of counts from a counter incrementing at 'hz'.
dev
logwang 2018-01-19 20:57:32 +08:00
parent e272b945ad
commit 39be5a505f
5 changed files with 21 additions and 8 deletions

View File

@ -462,9 +462,6 @@ zone_foreach_keg(uma_zone_t zone, void (*kegfn)(uma_keg_t))
static void
uma_timeout(void *unused)
{
#ifdef FSTACK
return;
#endif
bucket_enable();
zone_foreach(zone_timeout);

View File

@ -1597,3 +1597,12 @@ ff_regist_packet_dispatcher(dispatch_func_t func)
{
packet_dispatcher = func;
}
uint64_t
ff_get_tsc_ns()
{
uint64_t cur_tsc = rte_rdtsc();
uint64_t hz = rte_get_tsc_hz();
return ((double)cur_tsc/(double)hz) * NS_PER_S;
}

View File

@ -167,7 +167,7 @@ ff_clock_gettime_ns(int id)
{
int64_t sec;
long nsec;
ff_clock_gettime(id, &sec, &nsec);
return ((uint64_t)sec * ff_NSEC_PER_SEC + nsec);
@ -176,8 +176,13 @@ ff_clock_gettime_ns(int id)
void
ff_get_current_time(time_t *sec, long *nsec)
{
*sec = current_ts.tv_sec;
*nsec = current_ts.tv_nsec;
if (sec) {
*sec = current_ts.tv_sec;
}
if (nsec) {
*nsec = current_ts.tv_nsec;
}
}
void

View File

@ -56,6 +56,7 @@ void ff_free(void *p);
void ff_clock_gettime(int id, int64_t *sec, long *nsec);
uint64_t ff_clock_gettime_ns(int id);
uint64_t ff_get_tsc_ns(void);
void ff_get_current_time(int64_t *sec, long *nsec);
void ff_update_current_ts(void);

View File

@ -1657,8 +1657,9 @@ ff_hardclock(void)
static unsigned int
ff_tc_get_timecount(struct timecounter *tc)
{
static u_int now;
return (++now);
uint64_t ns;
ns = ff_get_tsc_ns();
return ((ns * tc->tc_frequency) / ff_NSEC_PER_SEC);
}
static struct timecounter ff_timecounter = {