patch 'eal: fail initialization if TSC frequency is zero' has been queued to stable release 24.11.9

luca.boccassi at gmail.com luca.boccassi at gmail.com
Tue Oct 27 12:50:13 CET 2026


Hi,

FYI, your patch has been queued to stable release 24.11.9

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 10/29/26. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/1b58f3125c37d9c34937c5b655d572d54a9fde46

Thanks.

Luca Boccassi

---
>From 1b58f3125c37d9c34937c5b655d572d54a9fde46 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Tue, 29 Sep 2026 07:13:37 -0700
Subject: [PATCH] eal: fail initialization if TSC frequency is zero

[ upstream commit 0eaf8e5afb77d40471148f3515d2ca857acb5fe6 ]

Many parts of DPDK will fail with divide by zero and
other errors if the initialization logic ever TSC hz was ever
determined to be zero. This might happen on a broken get_tsc_freq_arch()
or bad emulation in QEMU.

If TSC hz is zero, log the error and propagate back to
fail rte_eal_init().

This fix doesn't need to go to stable since it is a purely
theoretical problem; we aren't getting divide by zero reports
from users.

Also, clarify that DPDK TSC is stable and the same for all lcore's.
The comment in rte_cycles.h implied that it could be different per lcore.

Fixes: 040cf8a41187 ("eal: deduplicate timer functions")

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
---
 lib/eal/common/eal_common_timer.c    | 19 +++++++++++++++----
 lib/eal/common/eal_private.h         |  2 +-
 lib/eal/freebsd/eal_timer.c          |  3 +--
 lib/eal/include/generic/rte_cycles.h |  2 +-
 lib/eal/linux/eal_timer.c            |  3 +--
 lib/eal/windows/eal_timer.c          |  3 +--
 6 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/lib/eal/common/eal_common_timer.c b/lib/eal/common/eal_common_timer.c
index e00be0a5c8d..8f374bd33a7 100644
--- a/lib/eal/common/eal_common_timer.c
+++ b/lib/eal/common/eal_common_timer.c
@@ -48,8 +48,8 @@ estimate_tsc_freq(void)
 	return RTE_ALIGN_MUL_NEAR(rte_rdtsc() - start, CYC_PER_10MHZ);
 }
 
-void
-set_tsc_freq(void)
+int
+init_tsc_freq(void)
 {
 	struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
 	uint64_t freq;
@@ -61,18 +61,29 @@ set_tsc_freq(void)
 		 * systems where arch-specific frequency detection is not
 		 * available.
 		 */
+		if (mcfg->tsc_hz == 0) {
+			EAL_LOG(ERR, "Primary process TSC frequency is zero");
+			return -1;
+		}
+
 		eal_tsc_resolution_hz = mcfg->tsc_hz;
-		return;
+		return 0;
 	}
 
 	freq = get_tsc_freq_arch();
 	freq = get_tsc_freq(freq);
-	if (!freq)
+	if (freq == 0) {
 		freq = estimate_tsc_freq();
+		if (freq == 0) {
+			EAL_LOG(ERR, "TSC frequency is too slow");
+			return -1;
+		}
+	}
 
 	EAL_LOG(DEBUG, "TSC frequency is ~%" PRIu64 " KHz", freq / 1000);
 	eal_tsc_resolution_hz = freq;
 	mcfg->tsc_hz = freq;
+	return 0;
 }
 
 void rte_delay_us_callback_register(void (*userfunc)(unsigned int))
diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h
index a10db6a399b..4328718018b 100644
--- a/lib/eal/common/eal_private.h
+++ b/lib/eal/common/eal_private.h
@@ -367,7 +367,7 @@ int eal_cpu_detected(unsigned lcore_id);
  *
  * This function is private to the EAL.
  */
-void set_tsc_freq(void);
+int init_tsc_freq(void);
 
 /**
  * Get precise TSC frequency from system
diff --git a/lib/eal/freebsd/eal_timer.c b/lib/eal/freebsd/eal_timer.c
index 4eba66eadb6..d4f34c3c2b5 100644
--- a/lib/eal/freebsd/eal_timer.c
+++ b/lib/eal/freebsd/eal_timer.c
@@ -63,6 +63,5 @@ get_tsc_freq(uint64_t arch_hz)
 int
 rte_eal_timer_init(void)
 {
-	set_tsc_freq();
-	return 0;
+	return init_tsc_freq();
 }
diff --git a/lib/eal/include/generic/rte_cycles.h b/lib/eal/include/generic/rte_cycles.h
index 7cfd51f0eb2..f8e1cde3324 100644
--- a/lib/eal/include/generic/rte_cycles.h
+++ b/lib/eal/include/generic/rte_cycles.h
@@ -34,7 +34,7 @@ extern enum timer_source eal_timer_source;
  * Get the measured frequency of the RDTSC counter
  *
  * @return
- *   The TSC frequency for this lcore
+ *   The TSC frequency for all lcores, always non-zero
  */
 uint64_t
 rte_get_tsc_hz(void);
