From: Stephen Hemminger Subject: [PATCH 2/7] rte_timer: optimize for empty case Date: Thu, 30 May 2013 10:12:36 -0700 Message-ID: <20130530171626.825256039@vyatta.com> References: <20130530171234.301927271@vyatta.com> To: dev-VfR2kkLFssw@public.gmane.org Return-path: Content-Disposition: inline; filename=timer-optimize.patch List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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 --- lib/librte_timer/rte_timer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/lib/librte_timer/rte_timer.c 2013-03-28 08:50:50.246413714 -0700 +++ b/lib/librte_timer/rte_timer.c 2013-05-29 08:49:09.305899903 -0700 @@ -404,9 +404,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 */