DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Medvedkin, Vladimir" <vladimir.medvedkin@intel.com>
Cc: <dev@dpdk.org>, Yipeng Wang <yipeng1.wang@intel.com>,
	Sameh Gobriel <sameh.gobriel@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>
Subject: Re: [PATCH v3 2/4] hash: add dynamic polynomial calculation
Date: Wed, 16 Oct 2024 20:23:44 -0700	[thread overview]
Message-ID: <20241016202344.000c00f1@hermes.local> (raw)
In-Reply-To: <9bd9e943-d277-44cb-86c4-36db3f1acf88@intel.com>

On Wed, 16 Oct 2024 17:28:17 +0100
"Medvedkin, Vladimir" <vladimir.medvedkin@intel.com> wrote:

> Hi Stephen,
> 
> On 15/10/2024 23:29, Stephen Hemminger wrote:
> > On Fri, 11 Oct 2024 18:17:00 +0000
> > Vladimir Medvedkin<vladimir.medvedkin@intel.com>  wrote:
> >  
> >> +
> >> +uint32_t
> >> +rte_thash_get_rand_poly(uint32_t poly_degree)
> >> +{
> >> +	uint32_t ret_poly;
> >> +
> >> +	if (poly_degree > 32)

Error log here?

> >> +		return 0;
> >> +
> >> +	do
> >> +		ret_poly = __thash_get_rand_poly(poly_degree);
> >> +	while (thash_test_poly_order(ret_poly, poly_degree));  
> > Unbounded loop adds some risk, should there be an upper limit on retries.  
> 
> Thisis the probabilisticpartof the algorithm.
> 
> __thash_get_rand_poly() returns a random polynomial that either 
> satisfies the order criteria (element <x> of the field must generate 
> multiplicative subgroup of order not less than some number), or not. The 
> probability that it does not meet this criteria is strictly less than 1. 
> Thus, with each attempt, the probability of not finding suitable 
> polynomial exponentially tends to zero.

Never trust probabilities to converge. Just add an upper bound of something big
like 32 tries and log error and give up.

> 
> >  
> >> +
> >> +	return ret_poly;
> >> +}
> >> diff --git a/lib/hash/version.map b/lib/hash/version.map
> >> index 4f13f1d5aa..7ce6ab1121 100644
> >> --- a/lib/hash/version.map
> >> +++ b/lib/hash/version.map
> >> @@ -61,4 +61,5 @@ INTERNAL {
> >>   
> >>   	rte_thash_gfni_stub;
> >>   	rte_thash_gfni_bulk_stub;
> >> +	rte_thash_get_rand_poly;  
> > Why does this function need to be moved to its own file?
> > Only used in one place in rte_thash.c.  
> It was done just for convenience. If you insist, I'll move it to rte_thash.c


It is actually good to put in seperate file, but you can keep the old name.
Best to reserve names with rte_ prefix for user visible prefixes.



  reply	other threads:[~2024-10-17  3:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 12:33 [PATCH v2 0/4] RSS hash key generation Vladimir Medvedkin
2024-10-10 12:33 ` [PATCH v2 1/4] thash: add RSS hash key generation API Vladimir Medvedkin
2024-10-10 15:04   ` Stephen Hemminger
2024-10-10 12:33 ` [PATCH v2 2/4] hash: add dynamic polynomial calculation Vladimir Medvedkin
2024-10-10 12:33 ` [PATCH v2 3/4] hash: implement RSS hash key generation API Vladimir Medvedkin
2024-10-10 12:33 ` [PATCH v2 4/4] test/thash: add tests for RSS " Vladimir Medvedkin
2024-10-11 18:16 ` [PATCH v3 0/4] RSS hash key generation Vladimir Medvedkin
2024-10-11 18:16   ` [PATCH v3 1/4] thash: add RSS hash key generation API Vladimir Medvedkin
2024-10-11 18:17   ` [PATCH v3 2/4] hash: add dynamic polynomial calculation Vladimir Medvedkin
2024-10-15 22:29     ` Stephen Hemminger
2024-10-16 16:28       ` Medvedkin, Vladimir
2024-10-17  3:23         ` Stephen Hemminger [this message]
2024-10-18 13:42           ` Medvedkin, Vladimir
2024-10-11 18:17   ` [PATCH v3 3/4] hash: implement RSS hash key generation API Vladimir Medvedkin
2024-10-11 18:17   ` [PATCH v3 4/4] test/thash: add tests for RSS " Vladimir Medvedkin
2024-10-24 18:46   ` [PATCH v4 0/4] RSS hash key generation Vladimir Medvedkin
2024-10-24 18:46     ` [PATCH v4 1/4] thash: add RSS hash key generation API Vladimir Medvedkin
2024-10-24 19:05       ` Stephen Hemminger
2024-10-24 18:46     ` [PATCH v4 2/4] hash: add dynamic polynomial calculation Vladimir Medvedkin
2024-10-24 19:06       ` Stephen Hemminger
2024-10-24 18:46     ` [PATCH v4 3/4] hash: implement RSS hash key generation API Vladimir Medvedkin
2024-10-24 19:06       ` Stephen Hemminger
2024-10-24 18:46     ` [PATCH v4 4/4] test/thash: add tests for RSS " Vladimir Medvedkin
2024-10-24 19:06       ` Stephen Hemminger
2024-11-11 12:55     ` [PATCH v4 0/4] RSS hash key generation Thomas Monjalon

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=20241016202344.000c00f1@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=sameh.gobriel@intel.com \
    --cc=vladimir.medvedkin@intel.com \
    --cc=yipeng1.wang@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).