From: Stephen Hemminger <stephen@networkplumber.org>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: dev@dpdk.org, "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>
Subject: Re: [RFC] random: use per lcore state
Date: Mon, 11 Sep 2023 09:04:03 -0700 [thread overview]
Message-ID: <20230911090403.1c9afa42@fedora> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D87B7C@smartserver.smartshare.dk>
On Wed, 6 Sep 2023 19:54:32 +0200
Morten Brørup <mb@smartsharesystems.com> wrote:
> >
> > - idx = rte_lcore_id();
> > + seed = __atomic_load_n(&rte_rand_seed, __ATOMIC_RELAXED);
> > + if (unlikely(seed != rand_state->seed)) {
>
> 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].
>
> This is in the hot path.
>
> 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.
next prev parent reply other threads:[~2023-09-11 16:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-06 17:20 [RFC] random: use per lcore state Stephen Hemminger
2023-09-06 17:54 ` Morten Brørup
2023-09-11 16:04 ` Stephen Hemminger [this message]
2023-09-11 16:37 ` Morten Brørup
2023-09-06 18:16 ` Morten Brørup
2023-09-06 19:55 ` Stephen Hemminger
2023-09-06 20:12 ` Mattias Rönnblom
2023-09-06 20:02 ` Mattias Rönnblom
2023-09-06 23:00 ` Stephen Hemminger
2023-09-08 7:04 ` Mattias Rönnblom
2023-09-11 16:06 ` Stephen Hemminger
2023-09-11 16:53 ` Mattias Rönnblom
2023-09-09 0:13 ` Konstantin Ananyev
2023-09-09 6:45 ` Mattias Rönnblom
2023-09-09 11:23 ` Morten Brørup
2023-09-11 9:00 ` Mattias Rönnblom
2023-09-11 16:02 ` Stephen Hemminger
2023-09-09 11:32 ` Stephen Hemminger
2023-09-10 13:26 ` Konstantin Ananyev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230911090403.1c9afa42@fedora \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=mattias.ronnblom@ericsson.com \
--cc=mb@smartsharesystems.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.