patch 'sched: fix data race in RED random number generation' has been queued to stable release 25.11.5
Kevin Traynor
ktraynor at redhat.com
Thu Dec 3 14:06:38 CET 2026
Hi,
FYI, your patch has been queued to stable release 25.11.5
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/08/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/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/ca072a16d241a2ae7cd8d78da2a4f7f9fb305985
Thanks.
Kevin
---
>From ca072a16d241a2ae7cd8d78da2a4f7f9fb305985 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Fri, 9 Oct 2026 18:59:15 -0700
Subject: [PATCH] sched: fix data race in RED random number generation
[ upstream commit ea1283bae8606ec574b40b8a63c1e184d61f038e ]
The RED scheduler used its own random number generator which was
weak and buggy. Change standard rte_rand() which has better
randomness and is thread safe.
There is no prior deprecation notice for related symbols. They were
never meant to be part of the API: rte_fast_rand() is the internal
generator of the dropper and the two variables are its state, all
exposed only because the drop test is inline in rte_red.h.
Fixes: de3cfa2c9823 ("sched: initial import")
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
lib/sched/rte_red.c | 9 +--------
lib/sched/rte_red.h | 26 ++------------------------
2 files changed, 3 insertions(+), 32 deletions(-)
diff --git a/lib/sched/rte_red.c b/lib/sched/rte_red.c
index d7534d0bee..6d20afa9dc 100644
--- a/lib/sched/rte_red.c
+++ b/lib/sched/rte_red.c
@@ -6,12 +6,7 @@
#include <eal_export.h>
#include "rte_red.h"
-#include <rte_random.h>
#include <rte_common.h>
-static int rte_red_init_done = 0; /**< Flag to indicate that global initialisation is done */
-RTE_EXPORT_SYMBOL(rte_red_rand_val)
-uint32_t rte_red_rand_val = 0; /**< Random value cache */
-RTE_EXPORT_SYMBOL(rte_red_rand_seed)
-uint32_t rte_red_rand_seed = 0; /**< Seed for random number generation */
+static int rte_red_init_done; /**< Flag to indicate that global initialisation is done */
/**
@@ -117,6 +112,4 @@ rte_red_config_init(struct rte_red_config *red_cfg,
*/
if (!rte_red_init_done) {
- rte_red_rand_seed = rte_rand();
- rte_red_rand_val = rte_fast_rand();
__rte_red_init_tables();
rte_red_init_done = 1;
diff --git a/lib/sched/rte_red.h b/lib/sched/rte_red.h
index 3b90cc46a9..ad11941ed5 100644
--- a/lib/sched/rte_red.h
+++ b/lib/sched/rte_red.h
@@ -16,4 +16,5 @@
#include <rte_cycles.h>
#include <rte_branch_prediction.h>
+#include <rte_random.h>
#ifdef __cplusplus
@@ -35,6 +36,4 @@ extern "C" {
* Externs
*/
-extern uint32_t rte_red_rand_val;
-extern uint32_t rte_red_rand_seed;
extern uint16_t rte_red_log2_1_minus_Wq[RTE_RED_WQ_LOG2_NUM];
extern uint16_t rte_red_pow2_frac_inv[16];
@@ -103,21 +102,4 @@ rte_red_config_init(struct rte_red_config *red_cfg,
const uint16_t maxp_inv);
-/**
- * @brief Generate random number for RED
- *
- * Implementation based on:
- * http://software.intel.com/en-us/articles/fast-random-number-generator-on-the-intel-pentiumr-4-processor/
- *
- * 10 bit shift has been found through empirical tests (was 16).
- *
- * @return Random number between 0 and (2^22 - 1)
- */
-static inline uint32_t
-rte_fast_rand(void)
-{
- rte_red_rand_seed = (214013 * rte_red_rand_seed) + 2531011;
- return rte_red_rand_seed >> 10;
-}
-
/**
* @brief calculate factor to scale average queue size when queue
@@ -294,10 +276,6 @@ __rte_red_drop(const struct rte_red_config *red_cfg, struct rte_red *red)
pa_den = red_cfg->pa_const - pa_num_count;
- /* If drop, generate and save random number to be used next time */
- if (unlikely((rte_red_rand_val % pa_den) < pa_num)) {
- rte_red_rand_val = rte_fast_rand();
-
+ if (unlikely((rte_rand() % pa_den) < pa_num))
return 1;
- }
/* No drop */
--
2.56.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-12-03 12:52:52.527285598 +0000
+++ 0472-sched-fix-data-race-in-RED-random-number-generation.patch 2026-12-03 12:52:39.359098106 +0000
@@ -1 +1 @@
-From ea1283bae8606ec574b40b8a63c1e184d61f038e Mon Sep 17 00:00:00 2001
+From ca072a16d241a2ae7cd8d78da2a4f7f9fb305985 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit ea1283bae8606ec574b40b8a63c1e184d61f038e ]
+
@@ -16 +17,0 @@
-Cc: stable at dpdk.org
@@ -20,17 +21,4 @@
- doc/guides/rel_notes/release_26_11.rst | 3 +++
- lib/sched/rte_red.c | 9 +--------
- lib/sched/rte_red.h | 26 ++------------------------
- 3 files changed, 6 insertions(+), 32 deletions(-)
-
-diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
-index 99494fda18..160b2f4856 100644
---- a/doc/guides/rel_notes/release_26_11.rst
-+++ b/doc/guides/rel_notes/release_26_11.rst
-@@ -329,4 +329,7 @@ Removed Items
- The ``pipeline`` example application covers the SWX pipeline API.
-
-+* sched: Removed the private random number generator used by RED:
-+ the inline function ``rte_fast_rand()``.
-+
- * metrics: Removed the ``rte_metrics_telemetry.h`` header
- and the experimental telemetry helper API: ``rte_metrics_tel_reg_all_ethdev``,
+ lib/sched/rte_red.c | 9 +--------
+ lib/sched/rte_red.h | 26 ++------------------------
+ 2 files changed, 3 insertions(+), 32 deletions(-)
+
More information about the stable
mailing list