All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net
Cc: kernel-team@fb.com
Subject: Re: [PATCH v2 bpf-next 1/2] libbpf: make RINGBUF map size adjustments more eagerly
Date: Fri, 15 Jul 2022 16:38:33 -0700	[thread overview]
Message-ID: <ca57e143-5e4d-f915-9256-71481d97d81b@fb.com> (raw)
In-Reply-To: <20220715230952.2219271-1-andrii@kernel.org>



On 7/15/22 4:09 PM, Andrii Nakryiko wrote:
> Make libbpf adjust RINGBUF map size (rounding it up to closest power-of-2
> of page_size) more eagerly: during open phase when initializing the map
> and on explicit calls to bpf_map__set_max_entries().
> 
> Such approach allows user to check actual size of BPF ringbuf even
> before it's created in the kernel, but also it prevents various edge
> case scenarios where BPF ringbuf size can get out of sync with what it
> would be in kernel. One of them (reported in [0]) is during an attempt
> to pin/reuse BPF ringbuf.
> 
> Move adjust_ringbuf_sz() helper closer to its first actual use. The
> implementation of the helper is unchanged.
> 
> Also make detection of whether bpf_object is already loaded more robust
> by checking obj->loaded explicitly, given that map->fd can be < 0 even
> if bpf_object is already loaded due to ability to disable map creation
> with bpf_map__set_autocreate(map, false).
> 
>    [0] Closes: https://github.com/libbpf/libbpf/pull/530
> 
> Fixes: 0087a681fa8c ("libbpf: Automatically fix up BPF_MAP_TYPE_RINGBUF size, if necessary")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

Acked-by: Yonghong Song <yhs@fb.com>

  parent reply	other threads:[~2022-07-15 23:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15 23:09 [PATCH v2 bpf-next 1/2] libbpf: make RINGBUF map size adjustments more eagerly Andrii Nakryiko
2022-07-15 23:09 ` [PATCH v2 bpf-next 2/2] selftests/bpf: test eager BPF ringbuf size adjustment logic Andrii Nakryiko
2022-07-15 23:39   ` Yonghong Song
2022-07-15 23:38 ` Yonghong Song [this message]
2022-07-19 17:10 ` [PATCH v2 bpf-next 1/2] libbpf: make RINGBUF map size adjustments more eagerly patchwork-bot+netdevbpf

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=ca57e143-5e4d-f915-9256-71481d97d81b@fb.com \
    --to=yhs@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.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.