From: sdf@google.com
To: Hou Tao <houtao@huaweicloud.com>
Cc: bpf@vger.kernel.org, Yonghong Song <yhs@fb.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Andrii Nakryiko <andrii@kernel.org>, Song Liu <song@kernel.org>,
Hao Luo <haoluo@google.com>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
KP Singh <kpsingh@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
houtao1@huawei.com
Subject: Re: [PATCH bpf 1/4] libbpf: Adjust ring buffer size when probing ring buffer map
Date: Fri, 11 Nov 2022 09:47:29 -0800 [thread overview]
Message-ID: <Y26KsQfOLGYeJJoo@google.com> (raw)
In-Reply-To: <20221111092642.2333724-2-houtao@huaweicloud.com>
On 11/11, Hou Tao wrote:
> From: Hou Tao <houtao1@huawei.com>
> Adjusting the size of ring buffer when probing ring buffer map, else
> the probe may fail on host with 64KB page size (e.g., an ARM64 host).
> After the fix, the output of "bpftool feature" on above host will be
> correct.
> Before :
> eBPF map_type ringbuf is NOT available
> eBPF map_type user_ringbuf is NOT available
> After :
> eBPF map_type ringbuf is available
> eBPF map_type user_ringbuf is available
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
> tools/lib/bpf/libbpf.c | 2 +-
> tools/lib/bpf/libbpf_internal.h | 2 ++
> tools/lib/bpf/libbpf_probes.c | 2 +-
> 3 files changed, 4 insertions(+), 2 deletions(-)
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 184ce1684dcd..907f735568ae 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -2353,7 +2353,7 @@ int parse_btf_map_def(const char *map_name, struct
> btf *btf,
> return 0;
> }
> -static size_t adjust_ringbuf_sz(size_t sz)
> +size_t adjust_ringbuf_sz(size_t sz)
> {
> __u32 page_sz = sysconf(_SC_PAGE_SIZE);
> __u32 mul;
> diff --git a/tools/lib/bpf/libbpf_internal.h
> b/tools/lib/bpf/libbpf_internal.h
> index 377642ff51fc..99dc4d6a19be 100644
> --- a/tools/lib/bpf/libbpf_internal.h
> +++ b/tools/lib/bpf/libbpf_internal.h
> @@ -576,4 +576,6 @@ static inline bool is_pow_of_2(size_t x)
> #define PROG_LOAD_ATTEMPTS 5
> int sys_bpf_prog_load(union bpf_attr *attr, unsigned int size, int
> attempts);
> +size_t adjust_ringbuf_sz(size_t sz);
> +
> #endif /* __LIBBPF_LIBBPF_INTERNAL_H */
> diff --git a/tools/lib/bpf/libbpf_probes.c b/tools/lib/bpf/libbpf_probes.c
> index f3a8e8e74eb8..29a1db2645fd 100644
> --- a/tools/lib/bpf/libbpf_probes.c
> +++ b/tools/lib/bpf/libbpf_probes.c
> @@ -234,7 +234,7 @@ static int probe_map_create(enum bpf_map_type
> map_type)
> case BPF_MAP_TYPE_USER_RINGBUF:
> key_size = 0;
> value_size = 0;
> - max_entries = 4096;
> + max_entries = adjust_ringbuf_sz(4096);
Why not pass PAGE_SIZE directly here? Something like:
max_entries = sysconf(_SC_PAGE_SIZE);
?
> break;
> case BPF_MAP_TYPE_STRUCT_OPS:
> /* we'll get -ENOTSUPP for invalid BTF type ID for struct_ops */
> --
> 2.29.2
next prev parent reply other threads:[~2022-11-11 17:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 9:26 [PATCH bpf 0/4] libbpf: Fixes for ring buffer Hou Tao
2022-11-11 9:26 ` [PATCH bpf 1/4] libbpf: Adjust ring buffer size when probing ring buffer map Hou Tao
2022-11-11 17:47 ` sdf [this message]
2022-11-12 2:31 ` Hou Tao
2022-11-11 9:26 ` [PATCH bpf 2/4] libbpf: Handle size overflow for ringbuf mmap Hou Tao
2022-11-11 17:54 ` sdf
2022-11-11 20:56 ` Andrii Nakryiko
2022-11-11 21:24 ` Stanislav Fomichev
2022-11-12 3:34 ` Hou Tao
2022-11-14 19:51 ` Andrii Nakryiko
2022-11-11 9:26 ` [PATCH bpf 3/4] libbpf: Handle size overflow for user " Hou Tao
2022-11-11 20:57 ` Andrii Nakryiko
2022-11-11 9:26 ` [PATCH bpf 4/4] libbpf: Check the validity of size in user_ring_buffer__reserve() Hou Tao
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=Y26KsQfOLGYeJJoo@google.com \
--to=sdf@google.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=houtao1@huawei.com \
--cc=houtao@huaweicloud.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=song@kernel.org \
--cc=yhs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox