Skip to content

Commit

Permalink
for more accurate estimation of tsc frequency in x86.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmoon authored and hhaim committed Feb 21, 2021
1 parent e8aefcb commit eb5f606
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dpdk/lib/librte_eal/common/eal_common_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ estimate_tsc_freq(void)
/* assume that the sleep(1) will sleep for 1 second */
uint64_t start = rte_rdtsc();
sleep(1);
#if defined(TREX_PATCH) && !defined(RTE_ARCH_ARM64)
return rte_rdtsc() - start;
#else
/* Round up to 10Mhz. 1E7 ~ 10Mhz */
return RTE_ALIGN_MUL_NEAR(rte_rdtsc() - start, CYC_PER_10MHZ);
#endif
}

void
Expand Down
4 changes: 4 additions & 0 deletions src/dpdk/lib/librte_eal/linux/eal_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,12 @@ get_tsc_freq(void)

double secs = (double)ns/NS_PER_SEC;
tsc_hz = (uint64_t)((end - start)/secs);
#if defined(TREX_PATCH) && !defined(RTE_ARCH_ARM64)
return tsc_hz;
#else
/* Round up to 10Mhz. 1E7 ~ 10Mhz */
return RTE_ALIGN_MUL_NEAR(tsc_hz, CYC_PER_10MHZ);
#endif
}
#endif
return 0;
Expand Down

0 comments on commit eb5f606

Please sign in to comment.