From: Stephen Hemminger Date: Thu, 30 May 2013 17:12:36 +0000 (+0000) Subject: timer: optimize for empty case X-Git-Tag: spdx-start~11248 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=3778059a51fcbc6b989ca7503a3ff89f6945ddd2;hp=6286101324294f7922f0268007252d1f008c49e4;p=dpdk.git timer: optimize for empty case 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 Reviewed-by: Vincent Jardin --- diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c index 095547a5b6..c9b253a820 100644 --- a/lib/librte_timer/rte_timer.c +++ b/lib/librte_timer/rte_timer.c @@ -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 */