summaryrefslogtreecommitdiff
path: root/lib/librte_timer
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2013-05-30 17:12:36 +0000
committerThomas Monjalon <thomas.monjalon@6wind.com>2013-09-17 14:09:22 +0200
commit3778059a51fcbc6b989ca7503a3ff89f6945ddd2 (patch)
tree5b266052fafc45955984706492eca537db9e83b1 /lib/librte_timer
parent6286101324294f7922f0268007252d1f008c49e4 (diff)
downloaddpdk-3778059a51fcbc6b989ca7503a3ff89f6945ddd2.zip
dpdk-3778059a51fcbc6b989ca7503a3ff89f6945ddd2.tar.gz
dpdk-3778059a51fcbc6b989ca7503a3ff89f6945ddd2.tar.xz
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 <shemminger@vyatta.com> Reviewed-by: Vincent Jardin <vincent.jardin@6wind.com>
Diffstat (limited to 'lib/librte_timer')
-rw-r--r--lib/librte_timer/rte_timer.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
index 095547a..c9b253a 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 */