Re: [PATCH v2 bpf-next 1/4] libbpf: add btf_has_size() and btf_int() inlines

2021-01-20 Thread Andrii Nakryiko
On Sun, Jan 17, 2021 at 2:22 PM Alan Maguire wrote: > > BTF type data dumping will use them in later patches, and they > are useful generally when handling BTF data. > > Signed-off-by: Alan Maguire > --- > tools/lib/bpf/btf.h | 19 +++ > 1 file changed, 19 insertions(+) > > diff

Re: [PATCH v2 bpf-next 4/4] selftests/bpf: add dump type data tests to btf dump tests

2021-01-20 Thread Andrii Nakryiko
On Sun, Jan 17, 2021 at 2:21 PM Alan Maguire wrote: > > Test various type data dumping operations by comparing expected > format with the dumped string; an snprintf-style printf function > is used to record the string dumped. > > Signed-off-by: Alan Maguire > --- >

Re: [PATCH bpf-next v5 3/4] selftests/bpf: Integrate the socket_cookie test to test_progs

2021-01-21 Thread Andrii Nakryiko
On Tue, Jan 19, 2021 at 8:00 AM Florent Revest wrote: > > Currently, the selftest for the BPF socket_cookie helpers is built and > run independently from test_progs. It's easy to forget and hard to > maintain. > > This patch moves the socket cookies test into prog_tests/ and vastly > simplifies

Re: [PATCH v2 bpf-next 2/4] libbpf: make skip_mods_and_typedefs available internally in libbpf

2021-01-20 Thread Andrii Nakryiko
On Sun, Jan 17, 2021 at 2:20 PM Alan Maguire wrote: > > btf_dump.c will need it for type-based data display. > > Signed-off-by: Alan Maguire > --- Given we make it into an internal API, let's call it btf_skip_mods_and_typedefs()? Otherwise all ok. Acked-by: Andrii Nakryiko &

Re: [PATCH bpf-next v3] samples/bpf: Update build procedure for manually compiling LLVM and Clang

2021-01-21 Thread Andrii Nakryiko
On Wed, Jan 20, 2021 at 9:36 PM Nathan Chancellor wrote: > > On Thu, Jan 21, 2021 at 01:27:35PM +0800, Tiezhu Yang wrote: > > The current LLVM and Clang build procedure in samples/bpf/README.rst is > > out of date. See below that the links are not accessible any more. > > > > $ git clone

Re: [PATCH v2 bpf-next 3/4] libbpf: BTF dumper support for typed data

