On Thu, 14 Nov 2024 16:37:10 +0800
Congjie Zhou <zcjie0...@qq.com> wrote:

>  
> +static uint64_t
> +current_time(void)
> +{
> +     struct timespec ts;
> +     if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == -1) {
> +             EAL_LOG(ERR, "Fail to get current time");
> +             return -1ULL;
> +     }
> +     uint64_t time_ns = (uint64_t)ts.tv_sec * 1000000000ULL + ts.tv_nsec;
> +     return time_ns;
> +}
> +
>  static int
>  secondary_msl_create_walk(const struct rte_memseg_list *msl,
>               void *arg __rte_unused)
> @@ -1447,8 +1460,8 @@ secondary_msl_create_walk(const struct rte_memseg_list 
> *msl,
>       local_msl = &local_memsegs[msl_idx];
>  
>       /* create distinct fbarrays for each secondary */
> -     snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%i",
> -             primary_msl->memseg_arr.name, getpid());
> +     snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%i_%"PRIx64,
> +             primary_msl->memseg_arr.name, getpid(), current_time());
>  

In general DPDK uses tsc instead of monotonic time, since it is faster and 
platform
independent (ie Windows).

Why not use use a global counter instead?

Reply via email to