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 01F9A42570; Mon, 11 Sep 2023 18:04:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1737402D6; Mon, 11 Sep 2023 18:04:07 +0200 (CEST) Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by mails.dpdk.org (Postfix) with ESMTP id A8B83402CE for ; Mon, 11 Sep 2023 18:04:06 +0200 (CEST) Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-9a63b2793ecso586412366b.2 for ; Mon, 11 Sep 2023 09:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1694448246; x=1695053046; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=UgTxGJge1WWRoNfc5k09xV7rszJATgYynphjYXqiSRk=; b=PJQqs6lDPXgEbZFbshvbCJEfvHsd1BwgO8xgURj3YXp4aftBeI8PIvITxNb2YXcn8f I15vny4NbbeM/A/G/ZQphZz4DmnbTU5zYFtEWLBwvA0NzrUnhvAPbS5lWiUpUpNuon1q C/q6NetbPQA/ZvQJ2f0OjwmMkqrcU4hH7Uqtw3bAyfiD6CvuSBk8OcsOrIUh/4T6Vr3e y16qaCjA1vL2rqgxFH+85EiuB3SSOBaqQghylvjiS/7QYIyDUqD2uN42cKpMAFLepsQe TEhkXAf/6NKqM/seMpVm0Swa583Z4b6TBZnZDTtF1YYkM14/pgP8y5MZ1E2cQ0AIzY5P Vrtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694448246; x=1695053046; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UgTxGJge1WWRoNfc5k09xV7rszJATgYynphjYXqiSRk=; b=u/cG9AVbyoSlp4PWYOEts2Ln+LCIw78C+X9H4H9PTm1UvdDaKANJXxO1kmK8/1RbBD tsiaQBO48RDkxRd74L+A6RyrEWpTNK/+Q7uSyDSmxHx9N2FHerd636yWAwsWJGDaDryb E5Mut7YvvPrek7yhlfnLayNz3AjwyLZXLhceHteI6iWcRBfh98avKgoZghoqUxRYopMR 8BR6LXGk0jn27Wf2zJvuEXymqCwkvlQOu7tdw1Dpu4ADGnea8TXHRPI9Y36IEDXtO7gh qMbHKqynlVfJoLmR7vGN0+ThYWeV90GHu2FnWgxGw+cbsR2JZl0R6MHVxgqp6kpadtrv e52w== X-Gm-Message-State: AOJu0YxTlB5OhiEr/XFQvFDTN2V86GK7UNL2YWPcnqJd2CSIkjZ3cDsF zqOThp9ZCMcTC91ZV52P7H4BBJmZzlYa8q0wQXga0w== X-Google-Smtp-Source: AGHT+IHK/DKCP34LRGmJpb7VpbXGyP5noq1P7jJuLjCXHrO7AzFWoLNbISAi3xZG7uFxLmVkOe5IoA== X-Received: by 2002:a17:907:77c1:b0:99c:75f7:19c1 with SMTP id kz1-20020a17090777c100b0099c75f719c1mr8559037ejc.39.1694448246186; Mon, 11 Sep 2023 09:04:06 -0700 (PDT) Received: from fedora ([79.140.208.123]) by smtp.gmail.com with ESMTPSA id a5-20020a17090682c500b00993664a9987sm5516540ejy.103.2023.09.11.09.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 09:04:05 -0700 (PDT) Date: Mon, 11 Sep 2023 09:04:03 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: , Mattias =?UTF-8?B?UsO2bm5ibG9t?= Subject: Re: [RFC] random: use per lcore state Message-ID: <20230911090403.1c9afa42@fedora> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D87B7C@smartserver.smartshare.dk> References: <20230906172013.169846-1-stephen@networkplumber.org> <98CBD80474FA8B44BF855DF32C47DC35D87B7C@smartserver.smartshare.dk> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Wed, 6 Sep 2023 19:54:32 +0200 Morten Br=C3=B8rup wrote: > >=20 > > - idx =3D rte_lcore_id(); > > + seed =3D __atomic_load_n(&rte_rand_seed, __ATOMIC_RELAXED); > > + if (unlikely(seed !=3D rand_state->seed)) { =20 >=20 > Please note that rte_rand_seed lives in a completely different cache > line than RTE_PER_LCORE(rte_rand_state), so the comparison with > rte_rand_seed requires reading one more cache line than the original > implementation, which only uses the cache line holding > rand_states[idx]. >=20 > This is in the hot path. >=20 > If we could register a per-thread INIT function, the lazy > initialization could be avoided, and only one cache line accessed. Since rte_rand_seed rarely changes, it will get cached by each cpu. The problem was before there was prefetch cache overlap causing false sharing.