From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH] eal: optimize timer routines Date: Mon, 01 May 2017 21:52:44 +0200 Message-ID: <1783111.z13ClxBXEf@xps> References: <20170501191207.6480-1-jerin.jacob@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org To: Jerin Jacob Return-path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 6937C5A98 for ; Mon, 1 May 2017 21:52:46 +0200 (CEST) In-Reply-To: <20170501191207.6480-1-jerin.jacob@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 01/05/2017 21:12, Jerin Jacob: > Since DPDK has only two timer sources, > Avoid &eal_timer_source memory read and followed > by the switch case statement when > RTE_LIBEAL_USE_HPET is not defined. [...] > static inline uint64_t > rte_get_timer_cycles(void) > { > +#ifdef RTE_LIBEAL_USE_HPET > switch(eal_timer_source) { > case EAL_TIMER_TSC: > return rte_get_tsc_cycles(); > case EAL_TIMER_HPET: > -#ifdef RTE_LIBEAL_USE_HPET > return rte_get_hpet_cycles(); > -#endif > default: rte_panic("Invalid timer source specified\n"); > } > +#else > + return rte_get_tsc_cycles(); > +#endif I think I would prefer avoiding the #else part by "unifdef" the first occurence of rte_get_tsc_cycles: static inline uint64_t rte_get_timer_cycles(void) { #ifdef RTE_LIBEAL_USE_HPET switch(eal_timer_source) { case EAL_TIMER_TSC: #endif return rte_get_tsc_cycles(); #ifdef RTE_LIBEAL_USE_HPET case EAL_TIMER_HPET: return rte_get_hpet_cycles(); default: rte_panic("Invalid timer source specified\n"); } #endif