mirror of https://github.com/F-Stack/f-stack.git
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'.
This commit is contained in:
parent
54e1dbca13
commit
9f78ac569c
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,9 +176,14 @@ ff_clock_gettime_ns(int id)
|
|||
void
|
||||
ff_get_current_time(time_t *sec, long *nsec)
|
||||
{
|
||||
if (sec) {
|
||||
*sec = current_ts.tv_sec;
|
||||
}
|
||||
|
||||
if (nsec) {
|
||||
*nsec = current_ts.tv_nsec;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ff_update_current_ts()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in New Issue