[ovs-dev] [PATCH 3/8] timeval: Factor out cycles_counter().

Jesse Gross jesse at kernel.org
Mon Jan 25 17:34:15 UTC 2016


On Sun, Jan 10, 2016 at 11:18 PM, Pravin B Shelar <pshelar at nicira.com> wrote:
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index cd72e62..c746cc2 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> +static inline unsigned long long
> +cycles_counter(void)
> +{
> +#ifdef DPDK_NETDEV
> +    return rte_get_tsc_cycles();
> +#else
> +    struct timespec tm;
> +
> +    if (clock_gettime(CLOCK_REALTIME, &tm) == -1 ) {

Actually, a couple more comments here:

I think CLOCK_MONOTONIC is a more appropriate counterpart to the TSC.
We don't want things to change if somebody resets the clock. We could
also consider just using the normal OVS timeval code.

I'm also not sure that it is really safe to use the raw TSC in all
cases. It's possible that DPDK support is compiled in but we aren't
using a DPDK port - in that case threads might not be pinned to a
particular core (even in the DPDK case we might want to allow the
threads to float in some situations).



More information about the dev mailing list