From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 85795A0679 for ; Fri, 5 Apr 2019 16:56:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2421B1B53A; Fri, 5 Apr 2019 16:56:28 +0200 (CEST) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by dpdk.org (Postfix) with ESMTP id 03C531B539 for ; Fri, 5 Apr 2019 16:56:27 +0200 (CEST) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 839F74000A for ; Fri, 5 Apr 2019 16:56:26 +0200 (CEST) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 6AFAF40010; Fri, 5 Apr 2019 16:56:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on bernadotte.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=ALL_TRUSTED,AWL autolearn=disabled version=3.4.1 X-Spam-Score: -0.9 Received: from [192.168.1.59] (host-90-232-144-184.mobileonline.telia.com [90.232.144.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 6B81D4000A; Fri, 5 Apr 2019 16:56:24 +0200 (CEST) To: Bruce Richardson Cc: dev@dpdk.org References: <20190405134542.28618-1-mattias.ronnblom@ericsson.com> <7428acf8-fd06-fcc5-521b-37ee0fa1729a@ericsson.com> <20190405142829.GA1710@bricha3-MOBL.ger.corp.intel.com> From: =?UTF-8?Q?Mattias_R=c3=b6nnblom?= Message-ID: <41b8d6bd-57da-a5e1-e2c8-f736b80b68ec@ericsson.com> Date: Fri, 5 Apr 2019 16:56:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190405142829.GA1710@bricha3-MOBL.ger.corp.intel.com> Content-Type: text/plain; charset="UTF-8"; format="flowed" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: [dpdk-dev] [RFC] eal: make rte_rand() MT safe 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" Message-ID: <20190405145624.H2XXuJ4W_ll-wfl5qyehIajqnYGsuofJC4PYe0GgMF0@z> On 2019-04-05 16:28, Bruce Richardson wrote: > On Fri, Apr 05, 2019 at 03:51:39PM +0200, Mattias Rönnblom wrote: >> On 2019-04-05 15:45, Mattias Rönnblom wrote: >>> The rte_rand() documentation left it unspecified if the rte_rand() was >>> multi-thread safe or not, and the implementation (based on lrand48()) >>> was not. >>> >>> This commit makes rte_rand() safe to use from any lcore thread by >>> using lrand48_r() and per-lcore random state structs. Besides the >>> obvious improvement in terms of correctness (for concurrent users), >>> this also much improves rte_rand() performance, since the threads no >>> longer shares state. For the single-threaded case, this patch causes >>> ~10% rte_rand() performance degradation. >>> >> >> It's a little unclear to me, if lrand48_r() exists in FreeBSD or not. Could >> someone confirm? >> > Nothing shows up for me in the man pages for such a function on FreeBSD 12, > so I suspect they aren't available. > Could arc4random(3) be a good replacement on FreeBSD? It "can be called in almost all coding environments, including pthreads(3)" according to the man page, so assume it's MT safe.