From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9E82945B53; Thu, 17 Oct 2024 05:23:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1179C4021F; Thu, 17 Oct 2024 05:23:48 +0200 (CEST) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mails.dpdk.org (Postfix) with ESMTP id 6D06240144 for ; Thu, 17 Oct 2024 05:23:47 +0200 (CEST) Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-71e4e481692so400846b3a.1 for ; Wed, 16 Oct 2024 20:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729135426; x=1729740226; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=JrTAg55+q7Q/rLAb+FZALtURjbzLk1hVL8V2Rpci8lg=; b=liHirOzQDSdBt5E4nCxucBWHGO/pZzwJ3/YWUBEWdXoLflkh3d7RBytvj4cBtDm6Gx uWLsmHFt7CkrrAHwEJwPPNnK/Q+dapnu5+DZpO2dzTz0oB5kjlL5siJGqsVgGcqorJXp VBYIxdV2FA1eRldqpWjXQy5MT2RA2rf6dJ13sbigX1CoQRU10jyqjVH02DYNARYYUZja afI1fgZ9YlKpsk/GhImpa9+AlfccKaGFkymX+fgwtuHn1tdlpvWPZRlF+JGYYShWVE7U doQiYJEEyGQaYX379pAdoT4jRhLDFM7C/84mTAp7sU9927vf9AEo3uZyDiElONZwZZuu f3kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729135426; x=1729740226; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JrTAg55+q7Q/rLAb+FZALtURjbzLk1hVL8V2Rpci8lg=; b=abNmcvHyjj9Xzrp3KlPBJ3H00sd8LkDEd39RGzwKVXlVpjuw8uUu0acdjP1HRgi9tg AqSdC9UzXaFN0mzWGUnK5N4xdre17iXBNxPns6isGIYXuG+Uk6msm77z3e9NWI5rGYYt crG1YTixkOafIxlS2q722o57ho0zHBU+tDa0NCO4K+jXNHj8iYcxWoNtl4kWyOQO9VhM egGyTw7J9qWB1V4r15kcfmbNwojtd5QOPsHkfHIY4GzSvaD1SmpirxaSu+wJ4YLHTTc2 J815yLWqHydL7Vg7YQMnX2wDQ6e+VG4drp9gMQWfY0cuVKl16QOG2zu3et3Ege6iKPf3 nJRw== X-Gm-Message-State: AOJu0YzqHCX9HpDzmts2skSQne+eBBhsuEgX8/vyn/EHzbAuJGt7MPar 6nZS2CL2g7PlCeHKCmsZwufSPnt42RAgOyQE/+rUQpOG6XAQCqt2rMK9ej38DiY= X-Google-Smtp-Source: AGHT+IGjGub18c8Xx4U84C1zC8mNEGxozmzOYP/4AeuL332OkT7CQdBeqdmU9I6SE8QSC+Hf5f/Upg== X-Received: by 2002:a05:6a21:670d:b0:1d9:1784:49d with SMTP id adf61e73a8af0-1d91784058cmr4514566637.41.1729135426466; Wed, 16 Oct 2024 20:23:46 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e773b1672sm3816570b3a.83.2024.10.16.20.23.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 20:23:46 -0700 (PDT) Date: Wed, 16 Oct 2024 20:23:44 -0700 From: Stephen Hemminger To: "Medvedkin, Vladimir" Cc: , Yipeng Wang , Sameh Gobriel , Bruce Richardson Subject: Re: [PATCH v3 2/4] hash: add dynamic polynomial calculation Message-ID: <20241016202344.000c00f1@hermes.local> In-Reply-To: <9bd9e943-d277-44cb-86c4-36db3f1acf88@intel.com> References: <20241010123331.749004-1-vladimir.medvedkin@intel.com> <20241011181703.236985-1-vladimir.medvedkin@intel.com> <20241011181703.236985-3-vladimir.medvedkin@intel.com> <20241015152945.530926a1@hermes.local> <9bd9e943-d277-44cb-86c4-36db3f1acf88@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, 16 Oct 2024 17:28:17 +0100 "Medvedkin, Vladimir" wrote: > Hi Stephen, > > On 15/10/2024 23:29, Stephen Hemminger wrote: > > On Fri, 11 Oct 2024 18:17:00 +0000 > > Vladimir Medvedkin 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 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.