DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Cristian Dumitrescu <cristian.dumitrescu@intel.com>,
	Jasvinder Singh <jasvinder.singh@intel.com>
Cc: dev@dpdk.org
Subject: DPDK PIE computation is broken
Date: Mon, 23 May 2022 15:49:46 -0700	[thread overview]
Message-ID: <20220523154946.5a4bcb33@hermes.local> (raw)

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.




                 reply	other threads:[~2022-05-23 22:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220523154946.5a4bcb33@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=jasvinder.singh@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).