DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Mattias Rönnblom" <hofors@lysator.liu.se>
Cc: dev@dpdk.org, "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>,
	"Morten Brørup" <mb@smartsharesystems.com>
Subject: Re: [RFC] random: use per lcore state
Date: Wed, 6 Sep 2023 16:00:04 -0700	[thread overview]
Message-ID: <20230906160004.333b0488@hermes.local> (raw)
In-Reply-To: <c661fdd6-ada8-b94e-d01b-b5394eed5d84@lysator.liu.se>

On Wed, 6 Sep 2023 22:02:54 +0200
Mattias Rönnblom <hofors@lysator.liu.se> wrote:

> On 2023-09-06 19:20, Stephen Hemminger wrote:
> > Move the random number state into thread local storage.  
> 
> Me and Morten discussed TLS versus other alternatives in some other 
> thread. The downside of TLS that Morten pointed out, from what I recall, 
> is that lazy initialization is *required* (since the number of threads 
> is open-ended), and the data ends up in non-huge page memory. It was 
> also unclear to me what the memory footprint implications would be, 
> would large per-lcore data structures be put in TLS. More specifically, 
> if they would be duplicated across all threads, even non-lcore threads.

But current method is unsafe on non-lcore threads.
Two non-lcore threads calling rte_rand() will clash on state without
any locking protection.

Also, right now the array is sized at 129 entries to allow for the
maximum number of lcores. When the maximum is increased to 512 or 1024
the problem will get worse.

  reply	other threads:[~2023-09-06 23:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06 17:20 Stephen Hemminger
2023-09-06 17:54 ` Morten Brørup
2023-09-11 16:04   ` Stephen Hemminger
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 [this message]
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=20230906160004.333b0488@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=hofors@lysator.liu.se \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).