[dpdk-dev] [PATCH] eal: optimize timer routines

Thomas Monjalon thomas at monjalon.net
Mon May 1 21:52:44 CEST 2017


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



More information about the dev mailing list