From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by dpdk.org (Postfix) with ESMTP id D555568AE for ; Mon, 21 Jul 2014 22:42:33 +0200 (CEST) Received: by mail-pd0-f176.google.com with SMTP id y10so9720575pdj.7 for ; Mon, 21 Jul 2014 13:43:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=1lYtq3Y+OGglbj/YODTZNORXH5XQ4kY98LUpdC0RgC0=; b=PlwziFo+MpYOKUMsAhfsKEov1XcJHvmJlM/58pMjWHEuHrj4wiJ9mxuV8nYbONUS3r rK+A4enazqKLs7GcKz3kn919gg3EtGj7qi5lIUgFF4Rm35f0w6DcE1yaP7iqhQmEyo3q obt2RNGZXOrYYQbfc2iHK2BRDawu508jEVJ+CHV2Tjunneo1w/m3dzHYHdYRvSBZi783 qPU0cWEQ4FLUxbsVGV5aXOOAgIUwJwQxsWqgakttlyYqHXI1nPgGqF89TIOdMjovKK28 AJ9nbJng072wz/DbqMRUElqTHpawAwJS/ZDzj3zva8vxjac0J8UjxBLmTbgMXdVEKho+ pKFA== X-Gm-Message-State: ALoCoQk/H8Zf8Ob2Lg1MtyMl2HvNl55aBQwfVhjmldj5CL0wTnDQHdJYDutNLItQwgIvaQsVpf07 X-Received: by 10.66.102.73 with SMTP id fm9mr28497530pab.72.1405975428668; Mon, 21 Jul 2014 13:43:48 -0700 (PDT) Received: from haswell (static-50-53-66-61.bvtn.or.frontiernet.net. [50.53.66.61]) by mx.google.com with ESMTPSA id fb7sm20320279pdb.68.2014.07.21.13.43.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jul 2014 13:43:48 -0700 (PDT) Date: Mon, 21 Jul 2014 13:43:50 -0700 From: Stephen Hemminger To: Neil Horman Message-ID: <20140721134350.70ad9fba@haswell> In-Reply-To: <20140721195415.GA25740@hmsreliant.think-freely.org> References: <20140721195415.GA25740@hmsreliant.think-freely.org> X-Mailer: Claws Mail 3.10.1 (GTK+ 2.24.24; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] Random numbers at line-rate X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jul 2014 20:42:34 -0000 On Mon, 21 Jul 2014 15:54:15 -0400 Neil Horman wrote: > On Mon, Jul 21, 2014 at 09:24:36PM +0200, Chris Pappas wrote: > > Hi, > > > > I need to generate a random number per packet and I used the rte_fast_rand > > function to do so. When I run the code for one port-core I get almost > > line-rate performance. However, running simultaneously on multiple cores > > degrades performance significantly. (in all cases I uses minimum-sized > > packets). > > > > Shouldn't the implementation scale for multicore and not degrade > > performance or am I missing anything? Also, is there another recommendation > > for generating randomness at line-rate? (the cpu does not support rdrand). > > > > Best regards, > > Chris > > > > thats an odd random number generator. I think, without locking, its likely on a > multicore system to produce identical values on multiple cores operating in > parallel (since multiple cores can read rte_red_rand_seed at the same time). > That may well lead to multiple packets having the same nonce, which might cause > odd behavior. > > If your cpu supports it, I'd suggest writing some inline assembly to use the > rdrand instruction instead. I'm not sure about its performance relative to the > current implementation, but IIRC the instruction is handled internal to the > core, so it should scale with any number of cpus. > > neil > Or just do per-core seed value (and use RTE_PER_LCORE)