timer: optimize for empty case
authorStephen Hemminger <shemminger@vyatta.com>
Thu, 30 May 2013 17:12:36 +0000 (17:12 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 17 Sep 2013 12:09:22 +0000 (14:09 +0200)
In many application there are no timers queued, and the call to
rte_timer_managecan be optimized in that case avoid reading HPET and
lock overhead.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Reviewed-by: Vincent Jardin <vincent.jardin@6wind.com>
lib/librte_timer/rte_timer.c

index 095547a..c9b253a 100644 (file)
@@ -403,9 +403,14 @@ void rte_timer_manage(void)
        union rte_timer_status status;
        struct rte_timer *tim, *tim2;
        unsigned lcore_id = rte_lcore_id();
-       uint64_t cur_time = rte_get_hpet_cycles();
+       uint64_t cur_time;
        int ret;
 
+       /* optimize for the case where per-cpu list is empty */
+       if (LIST_EMPTY(&priv_timer[lcore_id].pending))
+               return;
+
+       cur_time = rte_get_hpet_cycles();
        __TIMER_STAT_ADD(manage, 1);
 
        /* browse ordered list, add expired timers in 'expired' list */