From patchwork Wed Apr 24 12:33:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mattias_R=C3=B6nnblom?= X-Patchwork-Id: 53048 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4ED491B127; Wed, 24 Apr 2019 14:33:25 +0200 (CEST) Received: from sesbmg23.ericsson.net (sesbmg23.ericsson.net [193.180.251.37]) by dpdk.org (Postfix) with ESMTP id 71B1558EC for ; Wed, 24 Apr 2019 14:33:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/relaxed; q=dns/txt; i=@ericsson.com; t=1556109204; x=1558701204; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5AZSNfKDPiqRycEMjU568cQ7bMzvpbBir00ndOn4uwc=; b=K3mzRGukjC8FySGCnrEqgW+Lp5Vm8SdcAXWaHzyrUYUKmx0C+k2ZGhsTa4pb7bzr tVGYtpBLtQcnQOQtQqGwoKG8PuoKWEWrOtJl7P3AExqK23p22XZt1yi6iLqJfwVi aov/qDNexsJGD+MwuVUmGhHtHO9hxnLfYGNNGgObLXs=; X-AuditID: c1b4fb25-399ff700000029f0-aa-5cc057946047 Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id E9.18.10736.49750CC5; Wed, 24 Apr 2019 14:33:24 +0200 (CEST) Received: from ESESBMB504.ericsson.se (153.88.183.171) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 24 Apr 2019 14:33:23 +0200 Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.187) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Wed, 24 Apr 2019 14:33:23 +0200 Received: from breslau.lmera.ericsson.se (breslau.lmera.ericsson.se [150.132.109.241]) by selio1a020.lmera.ericsson.se (8.15.1+Sun/8.15.1) with ESMTP id x3OCXNAc010622; Wed, 24 Apr 2019 14:33:23 +0200 (CEST) From: =?utf-8?q?Mattias_R=C3=B6nnblom?= To: CC: , , =?utf-8?q?Matti?= =?utf-8?q?as_R=C3=B6nnblom?= Date: Wed, 24 Apr 2019 14:33:18 +0200 Message-ID: <20190424123320.19610-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBLMWRmVeSWpSXmKPExsUyM2J7ue6U8AMxBjf72C3efdrOZHGr+SSb xeI7cg7MHr8WLGX16Dk5j8njyvfVjAHMUVw2Kak5mWWpRfp2CVwZX369ZylYzVMx/fpe5gbG O5xdjJwcEgImEnOfbGPrYuTiEBI4yigx4UI3O4TzjVHi+LLXUM5FRonn/V9YIJzLjBJzdh1j AelnE/CUmPyuG8wWERCSWPrxMjuIzSzQwCixcCsHiC0s4CSxtPUZM4jNIqAqcezSckYQmxco vujOJnaIO+QlVm84AFbDKeAgMWfVTDBbSMBe4nbTZyaIekGJkzOfsEDM15Ro3f4bape8RPPW 2VD1WhL3l3xhnsAoNAtJyywkLbOQtCxgZF7FKFqcWpyUm25krJdalJlcXJyfp5eXWrKJERje B7f8Vt3BePmN4yFGAQ5GJR7efMcDMUKsiWXFlbmHGCU4mJVEeE22748R4k1JrKxKLcqPLyrN SS0+xCjNwaIkzhu9ek+MkEB6YklqdmpqQWoRTJaJg1OqgTHf+9NZCbfa2ztjH9aW3/zoJhb1 kGNqgTvjmcs3N0fPqdqeufxdB6+RyNFcC3PHosi9YQE65zzZZ84NvzvJWf9LXpSjoemZYyxW 73dKylYez9TfacL4fdP/yPuMedVs060eWnyd6rExbeWveX3BhVtCoiOOz5c+kD2x4Lj5roa6 zhbHmO1ZbkosxRmJhlrMRcWJAP1m2yBrAgAA Subject: [dpdk-dev] [RFC v3 0/2] Pseudo-random number generation improvements X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Make rte_rand() multi-thread safe, go faster and produce better-quality pseudo-random numbers. Thanks to Stephen Hemminger, Keith Wiles and Neil Horman for valuable feedback. v3: * Since rte_rand() and rte_srand() have been a part of the API since long, the experimental attribute was removed and the symbols were moved out of the experimental section of the version.map file. * rte_rand_max() performance improvements: * Avoid repeated rte_lcore_id() calls. * Handle a power-of-2 upper bound as a special case. * Added a Bugzilla reference to the rte_rand() MT safety bug. v2: * Removed 32-bit version of rte_rand() and rte_rand_max(). * Switched from a four-sequence LFSR (producing a 32-bit number) to a five-sequence LFSR (producing a 64-bit number). * Added a note on generator not being cryptographically secure. Mattias Rönnblom (2): eal: replace libc-based random number generation with LFSR eal: introduce random generator function with upper bound lib/librte_eal/common/include/rte_random.h | 45 +++--- lib/librte_eal/common/meson.build | 1 + lib/librte_eal/common/rte_random.c | 176 +++++++++++++++++++++ lib/librte_eal/freebsd/eal/Makefile | 1 + lib/librte_eal/freebsd/eal/eal.c | 2 - lib/librte_eal/linux/eal/Makefile | 1 + lib/librte_eal/linux/eal/eal.c | 2 - lib/librte_eal/rte_eal_version.map | 3 + 8 files changed, 209 insertions(+), 22 deletions(-) create mode 100644 lib/librte_eal/common/rte_random.c