* DPDK PIE computation is broken
@ 2022-05-23 22:49 Stephen Hemminger
0 siblings, 0 replies; only message in thread
From: Stephen Hemminger @ 2022-05-23 22:49 UTC (permalink / raw)
To: Cristian Dumitrescu, Jasvinder Singh; +Cc: dev
Was looking at where rte_rand() is currently used in DPDK.
Found that rte_pie uses it (that is expected.
But it also using it wrong on a couple of levels.
First. Look at:
#define RTE_RAND_MAX ~0LLU /**< Max value of the random number */
_rte_pie_drop(const struct rte_pie_config *pie_cfg,
struct rte_pie *pie)
{
uint64_t rand_value;
...
rand_value = rte_rand()/RTE_RAND_MAX;
if ((double)rand_value < pie->drop_prob) {
pie->accu_prob = 0;
return 1;
}
/* No drop */
return 0;
Since rand_value is 64 bit unsigned value the division happens as unsigned
Therefore for all values of rte_rand(). rand_value is going to be 0
Converting it to double just makes it zero in another form.
How was PIE tested? Why was this not seen.
Second, the obvious fix would be to make rand_value a double.
But doing floating point divide in the packet path would be a major
performance loss. Saw this earlier with the packet_sched code.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-23 22:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23 22:49 DPDK PIE computation is broken 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).