2021-01-20 Thread Andrii Nakryiko
On Sun, Jan 17, 2021 at 2:22 PM Alan Maguire wrote: > > Add a BTF dumper for typed data, so that the user can dump a typed > version of the data provided. > > The API is > > int btf_dump__emit_type_data(struct btf_dump *d, __u32 id, > const struct

Re: [PATCH v5 0/3] Kbuild: DWARF v5 support

2021-01-15 Thread Andrii Nakryiko
On Fri, Jan 15, 2021 at 3:34 PM Nick Desaulniers wrote: > > On Fri, Jan 15, 2021 at 3:24 PM Yonghong Song wrote: > > > > > > > > On 1/15/21 1:53 PM, Sedat Dilek wrote: > > > En plus, I encountered breakage with GCC v10.2.1 and LLVM=1 and > > > CONFIG_DEBUG_INFO_DWARF4. > > > So might be good to

Re: [PATCH RFC] tools: Factor Clang, LLC and LLVM utils definitions

2021-01-21 Thread Andrii Nakryiko
On Wed, Jan 20, 2021 at 2:36 PM Jiri Olsa wrote: > > On Sat, Jan 16, 2021 at 10:54:04AM +0100, Sedat Dilek wrote: > > When dealing with BPF/BTF/pahole and DWARF v5 I wanted to build bpftool. > > > > While looking into the source code I found duplicate assignments > > in misc tools for the LLVM

Re: [PATCH v2 bpf-next 3/4] libbpf: BTF dumper support for typed data

2021-01-21 Thread Andrii Nakryiko
On Wed, Jan 20, 2021 at 10:56 PM Andrii Nakryiko wrote: > > On Sun, Jan 17, 2021 at 2:22 PM Alan Maguire wrote: > > > > Add a BTF dumper for typed data, so that the user can dump a typed > > version of the data provided. > > > > The API is > > > >

Re: [PATCH bpf-next v5 3/4] selftests/bpf: Integrate the socket_cookie test to test_progs

2021-01-22 Thread Andrii Nakryiko
On Fri, Jan 22, 2021 at 6:35 AM Florent Revest wrote: > > On Thu, Jan 21, 2021 at 8:55 AM Andrii Nakryiko > wrote: > > > > On Tue, Jan 19, 2021 at 8:00 AM Florent Revest wrote: > > > > > > Currently, the selftest for the BPF socket_cookie helpers is

Re: [PATCH v3 1/4] btf: add support for ints larger than 128 bits

2021-01-05 Thread Andrii Nakryiko
On Tue, Jan 5, 2021 at 6:45 AM Sean Young wrote: > > clang supports arbitrary length ints using the _ExtInt extension. This > can be useful to hold very large values, e.g. 256 bit or 512 bit types. > > Larger types (e.g. 1024 bits) are possible but I am unaware of a use > case for these. > > This

Re: [PATCH v3 3/4] bpftool: add support for ints larger than 128 bits

2021-01-05 Thread Andrii Nakryiko
On Tue, Jan 5, 2021 at 6:45 AM Sean Young wrote: > > clang supports arbitrary length ints using the _ExtInt extension. This > can be useful to hold very large values, e.g. 256 bit or 512 bit types. > > This requires the _ExtInt extension enabled in clang, which is under > review. > > Link: >

Re: [PATCH v3 1/4] btf: add support for ints larger than 128 bits

2021-01-05 Thread Andrii Nakryiko
On Tue, Jan 5, 2021 at 9:10 PM Andrii Nakryiko wrote: > > On Tue, Jan 5, 2021 at 6:45 AM Sean Young wrote: > > > > clang supports arbitrary length ints using the _ExtInt extension. This > > can be useful to hold very large values, e.g. 256 bit or 512 bit types. > &g

Re: [PATCH v3 4/4] bpf: add tests for ints larger than 128 bits

2021-01-05 Thread Andrii Nakryiko
On Tue, Jan 5, 2021 at 6:45 AM Sean Young wrote: > > clang supports arbitrary length ints using the _ExtInt extension. This > can be useful to hold very large values, e.g. 256 bit or 512 bit types. > > Larger types (e.g. 1024 bits) are possible but I am unaware of a use > case for these. > > This

Re: [PATCH v2] sched/debug: Add new tracepoint to track cpu_capacity

2021-01-06 Thread Andrii Nakryiko
On Wed, Jan 6, 2021 at 3:27 AM Qais Yousef wrote: > > On 01/05/21 08:44, Alexei Starovoitov wrote: > > > Any pointer to an example test I could base this on? > > > > selftests/bpf/ > > I was hoping for something more elaborate. I thought there's something already > there that do some verification

Re: [RFC PATCH bpf-next 1/2] bpf: share BTF "show" implementation between kernel and libbpf

2021-01-14 Thread Andrii Nakryiko
On Thu, Jan 14, 2021 at 7:37 AM Alan Maguire wrote: > > On Mon, 11 Jan 2021, Andrii Nakryiko wrote: > > > On Mon, Jan 11, 2021 at 9:34 AM Alan Maguire > > wrote: > > > Currently the only "show" function for userspace is to write the > > >

Re: [PATCH bpf 1/2] bpf: support PTR_TO_MEM{,_OR_NULL} register spilling

2021-01-12 Thread Andrii Nakryiko
On Tue, Jan 12, 2021 at 1:14 AM Gilad Reti wrote: > > Add support for pointer to mem register spilling, to allow the verifier > to track pointer to valid memory addresses. Such pointers are returned > for example by a successful call of the bpf_ringbuf_reserve helper. > > This patch was suggested

Re: [PATCH bpf-next 2/2] selftests: bpf: Add a new test for bare tracepoints

2021-01-12 Thread Andrii Nakryiko
On Tue, Jan 12, 2021 at 11:27 AM Qais Yousef wrote: > > On 01/11/21 23:26, Andrii Nakryiko wrote: > > On Mon, Jan 11, 2021 at 10:20 AM Qais Yousef wrote: > > > > > > Reuse module_attach infrastructure to add a new bare tracepoint to check > > >

Re: [PATCH] bpf: Hoise pahole version checks into Kconfig

2021-01-13 Thread Andrii Nakryiko
On Mon, Jan 11, 2021 at 1:24 PM Andrii Nakryiko wrote: > > On Mon, Jan 11, 2021 at 12:00 PM Nathan Chancellor > wrote: > > > > On Tue, Jan 12, 2021 at 04:50:50AM +0900, Masahiro Yamada wrote: > > > On Tue, Jan 12, 2021 at 4:34 AM Nathan Chancellor > > >

Re: [PATCH] bpf: Fix test_verifier after introducing resolve_pseudo_ldimm64

2020-10-06 Thread Andrii Nakryiko
On Tue, Oct 6, 2020 at 4:45 PM Hao Luo wrote: > > Commit 4976b718c355 ("bpf: Introduce pseudo_btf_id") switched > the order of check_subprogs() and resolve_pseudo_ldimm() in > the verifier. Now an empty prog and the prog of a single > invalid ldimm expect to see the error "last insn is not an >

Re: [PATCH] bpf: Fix test_verifier after introducing resolve_pseudo_ldimm64

2020-10-06 Thread Andrii Nakryiko
On Tue, Oct 6, 2020 at 5:51 PM Hao Luo wrote: > > On Tue, Oct 6, 2020 at 5:43 PM Andrii Nakryiko > wrote: > > > > On Tue, Oct 6, 2020 at 4:45 PM Hao Luo wrote: > > > > > > Commit 4976b718c355 ("bpf: Introduce pseudo_btf_id") switched > > &

Re: [PATCH bpf-next 2/5] libbpf: support BPF_PROG_TYPE_USER programs

2020-08-04 Thread Andrii Nakryiko
On Mon, Aug 3, 2020 at 6:18 PM Song Liu wrote: > > > > > On Aug 2, 2020, at 6:40 PM, Andrii Nakryiko > > wrote: > > > > On Sat, Aug 1, 2020 at 1:50 AM Song Liu wrote: > >> > > [...] > > > > >> }; > >> > >> L

Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog

2020-08-04 Thread Andrii Nakryiko
On Tue, Aug 4, 2020 at 2:01 PM Song Liu wrote: > > > > > On Aug 2, 2020, at 10:10 PM, Andrii Nakryiko > > wrote: > > > > On Sun, Aug 2, 2020 at 9:47 PM Song Liu wrote: > >> > >> > >>> On Aug 2, 2020, at 6:51 PM, Andrii Nakryiko &

Re: [PATCH bpf-next 2/5] libbpf: support BPF_PROG_TYPE_USER programs

2020-08-04 Thread Andrii Nakryiko
On Tue, Aug 4, 2020 at 8:59 PM Song Liu wrote: > > > > > On Aug 4, 2020, at 6:38 PM, Andrii Nakryiko > > wrote: > > > > On Mon, Aug 3, 2020 at 6:18 PM Song Liu wrote: > >> > >> > >> > >>> On Aug 2, 2020, at 6:40 PM, Andrii

Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog

2020-08-04 Thread Andrii Nakryiko
On Tue, Aug 4, 2020 at 9:47 PM Song Liu wrote: > > > > > On Aug 4, 2020, at 6:52 PM, Andrii Nakryiko > > wrote: > > > > On Tue, Aug 4, 2020 at 2:01 PM Song Liu wrote: > >> > >> > >> > >>> On Aug 2, 2020, at 10:10 PM, A

Re: [PATCH bpf-next 2/5] libbpf: support BPF_PROG_TYPE_USER programs

