BPF List
 help / color / mirror / Atom feed
From: Barret Rhoden <brho@google.com>
To: paulmck@kernel.org
Cc: Josh Don <joshdon@google.com>, Hao Luo <haoluo@google.com>,
	davemarchevsky@meta.com, Tejun Heo <tj@kernel.org>,
	David Vernet <dvernet@meta.com>, Neel Natu <neelnatu@google.com>,
	Jack Humphries <jhumphri@google.com>,
	bpf@vger.kernel.org, ast@kernel.org
Subject: Re: BPF memory model
Date: Mon, 18 Sep 2023 11:09:26 -0400	[thread overview]
Message-ID: <5c3b16c8-63e6-4f80-8fa2-6bacb38cdcb6@google.com> (raw)
In-Reply-To: <33f06fa6-2f4d-4e50-a87e-0d6604d3c413@paulmck-laptop>

On 9/8/23 04:42, Paul E. McKenney wrote:
> But what BPF programs are you running that are seeing excessive 
> synchronization overhead? That will tell us which operations to start 
> with. (Or maybe it is time to just add the full Linux-kernel 
> atomic-operations kitchen sink, but that would not normally be the way 
> to bet.)

Here's what I use in BPF, (also for writing parallel schedulers):
- READ_ONCE/WRITE_ONCE
- compiler atomic builtins, like CAS, swap/exchange, fetch_and_add, etc.
- smp_store_release, __atomic_load_n, etc.
- at one point, i was sprinkling asm volatile ("" ::: "memory") around 
too, though not in any active code at the moment.

My mental model, right or wrong, is that I am operating under something 
like the LKMM, and that I need to convince the compiler to spit out the 
right code (sort of like writing shared memory code to talk to a device 
or userspace) and hope the JIT does the right thing.

Barret



  parent reply	other threads:[~2023-09-18 15:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07 22:00 BPF memory model Josh Don
2023-09-08  8:42 ` Paul E. McKenney
2023-09-08 20:26   ` Josh Don
2023-09-08 22:07     ` Tejun Heo
2023-09-08 23:16       ` Alexei Starovoitov
2023-09-09 12:47         ` Paul E. McKenney
2023-09-18 15:09   ` Barret Rhoden [this message]
2023-09-19  9:52     ` Paul E. McKenney
2023-09-19 15:55       ` Barret Rhoden
2023-10-16 16:48         ` Paul E. McKenney
2023-10-16 17:17           ` Jose E. Marchesi
2023-11-13 18:53           ` Barret Rhoden
2023-11-13 20:03             ` Paul E. McKenney

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=5c3b16c8-63e6-4f80-8fa2-6bacb38cdcb6@google.com \
    --to=brho@google.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=davemarchevsky@meta.com \
    --cc=dvernet@meta.com \
    --cc=haoluo@google.com \
    --cc=jhumphri@google.com \
    --cc=joshdon@google.com \
    --cc=neelnatu@google.com \
    --cc=paulmck@kernel.org \
    --cc=tj@kernel.org \
    /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