DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] timer/linux: lower rounding of tsc estimation to 10KHz
@ 2024-09-21 14:00 Isaac Boukris
  2024-09-21 14:00 ` [PATCH 2/2] timer/linux: override TSC freq if no tsc_known_freq Isaac Boukris
                   ` (4 more replies)
  0 siblings, 5 replies; 33+ messages in thread
From: Isaac Boukris @ 2024-09-21 14:00 UTC (permalink / raw)
  To: dev; +Cc: stephen, Isaac Boukris

In practice, the estimation result is just a couple of KHz
away from the kernel's tsc_khz value, so it should suffice.

Roundin to 10MHz can cause a significant drift from real time,
up to a second per 10 minutes.

See also bugzilla: 959

Signed-off-by: Isaac Boukris <iboukris@gmail.com>
---
 lib/eal/linux/eal_timer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 1cb1e92193..241b20d416 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -192,7 +192,7 @@ get_tsc_freq(void)
 {
 #ifdef CLOCK_MONOTONIC_RAW
 #define NS_PER_SEC 1E9
-#define CYC_PER_10MHZ 1E7
+#define CYC_PER_10KHZ 1E4
 
 	struct timespec sleeptime = {.tv_nsec = NS_PER_SEC / 10 }; /* 1/10 second */
 
@@ -209,8 +209,8 @@ get_tsc_freq(void)
 
 		double secs = (double)ns/NS_PER_SEC;
 		tsc_hz = (uint64_t)((end - start)/secs);
-		/* Round up to 10Mhz. 1E7 ~ 10Mhz */
-		return RTE_ALIGN_MUL_NEAR(tsc_hz, CYC_PER_10MHZ);
+		/* Round up to 10Khz. 1E4 ~ 10Khz */
+		return RTE_ALIGN_MUL_NEAR(tsc_hz, CYC_PER_10KHZ);
 	}
 #endif
 	return 0;
-- 
2.45.0


^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2024-10-08  7:56 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-21 14:00 [PATCH 1/2] timer/linux: lower rounding of tsc estimation to 10KHz Isaac Boukris
2024-09-21 14:00 ` [PATCH 2/2] timer/linux: override TSC freq if no tsc_known_freq Isaac Boukris
2024-09-24 17:04   ` Isaac Boukris
2024-09-30 15:04     ` Bruce Richardson
2024-09-30 22:08 ` [PATCH v2 0/2] Improve TSC frequency accuracy on Linux Isaac Boukris
2024-09-30 22:08   ` [PATCH v2 1/2] timer/linux: lower rounding of tsc estimation to 100KHz Isaac Boukris
2024-09-30 22:08   ` [PATCH v2 2/2] timer/linux/x86: override TSC freq if no tsc_known_freq Isaac Boukris
2024-10-01  0:10     ` Stephen Hemminger
2024-10-01  0:22 ` [PATCH v3 0/2] Improve TSC frequency accuracy on Linux Isaac Boukris
2024-10-01  0:22   ` [PATCH v3 1/2] timer/linux: lower rounding of tsc estimation to 100KHz Isaac Boukris
2024-10-01 15:18     ` Stephen Hemminger
2024-10-01  0:22   ` [PATCH v3 2/2] timer/linux/x86: override TSC freq if no tsc_known_freq Isaac Boukris
2024-10-01 15:19     ` Stephen Hemminger
2024-10-01 21:56       ` Isaac Boukris
2024-10-01 20:01     ` Bruce Richardson
2024-10-01 21:59       ` Isaac Boukris
2024-10-02  8:06         ` Bruce Richardson
2024-10-02 16:56 ` [PATCH v4 0/2] Improve TSC frequency accuracy Isaac Boukris
2024-10-02 16:56   ` [PATCH v4 1/2] timer: lower rounding of TSC estimation to 100KHz Isaac Boukris
2024-10-02 16:56   ` [PATCH v4 2/2] timer: allow platform to override cpu TSC frequency Isaac Boukris
2024-10-02 17:11     ` Bruce Richardson
2024-10-02 19:14       ` Isaac Boukris
2024-10-03  9:31         ` Bruce Richardson
2024-10-03 12:29           ` Isaac Boukris
2024-10-02 17:12   ` [PATCH v4 0/2] Improve TSC frequency accuracy Bruce Richardson
2024-10-03 12:26 ` [PATCH v5 " Isaac Boukris
2024-10-03 12:26   ` [PATCH v5 1/2] timer: lower rounding of TSC estimation to 100KHz Isaac Boukris
2024-10-03 14:05     ` Bruce Richardson
2024-10-03 15:13       ` Stephen Hemminger
2024-10-08  7:56         ` David Marchand
2024-10-03 12:26   ` [PATCH v5 2/2] timer: allow platform to override cpu TSC frequency Isaac Boukris
2024-10-03 14:06     ` Bruce Richardson
2024-10-03 15:14       ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).