2020-08-05 Thread Andrii Nakryiko
On Tue, Aug 4, 2020 at 11:26 PM Song Liu wrote: > > > > > On Aug 4, 2020, at 10:32 PM, Andrii Nakryiko > > wrote: > > > > On Tue, Aug 4, 2020 at 8:59 PM Song Liu wrote: > >> > >> > >> > >>> On Aug 4, 2020, at 6:38 PM, A

Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog

2020-08-05 Thread Andrii Nakryiko
On Wed, Aug 5, 2020 at 10:16 AM Alexei Starovoitov wrote: > > On Wed, Aug 05, 2020 at 04:47:30AM +, Song Liu wrote: > > > > Being able to trigger BPF program on a different CPU could enable many > > use cases and optimizations. The use case I am looking at is to access > > perf_event and

Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog

2020-08-05 Thread Andrii Nakryiko
On Wed, Aug 5, 2020 at 12:01 AM Song Liu wrote: > > > > > On Aug 4, 2020, at 10:47 PM, Andrii Nakryiko > > wrote: > > > > On Tue, Aug 4, 2020 at 9:47 PM Song Liu wrote: > >> > >> > >> > >>> On Aug 4, 2020, at 6:52 PM, A

Re: [PATCH bpf-next 2/5] libbpf: support BPF_PROG_TYPE_USER programs

2020-08-05 Thread Andrii Nakryiko
On Wed, Aug 5, 2020 at 12:23 AM Song Liu wrote: > > > > > On Aug 4, 2020, at 11:54 PM, Andrii Nakryiko > > wrote: > > > > On Tue, Aug 4, 2020 at 11:26 PM Song Liu wrote: > >> > >> > >> > >>> On Aug 4, 2020, at 10:32 PM, A

Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog

2020-08-05 Thread Andrii Nakryiko
On Wed, Aug 5, 2020 at 10:45 AM Alexei Starovoitov wrote: > > On Wed, Aug 05, 2020 at 10:27:28AM -0700, Andrii Nakryiko wrote: > > On Wed, Aug 5, 2020 at 10:16 AM Alexei Starovoitov > > wrote: > > > > > > On Wed, Aug 05, 2020 at 04:47:30AM +, Song L

Re: [PATCH bpf-next v2] bpf: fix segmentation fault of test_progs

2020-08-10 Thread Andrii Nakryiko
eter to delete tmp1 mappings should be 4*page_size. > > Signed-off-by: Jianlin Lv > --- LGTM, thanks for the fix! Acked-by: Andrii Nakryiko > v2: > - Update commit messages > - Create 4 pages of anonymous mapping that serve the subsequent mmap() > --- > tools/testing

Re: [PATCH bpf-next 2/2] selftests/bpf: ensure snprintf_btf/bpf_iter tests compatibility with old vmlinux.h

2020-09-29 Thread Andrii Nakryiko
d redefine > them to work around this. > > Fixes: b72091bd4ee4 ("selftests/bpf: Add test for bpf_seq_printf_btf helper") > Fixes: 076a95f5aff2 ("selftests/bpf: Add bpf_snprintf_btf helper tests") > Reported-by: Andrii Nakryiko > Signed-off-by: Alan Maguire &g

Re: [PATCH bpf-next v2 2/4] selftests: bpf: Add helper to compare socket cookies

2020-10-01 Thread Andrii Nakryiko
On Thu, Oct 1, 2020 at 12:25 AM Alexei Starovoitov wrote: > > On Wed, Sep 30, 2020 at 10:28:33AM +0100, Lorenz Bauer wrote: > > On Tue, 29 Sep 2020 at 16:48, Alexei Starovoitov > > wrote: > > > > ... > > > > > There was a warning. I noticed it while applying and fixed it up. > > > Lorenz, please

[PATCH] fs: fix NULL dereference due to data race in prepend_path()

2020-10-14 Thread Andrii Nakryiko
ernel.org Fixes: f2683bd8d5bd ("[PATCH] fix d_absolute_path() interplay with fsmount()") Signed-off-by: Andrii Nakryiko --- fs/d_path.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/d_path.c b/fs/d_path.c index 0f1fc1743302..a69e2cd36e6e 100644 --- a/fs/d

Re: [PATCH] fs: fix NULL dereference due to data race in prepend_path()

2020-10-14 Thread Andrii Nakryiko
On Wed, Oct 14, 2020 at 4:08 PM Al Viro wrote: > > On Wed, Oct 14, 2020 at 01:45:28PM -0700, Andrii Nakryiko wrote: > > Fix data race in prepend_path() with re-reading mnt->mnt_ns twice without > > holding the lock. is_mounted() does check for NULL, but > > is_anon_n

[PATCH] fs: clean up is_mounted() check with extra helper

2020-10-14 Thread Andrii Nakryiko
Add is_real_ns() helper validating that mount namespace is a valid one. Use that from is_mounted() and clean up prepare_path() that open-coded similar check. Suggested-by: Alexander Viro Signed-off-by: Andrii Nakryiko --- fs/d_path.c | 3 +-- fs/mount.h | 9 +++-- 2 files changed, 8

Re: [PATCH bpf-next v3 2/4] selftests/bpf: add test for freplace program with write access

2020-08-27 Thread Andrii Nakryiko
On Tue, Aug 25, 2020 at 4:21 PM Udip Pant wrote: > > This adds a selftest that tests the behavior when a freplace target program > attempts to make a write access on a packet. The expectation is that the read > or write > access is granted based on the program type of the linked program and >

Re: [PATCH bpf-next v1 4/8] bpf/libbpf: BTF support for typed ksyms

2020-09-01 Thread Andrii Nakryiko
On Thu, Aug 27, 2020 at 3:29 PM Hao Luo wrote: > > On Fri, Aug 21, 2020 at 3:37 PM Andrii Nakryiko > wrote: > > > > On Wed, Aug 19, 2020 at 3:42 PM Hao Luo wrote: > > > > > > If a ksym is defined with a type, libbpf will try to find the ksym's btf > &

