From patchwork Tue Jun 20 21:17:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 128875 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B56942D0C; Tue, 20 Jun 2023 23:17:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9385C410F6; Tue, 20 Jun 2023 23:17:42 +0200 (CEST) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by mails.dpdk.org (Postfix) with ESMTP id 80C59410D7 for ; Tue, 20 Jun 2023 23:17:41 +0200 (CEST) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-4f86a7a5499so4589405e87.2 for ; Tue, 20 Jun 2023 14:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687295860; x=1689887860; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=uq5/bHWUobJnBbaHJVEryoGkBwmYgrF7m5oLVrnhKXo=; b=kKj22PRDviqTPRCtWN5rKa1zOi9dhGiAIk337qPq69kpdBifIamZ5VwVbgV4yb74gt t025iShSW+hqlbrQdFdUQBXHvpjCFZzyo+6rfbzPVkwKMYryti71C19jcoMeAyvuAa7B kxCLkrvCyyeVH5o1jbFeSOaBEYmXU+hEGyVC30GG2Pl3DxANQTgFJzDnlgQcF97oMwX1 1LmcXcJzgHehI5AN0ESqaEt3o3x4ypk2VHArZCg+HxMy9usn4j1e8xOSL+ssOMJDHznG IVzmMoim/UXWRC3QoionDOorVS2Fu9VPx5kzbjO9GPiX7nB0Zzijfsqr1QMPHZg35cQu 1u1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687295860; x=1689887860; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uq5/bHWUobJnBbaHJVEryoGkBwmYgrF7m5oLVrnhKXo=; b=BG4S2Xbxfps63h9tzvi1wGG0i4GToRzgUVcojBAy5GIfhfBfVJ3zeeTopMBv71TWWx j0rrqnkyA++uCdxSioIciONMkBe1q977VsVVkT2EeDmsV0TA7JC6rwygsXIxUEZihANV XEw6chP2qazYVo28D6kZL2KUO+UKe9NTP88qn5eYmobsX2ZjLUaWoFffZrLRYtStd5o6 FY1H6JzaB9qcmhiFTHEBqAd4NMsKKYQUXpmOSOw6TtpV2pVi0LVDp+0BaBP4K7HJx7VL MLgGikZdvXaUjwgNFSLVFXeFUb0CuFY7hPQ2HhM4S/TgjdVDo78vEpQqhbZ7uZQ0he7X mPQQ== X-Gm-Message-State: AC+VfDyc/kogkkh77NhX2+maC8GTQl9TPzuG1V2S/XcasaJndNSSbLtw oCSh0D2rNlnigSLqwOCEGnfUuAOeBSc= X-Google-Smtp-Source: ACHHUZ6gUyBsK7hwSc8cuDbyxpFfiRsECNCPpZFm+6fQJ0Vz3Rr5lZaV3El/Nab6S/v54LsSiCMRYA== X-Received: by 2002:a19:4409:0:b0:4f8:7556:23e6 with SMTP id r9-20020a194409000000b004f8755623e6mr3194784lfa.54.1687295860201; Tue, 20 Jun 2023 14:17:40 -0700 (PDT) Received: from sovereign.. (broadband-109-173-110-33.ip.moscow.rt.ru. [109.173.110.33]) by smtp.gmail.com with ESMTPSA id y5-20020a197505000000b004f62229b6c9sm493932lfe.89.2023.06.20.14.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 14:17:39 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , leyi.rong@intel.com, Yipeng Wang , Sameh Gobriel , Alan Liu Subject: [PATCH] member: fix PRNG seed reset in NitroSketch mode Date: Wed, 21 Jun 2023 00:17:20 +0300 Message-Id: <20230620211720.350336-1-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.38.4 MIME-Version: 1.0 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 Sketch creation seeded the global PRNG using the supplied seed for hashing. The use of this seed by SKETCH set summary was not documented. SKETCH set summary does not require two independent hash seeds, unlike other set summary types. Seeding the global PRNG at sketch creation does not make the sketch operation deterministic: it uses rte_rand() later, the PRNG may be seeded again by that point. On the other hand, seeding the global PRNG with a hash seed, is likely undesired, because it may be low-entropy or even constant. Deterministic operation can be achieved by seeding the PRNG externally. Remove the call to rte_srand() at sketch creation. Document that hash seeds are not used by SKETCH set summary type. Fixes: db354bd2e1f8 ("member: add NitroSketch mode") Cc: leyi.rong@intel.com Signed-off-by: Dmitry Kozlyuk Acked-by: Stephen Hemminger --- lib/member/rte_member.h | 1 + lib/member/rte_member_sketch.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/member/rte_member.h b/lib/member/rte_member.h index 072a253c89..d08b143e51 100644 --- a/lib/member/rte_member.h +++ b/lib/member/rte_member.h @@ -314,6 +314,7 @@ struct rte_member_parameters { * for bucket location. * For vBF type, these two hashes and their combinations are used as * hash locations to index the bit array. + * For Sketch type, these seeds are not used. */ uint32_t prim_hash_seed; diff --git a/lib/member/rte_member_sketch.c b/lib/member/rte_member_sketch.c index 524ba77620..d5f35aabe9 100644 --- a/lib/member/rte_member_sketch.c +++ b/lib/member/rte_member_sketch.c @@ -227,7 +227,6 @@ rte_member_create_sketch(struct rte_member_setsum *ss, goto error_runtime; } - rte_srand(ss->prim_hash_seed); for (i = 0; i < ss->num_row; i++) ss->hash_seeds[i] = rte_rand();