BPF List
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Josh Don <joshdon@google.com>
Cc: paulmck@kernel.org, Hao Luo <haoluo@google.com>,
	davemarchevsky@meta.com, 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: Fri, 8 Sep 2023 12:07:29 -1000	[thread overview]
Message-ID: <ZPubIZLXFuAsfN7a@slm.duckdns.org> (raw)
In-Reply-To: <CABk29Nva+c6oBZra6srWGcfxMEquOP30dReM-PgW_Wh+zKiBuQ@mail.gmail.com>

Hello,

On Fri, Sep 08, 2023 at 01:26:11PM -0700, Josh Don wrote:
> I'm writing BPF programs for scheduling (ie. sched_ext), so these are
> getting invoked in hot paths and invoked concurrently across multiple
> cpus (for example, pick_next_task, enqueue_task, etc.). The kernel is
> responsible for relaying ground truth, userspace makes O(ms)
> scheduling decisions, and BPF makes O(us) scheduling decisions.
> BPF-BPF concurrency is possible with spinlocks and RMW, BPF-userspace
> can currently only really use RMW. My line of questioning is more
> forward looking, as I'm preemptively thinking of how to ensure
> kernel-like scheduling performance, since BPF spinlock or RMW is
> sometimes overkill :) I would think that barrier() and smp_mb() would
> probably be the minimum viable set (at least for x86) that people
> would find useful, but maybe others can chime in.

My personal favorite set is store_release/load_acquire(). I have a hard time
thinking up cases which can't be covered by them and they're basically free
on x86.

Thanks.

-- 
tejun

  reply	other threads:[~2023-09-08 22:07 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 [this message]
2023-09-08 23:16       ` Alexei Starovoitov
2023-09-09 12:47         ` Paul E. McKenney
2023-09-18 15:09   ` Barret Rhoden
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=ZPubIZLXFuAsfN7a@slm.duckdns.org \
    --to=tj@kernel.org \
    --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 \
    /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