Re: [PATCH bpf-next v1 8/8] bpf/selftests: Test for bpf_per_cpu_ptr()

2020-09-01 Thread Andrii Nakryiko
On Thu, Aug 27, 2020 at 8:42 PM Hao Luo wrote: > > Thanks for taking a look! > > On Fri, Aug 21, 2020 at 8:30 PM Andrii Nakryiko > wrote: > > > > On Wed, Aug 19, 2020 at 3:42 PM Hao Luo wrote: > > > > > > Test bpf_per_cpu_ptr(). Test two paths in

Re: [PATCH bpf-next v1 4/8] bpf/libbpf: BTF support for typed ksyms

2020-09-01 Thread Andrii Nakryiko
On Tue, Sep 1, 2020 at 1:35 PM Hao Luo wrote: > > On Tue, Sep 1, 2020 at 11:11 AM Andrii Nakryiko > wrote: > > > > On Thu, Aug 27, 2020 at 3:29 PM Hao Luo wrote: > > > > > > On Fri, Aug 21, 2020 at 3:37 PM Andrii Nakryiko > > > wrote: > &g

Re: [RFC PATCH] bpftool btf: Add prefix option to dump C

2020-07-31 Thread Andrii Nakryiko
On Fri, Jul 31, 2020 at 6:47 PM Ian Rogers wrote: > > On Tue, Jul 21, 2020 at 11:58 PM Andrii Nakryiko > wrote: > > > > On Tue, Jul 21, 2020 at 10:44 PM Ian Rogers wrote: > > > > > > When bpftool dumps types and enum members into a header file fo

Re: [PATCH] tools/bpf/bpftool: Fix wrong return value in do_dump()

2020-08-02 Thread Andrii Nakryiko
On Sun, Aug 2, 2020 at 4:16 AM Tianjia Zhang wrote: > > In case of btf_id does not exist, a negative error code -ENOENT > should be returned. > > Fixes: c93cc69004df3 ("bpftool: add ability to dump BTF types") > Cc: Andrii Nakryiko > Signed-off-by: Tianjia

Re: [PATCH bpf-next 2/5] libbpf: support BPF_PROG_TYPE_USER programs

2020-08-02 Thread Andrii Nakryiko
On Sat, Aug 1, 2020 at 1:50 AM Song Liu wrote: > > Add cpu_plus to bpf_prog_test_run_attr. Add BPF_PROG_SEC "user" for > BPF_PROG_TYPE_USER programs. > > Signed-off-by: Song Liu > --- > tools/lib/bpf/bpf.c | 1 + > tools/lib/bpf/bpf.h | 3 +++ > tools/lib/bpf/libbpf.c

Re: [PATCH bpf-next 3/5] selftests/bpf: add selftest for BPF_PROG_TYPE_USER

2020-08-02 Thread Andrii Nakryiko
On Sat, Aug 1, 2020 at 1:50 AM Song Liu wrote: > > This test checks the correctness of BPF_PROG_TYPE_USER program, including: > running on the right cpu, passing in correct args, returning retval, and > being able to call bpf_get_stack|stackid. > > Signed-off-by: Song Liu > --- >

Re: [PATCH bpf-next 4/5] selftests/bpf: move two functions to test_progs.c

2020-08-02 Thread Andrii Nakryiko
On Sat, Aug 1, 2020 at 1:50 AM Song Liu wrote: > > Move time_get_ns() and get_base_addr() to test_progs.c, so they can be > used in other tests. > > Signed-off-by: Song Liu > --- > .../selftests/bpf/prog_tests/attach_probe.c | 21 - > .../selftests/bpf/prog_tests/test_overhead.c

Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog

2020-08-02 Thread Andrii Nakryiko
On Sat, Aug 1, 2020 at 1:50 AM Song Liu wrote: > > Add a benchmark to compare performance of > 1) uprobe; > 2) user program w/o args; > 3) user program w/ args; > 4) user program w/ args on random cpu. > Can you please add it to the existing benchmark runner instead, e.g., along the

Re: [PATCH bpf-next 2/5] libbpf: support BPF_PROG_TYPE_USER programs

2020-08-02 Thread Andrii Nakryiko
On Sun, Aug 2, 2020 at 9:21 PM Song Liu wrote: > > > > > On Aug 2, 2020, at 6:40 PM, Andrii Nakryiko > > wrote: > > > > On Sat, Aug 1, 2020 at 1:50 AM Song Liu wrote: > >> > >> Add cpu_plus to bpf_prog_test_run_attr. Add BPF_P

Re: [PATCH bpf-next 3/5] selftests/bpf: add selftest for BPF_PROG_TYPE_USER

2020-08-02 Thread Andrii Nakryiko
On Sun, Aug 2, 2020 at 9:33 PM Song Liu wrote: > > > > > On Aug 2, 2020, at 6:43 PM, Andrii Nakryiko > > wrote: > > > > On Sat, Aug 1, 2020 at 1:50 AM Song Liu wrote: > >> > >> This test checks the correctness of BPF_PROG_TYPE_USER program

Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog

2020-08-02 Thread Andrii Nakryiko
On Sun, Aug 2, 2020 at 9:47 PM Song Liu wrote: > > > > On Aug 2, 2020, at 6:51 PM, Andrii Nakryiko > > wrote: > > > > On Sat, Aug 1, 2020 at 1:50 AM Song Liu wrote: > >> > >> Add a benchmark to compare performance of > >> 1) uprobe

Re: [PATCH bpf-next v1 3/8] bpf: Introduce help function to validate ksym's type.

2020-08-21 Thread Andrii Nakryiko
On Thu, Aug 20, 2020 at 10:22 AM Yonghong Song wrote: > > > > On 8/19/20 3:40 PM, Hao Luo wrote: > > For a ksym to be safely dereferenced and accessed, its type defined in > > bpf program should basically match its type defined in kernel. Implement > > a help function for a quick matching, which

Re: [PATCH bpf-next v1 4/8] bpf/libbpf: BTF support for typed ksyms

2020-08-21 Thread Andrii Nakryiko
On Wed, Aug 19, 2020 at 3:42 PM Hao Luo wrote: > > If a ksym is defined with a type, libbpf will try to find the ksym's btf > information from kernel btf. If a valid btf entry for the ksym is found, > libbpf can pass in the found btf id to the verifier, which validates the > ksym's type and

Re: [PATCH bpf-next v1 5/8] bpf/selftests: ksyms_btf to test typed ksyms

2020-08-21 Thread Andrii Nakryiko
On Thu, Aug 20, 2020 at 10:32 AM Yonghong Song wrote: > > > > On 8/19/20 3:40 PM, Hao Luo wrote: > > Selftests for typed ksyms. Tests two types of ksyms: one is a struct, > > the other is a plain int. This tests two paths in the kernel. Struct > > ksyms will be converted into PTR_TO_BTF_ID by the

Re: [PATCH bpf-next v1 3/8] bpf: Introduce help function to validate ksym's type.

2020-08-21 Thread Andrii Nakryiko
On Fri, Aug 21, 2020 at 5:43 PM Hao Luo wrote: > > On Fri, Aug 21, 2020 at 2:50 PM Andrii Nakryiko > wrote: > > > > On Thu, Aug 20, 2020 at 10:22 AM Yonghong Song wrote: > > > > > > > > > > > > On 8/19/20 3:40 PM, Hao Luo wrote: >

Re: [PATCH bpf-next v1 6/8] bpf: Introduce bpf_per_cpu_ptr()

2020-08-21 Thread Andrii Nakryiko
the caller must check the returned value. > > Signed-off-by: Hao Luo > --- The logic looks correct, few naming nits, but otherwise: Acked-by: Andrii Nakryiko > include/linux/bpf.h | 3 ++ > include/linux/btf.h | 11 +++ > include/uapi/linux/bpf.h | 14 +

Re: [PATCH bpf-next v1 8/8] bpf/selftests: Test for bpf_per_cpu_ptr()

2020-08-21 Thread Andrii Nakryiko
isn't a struct, the returned reg is of type > PTR_TO_MEM, which also supports direct pointer dereference. > > Signed-off-by: Hao Luo > --- Acked-by: Andrii Nakryiko > .../testing/selftests/bpf/prog_tests/ksyms_btf.c | 4 > .../testing/selftests/bpf/progs/test_ksyms

Re: [PATCH bpf-next v1 6/8] bpf: Introduce bpf_per_cpu_ptr()

2020-08-21 Thread Andrii Nakryiko
On Fri, Aug 21, 2020 at 8:26 PM Andrii Nakryiko wrote: > > On Wed, Aug 19, 2020 at 3:42 PM Hao Luo wrote: > > > > Add bpf_per_cpu_ptr() to help bpf programs access percpu vars. > > bpf_per_cpu_ptr() has the same semantic as per_cpu_ptr() in the kernel > >

Re: [PATCH bpf-next v1 5/8] bpf/selftests: ksyms_btf to test typed ksyms

2020-08-22 Thread Andrii Nakryiko
On Sat, Aug 22, 2020 at 12:27 AM Hao Luo wrote: > > On Fri, Aug 21, 2020 at 4:03 PM Andrii Nakryiko > wrote: > > > > On Thu, Aug 20, 2020 at 10:32 AM Yonghong Song wrote: > > > > > > > > > > > > On 8/19/20 3:40 PM, Hao Luo wrote: > &g

Re: [PATCH bpf-next v1 6/8] bpf: Introduce bpf_per_cpu_ptr()

2020-08-22 Thread Andrii Nakryiko
On Sat, Aug 22, 2020 at 12:49 AM Hao Luo wrote: > > On Fri, Aug 21, 2020 at 8:31 PM Andrii Nakryiko > wrote: > > > > On Fri, Aug 21, 2020 at 8:26 PM Andrii Nakryiko > > wrote: > > > > > > On Wed, Aug 19, 2020 at 3:42 PM Hao Luo wrote: > > >

Re: [PATCH bpf-next v2 4/6] bpf: Introduce bpf_per_cpu_ptr()

2020-09-14 Thread Andrii Nakryiko
s to be guarded by perfmon_capable() check, similar to bpf_get_current_task_proto. > > On Fri, Sep 4, 2020 at 1:04 PM Andrii Nakryiko > wrote: > > > > On Thu, Sep 3, 2020 at 3:35 PM Hao Luo wrote: > > > > > > Add bpf_per_cpu_ptr() to help bpf programs access perc

Re: [PATCH bpf-next v2 3/6] bpf/selftests: ksyms_btf to test typed ksyms

2020-09-14 Thread Andrii Nakryiko
On Sun, Sep 13, 2020 at 9:58 PM Hao Luo wrote: > > Thanks for taking a look, Andrii. > > On Fri, Sep 4, 2020 at 12:49 PM Andrii Nakryiko > wrote: > > > > On Thu, Sep 3, 2020 at 3:35 PM Hao Luo wrote: > > > > > > Selftests for typed ksy

Re: [PATCH bpf-next v2 1/5] bpf: expose is_mptcp flag to bpf_tcp_sock

2020-09-14 Thread Andrii Nakryiko
On Mon, Sep 14, 2020 at 11:21 AM Song Liu wrote: > > On Fri, Sep 11, 2020 at 8:07 AM Nicolas Rybowski > wrote: > > > > is_mptcp is a field from struct tcp_sock used to indicate that the > > current tcp_sock is part of the MPTCP protocol. > > > > In this protocol, a first socket (mptcp_sock) is

Re: [PATCH bpf-next v3 1/6] bpf: Introduce pseudo_btf_id

2020-09-21 Thread Andrii Nakryiko
lsyms and (2) the encoding of kernel global VARs in pahole, which > should be available since pahole v1.18. > > Signed-off-by: Hao Luo > --- Looks good, few minor nits if you are going to post another version anyways. Assuming BPF offload change I mentioned is ok: Acked-by: Andrii Nakryiko

Re: [PATCH bpf-next v3 2/6] bpf/libbpf: BTF support for typed ksyms