diff --git a/lib/eal/linux/eal_timer.c b/lib/eal/linux/eal_timer.c
index 489732c1168..b37efa93f65 100644
--- a/lib/eal/linux/eal_timer.c
+++ b/lib/eal/linux/eal_timer.c
@@ -269,6 +269,5 @@ rte_eal_timer_init(void)
 
 	eal_timer_source = EAL_TIMER_TSC;
 
-	set_tsc_freq();
-	return 0;
+	return init_tsc_freq();
 }
diff --git a/lib/eal/windows/eal_timer.c b/lib/eal/windows/eal_timer.c
index 020035c4ccd..2ec84e70748 100644
--- a/lib/eal/windows/eal_timer.c
+++ b/lib/eal/windows/eal_timer.c
@@ -92,6 +92,5 @@ get_tsc_freq(uint64_t arch_hz)
 int
 rte_eal_timer_init(void)
 {
-	set_tsc_freq();
-	return 0;
+	return init_tsc_freq();
 }
-- 
2.47.3

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2026-10-27 11:43:58.324504224 +0000
+++ 0119-eal-fail-initialization-if-TSC-frequency-is-zero.patch	2026-10-27 11:43:53.650063658 +0000
@@ -1 +1 @@
-From 0eaf8e5afb77d40471148f3515d2ca857acb5fe6 Mon Sep 17 00:00:00 2001
+From 1b58f3125c37d9c34937c5b655d572d54a9fde46 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 0eaf8e5afb77d40471148f3515d2ca857acb5fe6 ]
+
@@ -35 +37 @@
-index bbf8b8b11b..67ede70c62 100644
+index e00be0a5c8d..8f374bd33a7 100644
@@ -38 +40 @@
-@@ -52,8 +52,8 @@ estimate_tsc_freq(void)
+@@ -48,8 +48,8 @@ estimate_tsc_freq(void)
@@ -49 +51 @@
-@@ -65,18 +65,29 @@ set_tsc_freq(void)
+@@ -61,18 +61,29 @@ set_tsc_freq(void)
@@ -80 +82 @@
- RTE_EXPORT_SYMBOL(rte_delay_us_callback_register)
+ void rte_delay_us_callback_register(void (*userfunc)(unsigned int))
@@ -82 +84 @@
-index 8507791ec2..6b9a3d521e 100644
+index a10db6a399b..4328718018b 100644
@@ -85 +87 @@
-@@ -395,7 +395,7 @@ int eal_cpu_detected(unsigned lcore_id);
+@@ -367,7 +367,7 @@ int eal_cpu_detected(unsigned lcore_id);
@@ -95 +97 @@
-index d21ffa2694..b966c30258 100644
+index 4eba66eadb6..d4f34c3c2b5 100644
@@ -98 +100 @@
-@@ -65,6 +65,5 @@ get_tsc_freq(uint64_t arch_hz)
+@@ -63,6 +63,5 @@ get_tsc_freq(uint64_t arch_hz)
@@ -107 +109 @@
-index 7cfd51f0eb..f8e1cde332 100644
+index 7cfd51f0eb2..f8e1cde3324 100644
@@ -120 +122 @@
-index 39f975b6b9..c425ea4ed8 100644
+index 489732c1168..b37efa93f65 100644
@@ -123 +125 @@
-@@ -99,6 +99,5 @@ rte_eal_timer_init(void)
+@@ -269,6 +269,5 @@ rte_eal_timer_init(void)
@@ -132 +134 @@
-index 33cbac6a03..1e381ad673 100644
+index 020035c4ccd..2ec84e70748 100644
@@ -135 +137 @@
-@@ -94,6 +94,5 @@ get_tsc_freq(uint64_t arch_hz)
+@@ -92,6 +92,5 @@ get_tsc_freq(uint64_t arch_hz)


More information about the stable mailing list