All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Song Liu <song@kernel.org>
Cc: Jiri Olsa <olsajiri@gmail.com>,
	bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
	kernel-team@meta.com
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Add mmap/munmap benchmark for array maps
Date: Fri, 24 Jul 2026 10:53:58 +0200	[thread overview]
Message-ID: <amMoJnZUF5flJazb@krava> (raw)
In-Reply-To: <CAPhsuW4NKdRmFxsmLoAYKV60NuKoRO-3NKqHAucaXPyFKk4BMw@mail.gmail.com>

On Thu, Jul 23, 2026 at 02:58:45PM -0700, Song Liu wrote:
> On Thu, Jul 23, 2026 at 11:46 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> [...]
> > > +static void *producer(void *input)
> > > +{
> > > +     while (true) {
> > > +             void *addr;
> > > +
> > > +             addr = mmap(NULL, ctx.mmap_sz, PROT_READ | PROT_WRITE,
> > > +                         MAP_SHARED, ctx.map_fd, 0);
> > > +             if (addr == MAP_FAILED) {
> > > +                     fprintf(stderr, "mmap failed: %d\n", -errno);
> > > +                     exit(1);
> > > +             }
> >
> > hi,
> > so now pages are populated only when accessed, benchmark shows
> > this nicely:
> >
> > before:
> >                 nr_threads: 1, map_size: 1048576
> >         arraymap-mmap:       throughput: 0.006 ą 0.000 M ops/s, latency: 172703.437 ns/op
> >
> > after:
> >                 nr_threads: 1, map_size: 1048576
> >         arraymap-mmap:       throughput: 0.082 ą 0.002 M ops/s, latency: 12212.778 ns/op
> >
> >
> > would it make sense to add some map access in here (each page I guess)
> > enabled by new option and measure the impact for accessed map ?
> > I assume latency should be equal in such case.
> 
> If we add a read per page, which is the worst case:
> 
> before:
>         nr_threads: 1, map_size: 1048576
> arraymap-mmap:       throughput: 0.032 ± 0.000 M ops/s, latency: 31248.846 ns/op
> 
>         nr_threads: 1, map_size: 8388608
> arraymap-mmap:       throughput: 0.003 ± 0.000 M ops/s, latency:
> 372565.622 ns/op
> 
>         nr_threads: 1, map_size: 67108864
> arraymap-mmap:       throughput: 0.000 ± 0.000 M ops/s, latency:
> 2061083.005 ns/op
> 
> after:
>         nr_threads: 1, map_size: 1048576
> arraymap-mmap:       throughput: 0.006 ± 0.000 M ops/s, latency:
> 170794.193 ns/op
> 
>         nr_threads: 1, map_size: 8388608
> arraymap-mmap:       throughput: 0.001 ± 0.000 M ops/s, latency:
> 1346389.229 ns/op
> 
>         nr_threads: 1, map_size: 67108864
> arraymap-mmap:       throughput: 0.000 ± 0.000 M ops/s, latency:
> 10700389.105 ns/op
> 
> So filling all the pages in the mmap is faster than faulting one page at a time
> in many page faults. IOW, there is a performance regression in this case.

would it make sense to add new map flag for that?

jirka

  reply	other threads:[~2026-07-24  8:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22  6:53 [PATCH bpf-next 0/2] bpf: Populate mmap-able array maps lazily Song Liu
2026-07-22  6:53 ` [PATCH bpf-next 1/2] bpf: Populate mmap-able array map memory lazily Song Liu
2026-07-22  7:16   ` sashiko-bot
2026-07-22  6:53 ` [PATCH bpf-next 2/2] selftests/bpf: Add mmap/munmap benchmark for array maps Song Liu
2026-07-22  7:05   ` sashiko-bot
2026-07-23 18:46   ` Jiri Olsa
2026-07-23 21:58     ` Song Liu
2026-07-24  8:53       ` Jiri Olsa [this message]
2026-07-25  0:13         ` Song Liu
2026-07-25  1:43           ` Kumar Kartikeya Dwivedi
2026-07-28  0:19             ` Song Liu
2026-07-28 20:11               ` Song Liu
2026-07-28 20:18                 ` Kumar Kartikeya Dwivedi
2026-07-29 10:30                 ` Jiri Olsa

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=amMoJnZUF5flJazb@krava \
    --to=olsajiri@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=memxor@gmail.com \
    --cc=song@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 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.