2020-09-21 Thread Andrii Nakryiko
type and value. > > Typeless ksyms (i.e. those defined as 'void') will not have such btf_id, > but it has the symbol's address (read from kallsyms) and its value is > treated as a raw pointer. > > Signed-off-by: Hao Luo > --- This looks nice and clean, thanks! Acked-by

Re: [PATCH bpf-next v3 3/6] selftests/bpf: ksyms_btf to test typed ksyms

2020-09-21 Thread Andrii Nakryiko
ll be converted into PTR_TO_MEM. > > Signed-off-by: Hao Luo > --- LGTM. Acked-by: Andrii Nakryiko > .../testing/selftests/bpf/prog_tests/ksyms.c | 38 -- > .../selftests/bpf/prog_tests/ksyms_btf.c | 70 +++ > .../selftests/bpf/progs/test_ksym

Re: [PATCH bpf-next v3 4/6] bpf: Introduce bpf_per_cpu_ptr()

2020-09-21 Thread Andrii Nakryiko
the caller must check the returned value. > > Acked-by: Andrii Nakryiko > Signed-off-by: Hao Luo > --- > include/linux/bpf.h| 4 +++ > include/linux/btf.h| 11 ++ > include/uapi/linux/bpf.h | 18 ++ > kernel/bpf/btf.c

Re: [PATCH bpf-next v3 4/6] bpf: Introduce bpf_per_cpu_ptr()

2020-09-21 Thread Andrii Nakryiko
On Thu, Sep 17, 2020 at 12:14 PM Hao Luo wrote: > > I need to cast the pointer to "const void __percpu *" before passing > into per_cpu_ptr. I will update and resend. You can try just declaring it as __percpu in BPF_CALL_2 macro. That might work, or not, depending on how exactly BPF_CALL macros

Re: WARNING in bpf_raw_tp_link_fill_link_info

2020-09-10 Thread Andrii Nakryiko
On Thu, Sep 10, 2020 at 2:31 AM syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit:7fb5eefd selftests/bpf: Fix test_sysctl_loop{1, 2} failure.. > git tree: bpf-next > console output: https://syzkaller.appspot.com/x/log.txt?x=1424fdb390 > kernel config:

Re: [PATCH v4 bpf-next 5/5] docs/bpf: add BPF ring buffer design notes

2020-09-10 Thread Andrii Nakryiko
On Wed, Sep 9, 2020 at 6:53 AM Mauro Carvalho Chehab wrote: > > Em Fri, 29 May 2020 00:54:24 -0700 > Andrii Nakryiko escreveu: > > > Add commit description from patch #1 as a stand-alone documentation under > > Documentation/bpf, as it might be more conveni

Re: [PATCH 1/2] tools, bpftool: Avoid array index warnings.

2020-10-28 Thread Andrii Nakryiko
On Tue, Oct 27, 2020 at 4:37 PM Ian Rogers wrote: > > The bpf_caps array is shorter without CAP_BPF, avoid out of bounds reads > if this isn't defined. Working around this avoids -Wno-array-bounds with > clang. > > Signed-off-by: Ian Rogers > --- Acked-by: Andrii Nakryiko

Re: [PATCH bpf-next] libbpf: Expose libbpf ringbufer epoll_fd

2020-12-11 Thread Andrii Nakryiko
On Fri, Dec 11, 2020 at 10:58 AM Brendan Jackman wrote: > > This allows the user to do their own manual polling in more > complicated setups. > > Signed-off-by: Brendan Jackman > --- perf_buffer has it, so it's good for consistency. In practice, though, I'd expect anyone who needs more

Re: BPF selftests build failure in 5.10-rc

2020-12-09 Thread Andrii Nakryiko
On Wed, Dec 9, 2020 at 2:24 PM Seth Forshee wrote: > > Building the BPF selftests with clang 11, I'm getting the following > error: > >CLNG-LLC [test_maps] profiler1.o > In file included from progs/profiler1.c:6: > progs/profiler.inc.h:260:17: error: use of unknown builtin >

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-18 Thread Andrii Nakryiko
On Thu, Dec 17, 2020 at 7:20 PM Alexei Starovoitov wrote: > > On Thu, Dec 17, 2020 at 09:26:09AM -0800, Yonghong Song wrote: > > > > > > On 12/17/20 7:31 AM, Florent Revest wrote: > > > On Mon, Dec 14, 2020 at 7:47 AM Yonghong Song wrote: > > > > On 12/11/20 6:40 AM, Florent Revest wrote: > > >

Re: [RFC PATCH v1 7/7] powerpc/bpf: Implement extended BPF on PPC32

2020-12-18 Thread Andrii Nakryiko
On Thu, Dec 17, 2020 at 1:54 AM Christophe Leroy wrote: > > > > Le 17/12/2020 à 07:11, Alexei Starovoitov a écrit : > > On Wed, Dec 16, 2020 at 10:07:37AM +, Christophe Leroy wrote: > >> Implement Extended Berkeley Packet Filter on Powerpc 32 > >> > >> Test result with test_bpf module: > >> >

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-18 Thread Andrii Nakryiko
On Fri, Dec 18, 2020 at 12:36 PM Alexei Starovoitov wrote: > > On Fri, Dec 18, 2020 at 10:53:57AM -0800, Andrii Nakryiko wrote: > > On Thu, Dec 17, 2020 at 7:20 PM Alexei Starovoitov > > wrote: > > > > > > On Thu, Dec 17, 2020 at 0

Re: BTFIDS: FAILED unresolved symbol udp6_sock

2021-01-04 Thread Andrii Nakryiko
On Sat, Jan 2, 2021 at 3:07 PM Jiri Olsa wrote: > > On Sat, Jan 02, 2021 at 02:25:34PM -0800, Andrii Nakryiko wrote: > > SNIP > > > > > > > so your .config has > > > CONFIG_CRYPTO_DEV_BCM_SPU=y > > > > > > and that defines 'struct devi

Re: [PATCH] selftests/bpf: clarify build error if no vmlinux

