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 A04E643B4B; Mon, 19 Feb 2024 15:04:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 26E0F40289; Mon, 19 Feb 2024 15:04:13 +0100 (CET) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by mails.dpdk.org (Postfix) with ESMTP id 1D01040275 for ; Mon, 19 Feb 2024 15:04:12 +0100 (CET) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 9315CCE2F for ; Mon, 19 Feb 2024 15:04:11 +0100 (CET) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 86B84CDD2; Mon, 19 Feb 2024 15:04:11 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on hermod.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED,AWL, T_SCC_BODY_TEXT_LINE autolearn=disabled version=4.0.0 X-Spam-Score: -1.4 Received: from [192.168.1.59] (h-62-63-215-114.A163.priv.bahnhof.se [62.63.215.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 17ABFCDD0; Mon, 19 Feb 2024 15:04:10 +0100 (CET) Message-ID: <06491a83-759a-4a78-950f-404d936e5158@lysator.liu.se> Date: Mon, 19 Feb 2024 15:04:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC v2 3/5] random: keep PRNG state in lcore variable Content-Language: en-US To: =?UTF-8?Q?Morten_Br=C3=B8rup?= , =?UTF-8?Q?Mattias_R=C3=B6nnblom?= , dev@dpdk.org Cc: Stephen Hemminger References: <20240208181644.455233-2-mattias.ronnblom@ericsson.com> <20240219094036.485727-1-mattias.ronnblom@ericsson.com> <20240219094036.485727-4-mattias.ronnblom@ericsson.com> <98CBD80474FA8B44BF855DF32C47DC35E9F22F@smartserver.smartshare.dk> From: =?UTF-8?Q?Mattias_R=C3=B6nnblom?= In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F22F@smartserver.smartshare.dk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP 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 2024-02-19 12:22, Morten Brørup wrote: >> From: Mattias Rönnblom [mailto:mattias.ronnblom@ericsson.com] >> Sent: Monday, 19 February 2024 10.41 >> >> Replace keeping PRNG state in a RTE_MAX_LCORE-sized static array of >> cache-aligned and RTE_CACHE_GUARDed struct instances with keeping the >> same state in a more cache-friendly lcore variable. >> >> Signed-off-by: Mattias Rönnblom >> --- > > [...] > >> @@ -19,14 +20,12 @@ struct rte_rand_state { >> uint64_t z3; >> uint64_t z4; >> uint64_t z5; >> - RTE_CACHE_GUARD; >> -} __rte_cache_aligned; >> +}; >> >> -/* One instance each for every lcore id-equipped thread, and one >> - * additional instance to be shared by all others threads (i.e., all >> - * unregistered non-EAL threads). >> - */ >> -static struct rte_rand_state rand_states[RTE_MAX_LCORE + 1]; >> +RTE_LCORE_VAR_HANDLE(struct rte_rand_state, rand_state); >> + >> +/* instance to be shared by all unregistered non-EAL threads */ >> +static struct rte_rand_state unregistered_rand_state >> __rte_cache_aligned; > > The unregistered_rand_state instance is still __rte_cache_aligned; consider also adding an RTE_CACHE_GUARD to it. > It shouldn't be cache-line aligned. I'll remove it. Thanks.