[dpdk-dev] [PATCH v9 2/3] Move common functions in eal_timer.c

Thomas Monjalon thomas.monjalon at 6wind.com
Mon Jul 27 01:40:26 CEST 2015


2015-07-25 12:36, Ravi Kerur
>  static int
>  set_tsc_freq_from_sysctl(void)
>  {
>  	size_t sz;
>  	int tmp;
> +	uint64_t tsc_hz;
>  
>  	sz = sizeof(tmp);
>  	tmp = 0;
> @@ -94,42 +77,23 @@ set_tsc_freq_from_sysctl(void)
>  	else if (tmp != 1)
>  		RTE_LOG(WARNING, EAL, "TSC is not invariant\n");
>  
> -	sz = sizeof(eal_tsc_resolution_hz);
> -	if (sysctlbyname("machdep.tsc_freq", &eal_tsc_resolution_hz, &sz, NULL, 0)) {
> +	sz = sizeof(tsc_hz);
> +	if (sysctlbyname("machdep.tsc_freq", &tsc_hz, &sz, NULL, 0)) {
>  		RTE_LOG(WARNING, EAL, "%s\n", strerror(errno));
>  		return -1;
>  	}
> +	rte_set_tsc_hz(tsc_hz);
>  
>  	return 0;
>  }
[...]
> --- /dev/null
> +++ b/lib/librte_eal/common/eal_common_timer.c
> +void
> +rte_set_tsc_hz(uint64_t tsc_hz)
> +{
> +	eal_tsc_resolution_hz = tsc_hz;
> +}
[...]
> +void
> +set_tsc_freq(void)
> +{
> +	if (set_tsc_freq_from_clock() < 0)
> +		set_tsc_freq_fallback();

It would be simpler to get value from return of these functions
and store it in eal_tsc_resolution_hz here.


More information about the dev mailing list