2020-12-14 Thread Andrii Nakryiko
On Mon, Dec 14, 2020 at 12:21 PM Kamal Mostafa wrote: > > If Makefile cannot find any of the vmlinux's in its VMLINUX_BTF_PATHS list, > it tries to run btftool incorrectly, with VMLINUX_BTF unset: > > bpftool btf dump file $(VMLINUX_BTF) format c > > Such that the keyword 'format' is

Re: [PATCH bpf-next v2] libbpf: Expose libbpf ringbufer epoll_fd

2020-12-15 Thread Andrii Nakryiko
On Tue, Dec 15, 2020 at 4:18 AM Brendan Jackman wrote: > > This provides a convenient perf ringbuf -> libbpf ringbuf migration > path for users of external polling systems. It is analogous to > perf_buffer__epoll_fd. > > Signed-off-by: Brendan Jackman > --- > Difference from v1: Added entry to

Re: [PATCH] samples/bpf/Makefile: Create tools/testing/selftests/bpf dir

2020-12-15 Thread Andrii Nakryiko
On Mon, Dec 14, 2020 at 2:57 AM Hui Zhu wrote: > > From: Hui Zhu > > Got an error when I built samples/bpf in a separate directory: > make O=../bk/ defconfig > make -j64 bzImage > make headers_install > make V=1 M=samples/bpf > ... > ... > make -C

Re: [PATCH v2] selftests/bpf: clarify build error if no vmlinux

2020-12-16 Thread Andrii Nakryiko
On Tue, Dec 15, 2020 at 10:20 AM Kamal Mostafa wrote: > > If Makefile cannot find any of the vmlinux's in its VMLINUX_BTF_PATHS list, > it tries to run btftool incorrectly, with VMLINUX_BTF unset: > > bpftool btf dump file $(VMLINUX_BTF) format c > > Such that the keyword 'format' is

Re: [PATCH 5.4 106/453] libbpf: Fix BTF data layout checks and allow empty BTF

