From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fiji.vyatta.com (fiji.vyatta.com [76.74.103.50]) by dpdk.org (Postfix) with ESMTP id C36B26889 for ; Thu, 30 May 2013 19:21:30 +0200 (CEST) Received: by fiji.vyatta.com (Postfix, from userid 1051) id B6D49B24006; Thu, 30 May 2013 08:08:24 -0700 (PDT) Message-Id: <20130530171626.825256039@vyatta.com> User-Agent: quilt/0.60-1 Date: Thu, 30 May 2013 10:12:36 -0700 From: Stephen Hemminger To: dev@dpdk.org References: <20130530171234.301927271@vyatta.com> Content-Disposition: inline; filename=timer-optimize.patch X-Mailman-Approved-At: Thu, 30 May 2013 23:34:34 +0200 Subject: [dpdk-dev] [PATCH 2/7] rte_timer: optimize for empty case X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 May 2013 17:21:31 -0000 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 */