2020-12-28 Thread Andrii Nakryiko
On Mon, Dec 28, 2020 at 7:49 AM Naresh Kamboju wrote: > > Perf build failed on stable-rc 5.4 branch due to this patch. > > On Mon, 28 Dec 2020 at 19:15, Greg Kroah-Hartman > wrote: > > > > From: Andrii Nakryiko > > > > [ Upstream commit d8123624506cd627

Re: BTFIDS: FAILED unresolved symbol udp6_sock

2021-01-02 Thread Andrii Nakryiko
On Wed, Dec 30, 2020 at 5:28 AM Jiri Olsa wrote: > > On Wed, Dec 30, 2020 at 10:03:37AM +0100, Jiri Olsa wrote: > > On Tue, Dec 29, 2020 at 11:28:35PM +, Qais Yousef wrote: > > > Hi Jiri > > > > > > On 12/29/20 18:34, Jiri Olsa wrote: > > > > On Tue, Dec 29, 2020 at 03:13:52PM +, Qais

Re: linux-next: build warning after merge of the bpf-next tree

2020-11-11 Thread Andrii Nakryiko
On Wed, Nov 11, 2020 at 6:03 AM Qian Cai wrote: > > On Wed, 2020-11-11 at 12:01 +1100, Stephen Rothwell wrote: > > Hi all, > > > > After merging the bpf-next tree, today's linux-next build (powerpc > > ppc64_defconfig) produced this warning: > > > > kernel/bpf/btf.c:4481:20: warning:

Re: [PATCH v4 bpf-next 4/5] bpf: load and verify kernel module BTFs

2020-11-11 Thread Andrii Nakryiko
On Wed, Nov 11, 2020 at 2:13 AM Jessica Yu wrote: > > +++ Andrii Nakryiko [09/11/20 17:19 -0800]: > [snipped] > >diff --git a/kernel/module.c b/kernel/module.c > >index a4fa44a652a7..f2996b02ab2e 100644 > >--- a/kernel/module.c > >+++ b/kernel/module.c &g

Re: [PATCH bpf v5 1/2] lib/strncpy_from_user.c: Don't overcopy bytes after NUL terminator

2020-11-11 Thread Andrii Nakryiko
> > This commit has strncpy start copying a byte at a time if a NUL is > spotted. > > Fixes: 6ae08ae3dea2 ("bpf: Add probe_read_{user, kernel} and > probe_read_{user, kernel}_str helpers") > Signed-off-by: Daniel Xu > --- This looks more immediately correc

Re: [PATCH bpf v5 0/2] Fix bpf_probe_read_user_str() overcopying

2020-11-11 Thread Andrii Nakryiko
On Wed, Nov 11, 2020 at 2:46 PM Daniel Xu wrote: > > 6ae08ae3dea2 ("bpf: Add probe_read_{user, kernel} and probe_read_{user, > kernel}_str helpers") introduced a subtle bug where > bpf_probe_read_user_str() would potentially copy a few extra bytes after > the NUL terminator. > > This issue is

Re: [PATCH v3 bpf] tools: bpftool: Add missing close before bpftool net attach exit

2020-11-11 Thread Andrii Nakryiko
On Wed, Nov 11, 2020 at 2:37 PM Andrii Nakryiko wrote: > > On Wed, Nov 11, 2020 at 1:24 PM Daniel Borkmann wrote: > > > > On 11/11/20 2:54 PM, Wang Hai wrote: > > > progfd is created by prog_parse_fd(), before 'bpftool net attach' exit, > > > it should be clo

Re: [PATCH v3 bpf] tools: bpftool: Add missing close before bpftool net attach exit

2020-11-11 Thread Andrii Nakryiko
On Wed, Nov 11, 2020 at 1:24 PM Daniel Borkmann wrote: > > On 11/11/20 2:54 PM, Wang Hai wrote: > > progfd is created by prog_parse_fd(), before 'bpftool net attach' exit, > > it should be closed. > > > > Fixes: 04949ccc273e ("tools: bpftool: add net attach command to attach XDP > > on

Re: [PATCH bpf-next 1/2] bpf: Augment the set of sleepable LSM hooks

2020-11-12 Thread Andrii Nakryiko
On Thu, Nov 12, 2020 at 9:20 AM KP Singh wrote: > > From: KP Singh > > Update the set of sleepable hooks with the ones that do not trigger > a warning with might_fault() when exercised with the correct kernel > config options enabled, i.e. > > DEBUG_ATOMIC_SLEEP=y > LOCKDEP=y >

Re: [PATCH bpf-next 2/2] bpf: Expose bpf_d_path helper to sleepable LSM hooks

2020-11-12 Thread Andrii Nakryiko
programs and merely uses the > list of sleeable hooks as the initial subset of LSM hooks where it can > be used. > > Signed-off-by: KP Singh > --- LGTM. Acked-by: Andrii Nakryiko > kernel/trace/bpf_trace.c | 7 ++- > 1 file changed, 6 insertions(+), 1 deletion(-) >

Re: [PATCH bpf v5 0/2] Fix bpf_probe_read_user_str() overcopying

2020-11-12 Thread Andrii Nakryiko
On Thu, Nov 12, 2020 at 11:13 AM Daniel Xu wrote: > > On Wed Nov 11, 2020 at 3:22 PM PST, Andrii Nakryiko wrote: > > On Wed, Nov 11, 2020 at 2:46 PM Daniel Xu wrote: > > > > > > 6ae08ae3dea2 ("bpf: Add probe_read_{user, kernel} and probe_read_{user, >

Re: [PATCH v4 bpf-next 4/5] bpf: load and verify kernel module BTFs

2020-11-13 Thread Andrii Nakryiko
On Fri, Nov 13, 2020 at 2:32 AM Jessica Yu wrote: > > +++ Andrii Nakryiko [11/11/20 12:11 -0800]: > >On Wed, Nov 11, 2020 at 2:13 AM Jessica Yu wrote: > >> > >> +++ Andrii Nakryiko [09/11/20 17:19 -0800]: > >> [snipped] > >> >diff --

Re: [RFC bpf-next 2/3] libbpf: bpf__find_by_name[_kind] should use btf__get_nr_types()

2020-11-13 Thread Andrii Nakryiko
On Fri, Nov 13, 2020 at 10:11 AM Alan Maguire wrote: > > When operating on split BTF, btf__find_by_name[_kind] will not > iterate over all types since they use btf->nr_types to show > the number of types to iterate over. For split BTF this is > the number of types _on top of base BTF_, so it

Re: [RFC bpf-next 3/3] selftests/bpf: verify module-specific types can be shown via bpf_snprintf_btf

2020-11-13 Thread Andrii Nakryiko
On Fri, Nov 13, 2020 at 10:11 AM Alan Maguire wrote: > > Verify that specifying a module name in "struct btf_ptr *" along > with a type id of a module-specific type will succeed. > > veth_stats_rx() is chosen because its function signature consists > of a module-specific type "struct veth_stats"

Re: [RFC bpf-next 1/3] bpf: add module support to btf display helpers

2020-11-13 Thread Andrii Nakryiko
On Fri, Nov 13, 2020 at 10:11 AM Alan Maguire wrote: > > bpf_snprintf_btf and bpf_seq_printf_btf use a "struct btf_ptr *" > argument that specifies type information about the type to > be displayed. Augment this information to include a module > name, allowing such display to support module

Re: Segfault in pahole 1.18 when building kernel 5.9.1 for arm64

2020-10-20 Thread Andrii Nakryiko
On Tue, Oct 20, 2020 at 10:05 AM Hao Luo wrote: > > Thanks for reporting this and cc'ing me. I forgot to update the error > messages when renaming the flags. I will send a patch to fix the error > message. > > The commit > > commit f3d9054ba8ff1df0fc44e507e3a01c0964cabd42 > Author: Hao Luo >

Re: Segfault in pahole 1.18 when building kernel 5.9.1 for arm64

2020-10-20 Thread Andrii Nakryiko
On Tue, Oct 20, 2020 at 3:51 AM Jiri Slaby wrote: > > Hi, > > On 19. 10. 20, 1:18, Érico Rolim wrote: > > I'm trying to build kernel 5.9.1 for arm64, and my dotconfig has > > `CONFIG_DEBUG_INFO_BTF=y`, which requires pahole for building. However, > > pahole > > version 1.18 segfaults during the

Re: Segfault in pahole 1.18 when building kernel 5.9.1 for arm64

2020-10-21 Thread Andrii Nakryiko
On Wed, Oct 21, 2020 at 6:48 AM Arnaldo Carvalho de Melo wrote: > > Em Wed, Oct 21, 2020 at 08:22:40AM +0200, Jiri Slaby escreveu: > > On 20. 10. 20, 14:20, Arnaldo Carvalho de Melo wrote: > > > > Yeah, I observe the very same. I reported it at: > > > >

Re: [PATCH] bpf: fix -Wshadow warnings

2020-10-26 Thread Andrii Nakryiko
ll the locals in that macro with __ to avoid most of > these warnings. > > Fixes: 492ecee892c2 ("bpf: enable program stats") > Signed-off-by: Arnd Bergmann > --- Acked-by: Andrii Nakryiko > include/linux/filter.h | 22 +++--- > 1 file changed, 11 ins

Re: [PATCH] bpf: suppress -Wcast-function-type warning

2020-10-26 Thread Andrii Nakryiko
~~ > > This appears to be intentional, so change the cast in a way that > suppresses the warning. > > Signed-off-by: Arnd Bergmann > --- LGTM. Acked-by: Andrii Nakryiko > include/linux/filter.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --g

Re: [PATCH] bpf: fix incorrect initialization of bpf_ctx_convert_map

2020-10-26 Thread Andrii Nakryiko
On Mon, Oct 26, 2020 at 2:04 PM Arnd Bergmann wrote: > > From: Arnd Bergmann > > gcc -Wextra points out that a field may get overridden in some > configurations such as x86 allmodconfig, when the next index after the one > that has been assigned last already had a value, in this case for index >

  1   2   3   4   5   6   >