Re: [PATCH 0/4] tracing: improve symbolic printing

2023-10-04 Thread Alan Maguire
On 04/10/2023 18:29, Steven Rostedt wrote: > On Wed, 4 Oct 2023 09:54:31 -0700 > Jakub Kicinski wrote: > >> On Wed, 4 Oct 2023 12:35:24 -0400 Steven Rostedt wrote: Potentially naive question - the trace point holds enum skb_drop_reason. The user space can get the names from BTF. Can we

Re: [PATCH 0/4] tracing: improve symbolic printing

2023-10-04 Thread Alan Maguire
On 04/10/2023 22:43, Steven Rostedt wrote: > On Wed, 4 Oct 2023 22:35:07 +0100 > Alan Maguire wrote: > >> One thing we've heard from some embedded folks [1] is that having >> kernel BTF loadable as a separate module (rather than embedded in >> vmlinux) would h

Re: [PATCH] bpf/btf: Move tracing BTF APIs to the BTF library

2023-10-11 Thread Alan Maguire
would be good to confirm. > Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Alan Maguire > --- > include/linux/btf.h| 24 + > kernel/bpf/btf.c | 115 +

Re: [PATCH v3 1/2] kunit: support failure from dynamic analysis tools

2021-02-11 Thread Alan Maguire
On Thu, 11 Feb 2021, David Gow wrote: > On Wed, Feb 10, 2021 at 6:14 AM Daniel Latypov wrote: > > > > From: Uriel Guajardo > > > > Add a kunit_fail_current_test() function to fail the currently running > > test, if any, with an error message. > > > > This is largely intended for dynamic analysis

Re: [PATCH v3 0/2] kunit: fail tests on UBSAN errors

2021-02-10 Thread Alan Maguire
s://lore.kernel.org/linux-kselftest/20200806174326.3577537-1-urielguajard...@gmail.com/ > For the series: Reviewed-by: Alan Maguire Thanks!

Re: [PATCH v2 1/2] kunit: support failure from dynamic analysis tools

2021-02-09 Thread Alan Maguire
On Fri, 5 Feb 2021, Daniel Latypov wrote: > From: Uriel Guajardo > > Add a kunit_fail_current_test() function to fail the currently running > test, if any, with an error message. > > This is largely intended for dynamic analysis tools like UBSAN and for > fakes. > E.g. say I had a fake ops stru

Re: [PATCH v2 1/2] kunit: support failure from dynamic analysis tools

2021-02-09 Thread Alan Maguire
On Tue, 9 Feb 2021, Daniel Latypov wrote: > On Tue, Feb 9, 2021 at 9:26 AM Alan Maguire wrote: > > > > On Fri, 5 Feb 2021, Daniel Latypov wrote: > > > > > From: Uriel Guajardo > > > > > > Add a kunit_fail_current_test() function to fail the cur

[RFC PATCH bpf-next 1/4] bpf: provide function to get vmlinux BTF information

2020-08-06 Thread Alan Maguire
It will be used later for BPF structure display support Signed-off-by: Alan Maguire --- include/linux/bpf.h | 2 ++ kernel/bpf/verifier.c | 18 -- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index cef4ef0..55eb67d

[RFC PATCH bpf-next 2/4] bpf: make BTF show support generic, apply to seq files/bpf_trace_printk

2020-08-06 Thread Alan Maguire
t; field; it is used to allow tracepoint filtering as typed display information can easily be interspersed with other tracing data, making it hard to read. Specifying a trace_id will allow users to selectively trace data, eliminating noise. Signed-off-by: Alan Maguire --- include/linux/bpf.h

[RFC PATCH bpf-next 0/4] bpf: add bpf-based bpf_trace_printk()-like support

2020-08-06 Thread Alan Maguire
on of the target dummy value which is either all zeros or all 0xff values; the idea is this exercises the "skip if zero" and "print everything" cases. - added support in BPF for using the %pT format specifier in bpf_trace_printk() - added BPF tests which ensure %pT format spe

[RFC PATCH bpf-next 3/4] bpf: add bpf_trace_btf helper

2020-08-06 Thread Alan Maguire
/union members; they are not displayed by default Signed-off-by: Alan Maguire --- include/linux/bpf.h| 1 + include/linux/btf.h| 9 ++-- include/uapi/linux/bpf.h | 63 + kernel/bpf/core.c | 5 ++ kernel

[RFC PATCH bpf-next 4/4] selftests/bpf: add bpf_trace_btf helper tests

2020-08-06 Thread Alan Maguire
Basic tests verifying various flag combinations for bpf_trace_btf() using a tp_btf program to trace skb data. Signed-off-by: Alan Maguire --- tools/testing/selftests/bpf/prog_tests/trace_btf.c | 45 ++ .../selftests/bpf/progs/netif_receive_skb.c| 43

[PATCH bpf] bpf: doc: remove references to warning message when using bpf_trace_printk()

2020-08-07 Thread Alan Maguire
ad of trace_printk()") Signed-off-by: Alan Maguire --- Documentation/bpf/bpf_design_QA.rst | 11 --- 1 file changed, 11 deletions(-) diff --git a/Documentation/bpf/bpf_design_QA.rst b/Documentation/bpf/bpf_design_QA.rst index 12a246f..2df7b06 100644 --- a/Documentation/bpf/bpf_design_QA

Re: [PATCH 1/2] kunit: support failure from dynamic analysis tools

2020-08-07 Thread Alan Maguire
On Thu, 6 Aug 2020, Uriel Guajardo wrote: > Adds an API to allow dynamic analysis tools to fail the currently > running KUnit test case. > > - Always places the kunit test in the task_struct to allow other tools > to access the currently running KUnit test. > > - Creates a new header file to avo

Re: [RFC PATCH bpf-next 2/4] bpf: make BTF show support generic, apply to seq files/bpf_trace_printk

2020-08-18 Thread Alan Maguire
On Fri, 14 Aug 2020, Alexei Starovoitov wrote: > On Fri, Aug 14, 2020 at 02:06:37PM +0100, Alan Maguire wrote: > > On Wed, 12 Aug 2020, Alexei Starovoitov wrote: > > > > > On Thu, Aug 06, 2020 at 03:42:23PM +0100, Alan Maguire wrote: > > > > > &

[RFC PATCH bpf-next 0/2] bpf, libbpf: share BTF data show functionality

2021-01-11 Thread Alan Maguire
format. The test closely mirrors the BPF program associated with the snprintf_btf.c; in this case however the string representations are verified in userspace rather than in BPF program context. Alan Maguire (2): bpf: share BTF "show" implementation between kernel and libbpf selftests

[RFC PATCH bpf-next 2/2] selftests/bpf: test libbpf-based type display

2021-01-11 Thread Alan Maguire
Test btf__snprintf with various base/kernel types and ensure display is as expected; tests are identical to those in snprintf_btf test save for the fact these run in userspace rather than BPF program context. Signed-off-by: Alan Maguire --- .../selftests/bpf/prog_tests/snprintf_btf_user.c

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

2021-01-11 Thread Alan Maguire
d\n", skb_id); else btf__snprintf(btf, buf, sizeof(buf), skb_id, skb, 0); Suggested-by: Alexei Starovoitov Signed-off-by: Alan Maguire --- include/linux/btf.h | 121 +--- include/linux/btf_common.h | 286 + kernel/bpf/Makefile |2 +

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

2021-01-14 Thread Alan Maguire
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 > > representation of the typed data to a string via > > > > LIBBPF_API int > > btf__s

[PATCH v2 bpf-next 0/3] bpf: support module BTF in BTF display helpers

2020-12-04 Thread Alan Maguire
likely be supported directly in the BPF program via __builtin_btf_type_id(); but I need to determine a good test to determine if that builtin supports object ids. Changes since RFC - add patch to remove module mutex - modify to use obj_id instead of module name as identifier in "struct btf_ptr&

[PATCH v2 bpf-next 2/3] bpf: add module support to btf display helpers

2020-12-04 Thread Alan Maguire
the object id specifies the module the type is in, or if no such id is found in the module list, we fall back to vmlinux. Signed-off-by: Alan Maguire --- include/linux/btf.h| 12 include/uapi/linux/bpf.h | 13 +++-- kernel/bpf/btf.c

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

2020-12-04 Thread Alan Maguire
t net_device". Currently the tests take the messy approach of determining object and type ids for the relevant module/function; __builtin_btf_type_id() supports object ids by returning a 64-bit value, but need to find a good way to determine if that support is present. Signed-off-by: Alan M

[PATCH v2 bpf-next 1/3] bpf: eliminate btf_module_mutex as RCU synchronization can be used

2020-12-04 Thread Alan Maguire
auditing example in Documentation/RCU/listRCU.rst ; and as such we can eliminate the lock and use list_del_rcu()/call_rcu() on module removal, and list_add_rcu() for module addition. Signed-off-by: Alan Maguire --- kernel/bpf/btf.c | 31 +-- 1 file changed, 17 insertions

Re: [PATCH v2 bpf-next 0/3] bpf: support module BTF in BTF display helpers

2020-12-05 Thread Alan Maguire
On Sat, 5 Dec 2020, Yonghong Song wrote: > > > __builtin_btf_type_id() is really only supported in llvm12 > and 64bit return value support is pushed to llvm12 trunk > a while back. The builtin is introduced in llvm11 but has a > corner bug, so llvm12 is recommended. So if people use the builti

[RFC PATCH bpf-next] ksnoop: kernel argument/return value tracing/display using BTF

2021-01-04 Thread Alan Maguire
edicate, e.g. ksnoop "ip_send_skb(skb->dev == 0, skb)" ...as this will be evaluated before the skb is stringified, and we potentially avoid that operation if the predicate fails. The same is _not_ true however in the stash case; for ksnoop "ip_send_skb(skb, return!=0)"

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

2021-01-17 Thread Alan Maguire
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 --- tools/testing/selftests/bpf/prog_tests/btf_dump.c | 233 ++ 1 file changed

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

2021-01-17 Thread Alan Maguire
btf_dump.c will need it for type-based data display. Signed-off-by: Alan Maguire --- tools/lib/bpf/libbpf.c | 4 +--- tools/lib/bpf/libbpf_internal.h | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 2abbc38

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

2021-01-17 Thread Alan Maguire
ound in it should be fixed there or vice versa; mirroring the tests should help with this also (Andrii) [1] https://lore.kernel.org/bpf/1610386373-24162-1-git-send-email-alan.magu...@oracle.com/T/#t Alan Maguire (4): libbpf: add btf_has_size() and btf_int() inlines libbpf: make skip_mods_an

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

2021-01-17 Thread Alan Maguire
6744073709551615, }, }, ... Signed-off-by: Alan Maguire --- tools/lib/bpf/btf.h | 17 + tools/lib/bpf/btf_dump.c | 974 +++ tools/lib/bpf/libbpf.map | 5 + 3 files changed, 996 insertions(+) diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/b

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

2021-01-17 Thread Alan Maguire
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 --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h index 1237bcd

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

2021-01-22 Thread Alan Maguire
On Thu, 21 Jan 2021, Andrii Nakryiko wrote: > 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

Re: [RFC PATCH bpf-next] ksnoop: kernel argument/return value tracing/display using BTF

2021-01-05 Thread Alan Maguire
On Tue, 5 Jan 2021, Cong Wang wrote: > On Mon, Jan 4, 2021 at 7:29 AM Alan Maguire wrote: > > > > BPF Type Format (BTF) provides a description of kernel data structures > > and of the types kernel functions utilize as arguments and return values. > > >

[PATCH bpf] bpftool: fix compilation failure for net.o with older glibc

2021-01-06 Thread Alan Maguire
needed for compilation anyhow. [1] https://lore.kernel.org/netdev/1461512707-23058-1-git-send-email-mikko.rapeli__34748.27880641$1462831734$gmane$o...@iki.fi/ Fixes: f6f3bac08ff9 ("tools/bpf: bpftool: add net support") Signed-off-by: Alan Maguire --- tools/bpf/bpftool/net.c | 1

Re: bpf: test_tunnel.sh: BUG: unable to handle kernel NULL pointer dereference

2019-02-11 Thread Alan Maguire
;s been initialized via __metadata_dst_init alright. I think the fix here is to use skb_valid_dst(skb) - it checks for DST_METADATA also, and with that fix in place, the problem - which was previously 100% reproducible - disappears. However what we should do in terms of path MTU setting for such

[PATCH linux-kselftest-test 3/3] kunit: update documentation to describe module-based build

2019-10-08 Thread Alan Maguire
Documentation should describe how to build kunit and tests as modules. Signed-off-by: Knut Omang Signed-off-by: Alan Maguire --- Documentation/dev-tools/kunit/faq.rst | 3 ++- Documentation/dev-tools/kunit/index.rst | 3 +++ Documentation/dev-tools/kunit/usage.rst | 16 3

[PATCH linux-kselftest-test 2/3] kunit: allow kunit to be loaded as a module

2019-10-08 Thread Alan Maguire
will load the tests along with the kunit module and run them. Signed-off-by: Knut Omang Signed-off-by: Alan Maguire --- kunit/Kconfig | 2 +- kunit/Makefile | 9 + kunit/test.c | 4 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/kunit/Kconfig b/kunit/Kconfig ind

[PATCH linux-kselftest-test 0/3] kunit: support module-based build

2019-10-08 Thread Alan Maguire
"always m"). KUnit based tests will load the kunit module as an implicit dependency. Alan Maguire (3): kunit: allow kunit tests to be loaded as a module kunit: allow kunit to be loaded as a module kunit: update documentation to describe module-based build Documentation/

[PATCH linux-kselftest-test 1/3] kunit: allow kunit tests to be loaded as a module

2019-10-08 Thread Alan Maguire
e. Signed-off-by: Knut Omang Signed-off-by: Alan Maguire --- include/kunit/test.h | 36 ++-- kernel/sysctl-test.c | 6 +- kunit/Kconfig | 4 ++-- kunit/assert.c | 8 kunit/example-test.c | 6 +- ku

[PATCH v2 linux-kselftest-test 0/3] kunit: support building core/tests as modules

2019-10-08 Thread Alan Maguire
dules. Patch 2 allows kunit itself to be loaded as a module. Patch 3 documents module support. Alan Maguire (3): kunit: allow kunit tests to be loaded as a module kunit: allow kunit to be loaded as a module kunit: update documentation to describe module-based build Documentation/dev-tools/

[PATCH v2 linux-kselftest-test 2/3] kunit: allow kunit to be loaded as a module

2019-10-08 Thread Alan Maguire
will load the tests along with the kunit module and run them. Signed-off-by: Alan Maguire Signed-off-by: Knut Omang --- lib/kunit/Kconfig | 2 +- lib/kunit/Makefile | 4 +++- lib/kunit/test.c | 4 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/kunit/Kconfig b/lib

[PATCH v2 linux-kselftest-test 3/3] kunit: update documentation to describe module-based build

2019-10-08 Thread Alan Maguire
Documentation should describe how to build kunit and tests as modules. Signed-off-by: Alan Maguire Signed-off-by: Knut Omang --- Documentation/dev-tools/kunit/faq.rst | 3 ++- Documentation/dev-tools/kunit/index.rst | 3 +++ Documentation/dev-tools/kunit/usage.rst | 16 3

[PATCH v2 linux-kselftest-test 1/3] kunit: allow kunit tests to be loaded as a module

2019-10-08 Thread Alan Maguire
e. Signed-off-by: Alan Maguire Signed-off-by: Knut Omang --- include/kunit/test.h | 30 +++--- kernel/sysctl-test.c | 6 +- lib/Kconfig.debug | 4 ++-- lib/kunit/Kconfig | 4 ++-- lib/kunit/assert.c | 8 +++

Re: [PATCH linux-kselftest-test 2/3] kunit: allow kunit to be loaded as a module

2019-10-08 Thread Alan Maguire
On Tue, 8 Oct 2019, Andy Shevchenko wrote: > On Tue, Oct 08, 2019 at 03:43:51PM +0100, Alan Maguire wrote: > > Making kunit itself buildable as a module allows for "always-on" > > kunit configuration; specifying CONFIG_KUNIT=m means the module > > is built but onl

Re: [PATCH v2 linux-kselftest-test 1/3] kunit: allow kunit tests to be loaded as a module

2019-10-09 Thread Alan Maguire
On Tue, 8 Oct 2019, Brendan Higgins wrote: > On Tue, Oct 08, 2019 at 03:55:44PM +0100, Alan Maguire wrote: > > as tests are added to kunit, it will become less feasible to execute > > all built tests together. By supporting modular tests we provide > > a simple way to do sel

Re: [PATCH v7 0/5] KUnit-KASAN Integration

2020-05-03 Thread Alan Maguire
s patchset has a v4 so I'm not sure if that will have implications for applying your changes on top of it (haven't tested it yet myself). For the series feel free to add Tested-by: Alan Maguire I'll try and take some time to review v7 shortly, but I wanted to confirm the issues I saw

Re: [RFC PATCH bpf-next 0/6] bpf, printk: add BTF-based type printing

2020-04-30 Thread Alan Maguire
On Mon, 20 Apr 2020, Joe Perches wrote: > On Mon, 2020-04-20 at 16:29 +0100, Alan Maguire wrote: > > On Sat, 18 Apr 2020, Alexei Starovoitov wrote: > > > > > On Fri, Apr 17, 2020 at 11:42:34AM +0100, Alan Maguire wrote: > > > > The printk family of functio

Re: [PATCH v2 linux-kselftest-test 1/3] kunit: allow kunit tests to be loaded as a module

2019-10-11 Thread Alan Maguire
On Fri, 11 Oct 2019, Brendan Higgins wrote: > Sorry for the delayed reply. I will be on vacation until Wednesday, > October 16th. > > On Wed, Oct 9, 2019 at 9:36 AM Alan Maguire wrote: > > > > On Tue, 8 Oct 2019, Brendan Higgins wrote: > > > > > On Tue,

Re: [PATCH v2 linux-kselftest-test 0/3] kunit: support building core/tests as modules

2019-10-14 Thread Alan Maguire
On Mon, 14 Oct 2019, Luis Chamberlain wrote: > On Tue, Oct 08, 2019 at 03:55:43PM +0100, Alan Maguire wrote: > > The current kunit execution model is to provide base kunit functionality > > and tests built-in to the kernel. The aim of this series is to allow > > buil

Re: [PATCH v2 linux-kselftest-test 1/3] kunit: allow kunit tests to be loaded as a module

2019-10-17 Thread Alan Maguire
On Wed, 16 Oct 2019, Brendan Higgins wrote: > On Fri, Oct 11, 2019 at 11:25:33AM +0100, Alan Maguire wrote: > > On Fri, 11 Oct 2019, Brendan Higgins wrote: > > > > > Sorry for the delayed reply. I will be on vacation until Wednesday, > > > October 16th. > &g

Re: [PATCH linux-kselftest/test v1] apparmor: add AppArmor KUnit tests for policy unpack

2019-10-19 Thread Alan Maguire
On Fri, 18 Oct 2019, Luis Chamberlain wrote: > On Thu, Oct 17, 2019 at 05:18:16PM -0700, Brendan Higgins wrote: > > From: Mike Salvatore > > > > In order to write the tests against the policy unpacking code, some > > static functions needed to be exposed for testing purposes. One of the > > goal

Re: [PATCH v3 3/7] kunit: tests for stats_fs API

2020-05-27 Thread Alan Maguire
On Tue, 26 May 2020, Emanuele Giuseppe Esposito wrote: > Add kunit tests to extensively test the stats_fs API functionality. > I've added in the kunit-related folks. > In order to run them, the kernel .config must set CONFIG_KUNIT=y > and a new .kunitconfig file must be created with CONFIG_STAT

[PATCH bpf-next 2/2] selftests/bpf: add selftests verifying bpf_trace_printk() behaviour

2020-07-03 Thread Alan Maguire
Simple selftest that verifies bpf_trace_printk() returns a sensible value and tracing messages appear. Signed-off-by: Alan Maguire --- .../selftests/bpf/prog_tests/trace_printk.c| 71 ++ tools/testing/selftests/bpf/progs/trace_printk.c | 21 +++ 2 files changed

[PATCH bpf-next 0/2] bpf: fix use of trace_printk() in BPF

2020-07-03 Thread Alan Maguire
://lore.kernel.org/r/20200628194334.6238b...@oasis.local.home Alan Maguire (2): bpf: use dedicated bpf_trace_printk event instead of trace_printk() selftests/bpf: add selftests verifying bpf_trace_printk() behaviour kernel/trace/Makefile | 2 + kernel/trace

[PATCH bpf-next 1/2] bpf: use dedicated bpf_trace_printk event instead of trace_printk()

2020-07-03 Thread Alan Maguire
https://lore.kernel.org/r/20200628194334.6238b...@oasis.local.home Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Alan Maguire --- kernel/trace/Makefile| 2 ++ kernel/trace/bpf_trace.c | 41 + kernel/trace/bpf_trace.h

Re: linux-next: build failure after merge of the thunderbolt tree

2020-06-30 Thread Alan Maguire
30 Jun 2020 15:51:50 +1000 > Subject: [PATCH] thunderbolt: merge fix for kunix_resource changes > > Signed-off-by: Stephen Rothwell Thanks Stephen, resolution looks good to me! If you need it Reviewed-by: Alan Maguire Once the kunit and thunderbolt trees are merged there may be some additio

Re: [PATCH v3 bpf-next 4/8] printk: add type-printing %pT format specifier which uses BTF

2020-06-26 Thread Alan Maguire
On Fri, 26 Jun 2020, Petr Mladek wrote: > On Tue 2020-06-23 13:07:07, Alan Maguire wrote: > > printk supports multiple pointer object type specifiers (printing > > netdev features etc). Extend this support using BTF to cover > > arbitrary types. "%pT" spec

[PATCH v3 bpf-next 1/8] bpf: provide function to get vmlinux BTF information

2020-06-23 Thread Alan Maguire
It will be used later for BTF printk() support Signed-off-by: Alan Maguire --- include/linux/bpf.h | 2 ++ kernel/bpf/verifier.c | 18 -- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 07052d4..a2ecebd 100644

[PATCH v3 bpf-next 0/8] bpf, printk: add BTF-based type printing

2020-06-23 Thread Alan Maguire
rtant note: if running test_printf.ko - the version in the bpf-next tree will induce a panic when running the fwnode_pointer() tests due to a kobject issue; applying the patch in https://lkml.org/lkml/2020/4/17/389 ...resolved this issue for me. Alan Maguire (8): bpf: provide function to get vm

[PATCH v3 bpf-next 3/8] checkpatch: add new BTF pointer format specifier

2020-06-23 Thread Alan Maguire
checkpatch complains about unknown format specifiers, so add the BTF format specifier we will implement in a subsequent patch to avoid errors. Signed-off-by: Alan Maguire --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b

[PATCH v3 bpf-next 7/8] bpf: add support for %pT format specifier for bpf_trace_printk() helper

2020-06-23 Thread Alan Maguire
Allow %pT[cNx0] format specifier for BTF-based display of data associated with pointer. The unsafe data modifier 'u' - where the source data is traversed without copying it to a safe buffer via probe_kernel_read() - is not supported. Signed-off-by: Alan Maguire --- include/uapi/l

[PATCH v3 bpf-next 4/8] printk: add type-printing %pT format specifier which uses BTF

2020-06-23 Thread Alan Maguire
k output is truncated at 1024 bytes. For cases where overflow is likely, the compact/no type names display modes may be used. Signed-off-by: Alan Maguire i --- Documentation/core-api/printk-formats.rst | 17 ++ include/linux/btf.h | 3 +- include/linux/printk.h

[PATCH v3 bpf-next 6/8] printk: extend test_printf to test %pT BTF-based format specifier

2020-06-23 Thread Alan Maguire
. These changes add up to approximately 20,000 new tests covering all enum, struct, union and typedefs in vmlinux BTF. Individual tests are also added for int, char, struct, enum and typedefs which verify output is as expected. Signed-off-by: Alan Maguire --- include/linux/btf.h | 3 + kernel/bpf

[PATCH v3 bpf-next 8/8] bpf/selftests: add tests for %pT format specifier

2020-06-23 Thread Alan Maguire
tests verify we get 0 return value from bpf_trace_print() using %pT format specifier with various modifiers/pointer values. Signed-off-by: Alan Maguire --- .../selftests/bpf/prog_tests/trace_printk_btf.c| 45 + .../selftests/bpf/progs/netif_receive_skb.c| 47

[PATCH v3 bpf-next 5/8] printk: initialize vmlinux BTF outside of printk in late_initcall()

2020-06-23 Thread Alan Maguire
vmlinux BTF initialization can take time so it's best to do that outside of printk context; otherwise the first printk() using %pT will trigger BTF initialization. Signed-off-by: Alan Maguire --- lib/vsprintf.c | 12 1 file changed, 12 insertions(+) diff --git a/lib/vsprint

[PATCH v3 bpf-next 2/8] bpf: move to generic BTF show support, apply it to seq files/strings

2020-06-23 Thread Alan Maguire
te pointer values. BTF_SHOW_UNSAFE - do not copy data to safe buffer before display. BTF_SHOW_ZERO - show zeroed values (by default they are not shown). Signed-off-by: Alan Maguire --- include/linux/btf.h | 36 ++ kernel/bpf/btf.c| 966 ++-

[PATCH v3 bpf-next 0/2] bpf: fix use of trace_printk() in BPF

2020-07-13 Thread Alan Maguire
l not prevent tracing output from being logged (Steven, patch 1) - use "tp/raw_syscalls/sys_enter" and a usleep(1) to trigger events in the selftest ensuring test runs faster (Andrii, patch 2) [1] https://lore.kernel.org/r/20200628194334.6238b...@oasis.local.home Alan Maguire (2): bpf

[PATCH v3 bpf-next 2/2] selftests/bpf: add selftests verifying bpf_trace_printk() behaviour

2020-07-13 Thread Alan Maguire
Simple selftests that verifies bpf_trace_printk() returns a sensible value and tracing messages appear. Signed-off-by: Alan Maguire Acked-by: Andrii Nakryiko --- .../selftests/bpf/prog_tests/trace_printk.c| 75 ++ tools/testing/selftests/bpf/progs/trace_printk.c

[PATCH v3 bpf-next 1/2] bpf: use dedicated bpf_trace_printk event instead of trace_printk()

2020-07-13 Thread Alan Maguire
https://lore.kernel.org/r/20200628194334.6238b...@oasis.local.home Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Alan Maguire Acked-by: Andrii Nakryiko --- kernel/trace/Makefile| 2 ++ kernel/trace/bpf_trace.c | 42 +- kernel/trace/bpf_trace.h

[PATCH bpf-next 1/2] selftests/bpf: fix unused-result warning in snprintf_btf.c

2020-09-29 Thread Alan Maguire
declared with attribute warn_unused_result [-Wunused-result] system("ping -c 1 127.0.0.1 > /dev/null"); ^ [...] Fixes: 076a95f5aff2 ("selftests/bpf: Add bpf_snprintf_btf helper tests") Reported-by: Daniel Borkmann Signed-off-

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

2020-09-29 Thread Alan Maguire
lftests/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 --- tools/testing/selftests/bpf/progs/bpf_iter.h | 23 ++ tools/testing/s

[PATCH bpf-next 0/2] selftests/bpf: BTF-based kernel data display fixes

2020-09-29 Thread Alan Maguire
Resolve issues in bpf selftests introduced with BTF-based kernel data display selftests; these are - a warning introduced in snprintf_btf.c; and - compilation failures with old kernels vmlinux.h Alan Maguire (2): selftests/bpf: fix unused-result warning in snprintf_btf.c selftests/bpf

[PATCH v7 bpf-next 1/8] bpf: provide function to get vmlinux BTF information

2020-09-28 Thread Alan Maguire
It will be used later for BPF structure display support Signed-off-by: Alan Maguire --- include/linux/bpf.h | 2 ++ kernel/bpf/verifier.c | 18 -- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 7990232..2eae3f3

[PATCH v7 bpf-next 0/8] bpf: add helpers to support BTF-based kernel data display

2020-09-28 Thread Alan Maguire
BPF for using the %pT format specifier in bpf_trace_printk() - added BPF tests which ensure %pT format specifier use works (Alexei). Alan Maguire (8): bpf: provide function to get vmlinux BTF information bpf: move to generic BTF show support, apply it to seq files/strings bpf: add bpf_snprint

[PATCH v7 bpf-next 3/8] bpf: add bpf_snprintf_btf helper

2020-09-28 Thread Alan Maguire
ruct/union member names/types - BTF_F_PTR_RAW:show raw (unobfuscated) pointer values; equivalent to %px. - BTF_F_ZERO: show zero-valued struct/union members; they are not displayed by default Signed-off-by: Alan Maguire --- include/l

[PATCH v7 bpf-next 2/8] bpf: move to generic BTF show support, apply it to seq files/strings

2020-09-28 Thread Alan Maguire
te pointer values. BTF_SHOW_UNSAFE - do not copy data to safe buffer before display. BTF_SHOW_ZERO - show zeroed values (by default they are not shown). Signed-off-by: Alan Maguire --- include/linux/btf.h | 36 ++ kernel/bpf/btf.c| 1007 +-

[PATCH v7 bpf-next 7/8] bpf: add bpf_seq_printf_btf helper

2020-09-28 Thread Alan Maguire
bpf_snprintf_btf helper, and the helper returns 0 on success or a negative error value. Suggested-by: Alexei Starovoitov Signed-off-by: Alan Maguire --- include/linux/btf.h| 2 ++ include/uapi/linux/bpf.h | 9 + kernel/bpf/btf.c | 4 ++-- kernel/bpf/core.c

[PATCH v7 bpf-next 6/8] selftests/bpf: fix overflow tests to reflect iter size increase

2020-09-28 Thread Alan Maguire
bpf iter size increase to PAGE_SIZE << 3 means overflow tests assuming page size need to be bumped also. Signed-off-by: Alan Maguire --- tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/testing/sel

[PATCH v7 bpf-next 4/8] selftests/bpf: add bpf_snprintf_btf helper tests

2020-09-28 Thread Alan Maguire
Tests verifying snprintf()ing of various data structures, flags combinations using a tp_btf program. Tests are skipped if __builtin_btf_type_id is not available to retrieve BTF type ids. Signed-off-by: Alan Maguire --- .../selftests/bpf/prog_tests/snprintf_btf.c| 60

[PATCH v7 bpf-next 5/8] bpf: bump iter seq size to support BTF representation of large data structures

2020-09-28 Thread Alan Maguire
BPF iter size is limited to PAGE_SIZE; if we wish to display BTF-based representations of larger kernel data structures such as task_struct, this will be insufficient. Suggested-by: Alexei Starovoitov Signed-off-by: Alan Maguire --- kernel/bpf/bpf_iter.c | 4 ++-- 1 file changed, 2 insertions

[PATCH v7 bpf-next 8/8] selftests/bpf: add test for bpf_seq_printf_btf helper

2020-09-28 Thread Alan Maguire
Add a test verifying iterating over tasks and displaying BTF representation of task_struct succeeds. Suggested-by: Alexei Starovoitov Signed-off-by: Alan Maguire --- tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 74 ++ .../selftests/bpf/progs/bpf_iter_task_btf.c

Re: [PATCH v6 bpf-next 6/6] selftests/bpf: add test for bpf_seq_printf_btf helper

2020-09-28 Thread Alan Maguire
On Thu, 24 Sep 2020, Alexei Starovoitov wrote: > to whatever number, but printing single task_struct needs ~800 lines and > ~18kbytes. Humans can scroll through that much spam, but can we make it less > verbose by default somehow? > May be not in this patch set, but in the follow up? > One app

[PATCH v4 kunit-next 0/2] kunit: extend kunit resources API

2020-05-29 Thread Alan Maguire
for non-named resource (Brendan, patch 2) Alan Maguire (2): kunit: generalize kunit_resource API beyond allocated resources kunit: add support for named resources Alan Maguire (2): kunit: generalize kunit_resource API beyond allocated resources kunit: add support for named res

[PATCH v4 kunit-next 1/2] kunit: generalize kunit_resource API beyond allocated resources

2020-05-29 Thread Alan Maguire
I've tried moving to kunit_[action]_resource() as the format of function names for consistency and readability. [1] https://lkml.org/lkml/2020/2/26/1286 Signed-off-by: Alan Maguire Reviewed-by: Brendan Higgins --- include/kunit/test.h | 156 +--

[PATCH v4 kunit-next 2/2] kunit: add support for named resources

2020-05-29 Thread Alan Maguire
uot;match-by-name" callback. If an attempt to add a resource with a name that already exists is made kunit_add_named_resource() will return -EEXIST. Signed-off-by: Alan Maguire Reviewed-by: Brendan Higgins --- include/kunit/test.h | 54 +++

Re: [PATCH] Documentation: kunit: Add some troubleshooting tips to the FAQ

2020-06-02 Thread Alan Maguire
dent of UML so can be useful to do if running under UML is failing. When tests are built-in they will execute on boot, and modules will automatically execute associated tests when loaded. Test results can be collected from /sys/kernel/debug/kunit//results. For more details see "KUnit on non-UML architectures" in :doc:`usage`. Reviewed-by: Alan Maguire

Re: [RFC PATCH] kunit: Support skipped tests

2020-05-13 Thread Alan Maguire
On Tue, 12 May 2020, David Gow wrote: > This is a proof-of-concept to support "skipping" tests. > Really glad to see skip support; nice work! > The kunit_mark_skipped() macro marks the current test as "skipped", with > the provided reason. The kunit_skip() macro will mark the test as > skipped,

Re: [PATCH v2 bpf-next 0/7] bpf, printk: add BTF-based type printing

2020-05-14 Thread Alan Maguire
On Wed, 13 May 2020, Alexei Starovoitov wrote: > On Tue, May 12, 2020 at 06:56:38AM +0100, Alan Maguire wrote: > > The printk family of functions support printing specific pointer types > > using %p format specifiers (MAC addresses, IP addresses, etc). For > > full deta

Re: [PATCH v2 bpf-next 4/7] printk: add type-printing %pT format specifier which uses BTF

2020-05-14 Thread Alan Maguire
On Wed, 13 May 2020, Yonghong Song wrote: > > > On 5/11/20 10:56 PM, Alan Maguire wrote: > > printk supports multiple pointer object type specifiers (printing > > netdev features etc). Extend this support using BTF to cover > > arbitrary types. "%pT"

Re: [PATCH v2] kunit: added lockdep support

2020-08-13 Thread Alan Maguire
On Wed, 12 Aug 2020, Uriel Guajardo wrote: > KUnit will fail tests upon observing a lockdep failure. Because lockdep > turns itself off after its first failure, only fail the first test and > warn users to not expect any future failures from lockdep. > > Similar to lib/locking-selftest [1], we ch

Re: [RFC PATCH bpf-next 2/4] bpf: make BTF show support generic, apply to seq files/bpf_trace_printk

2020-08-14 Thread Alan Maguire
On Wed, 12 Aug 2020, Alexei Starovoitov wrote: > On Thu, Aug 06, 2020 at 03:42:23PM +0100, Alan Maguire wrote: > > > > The bpf_trace_printk tracepoint is augmented with a "trace_id" > > field; it is used to allow tracepoint filtering as typed display > > i

Re: [PATCH 5.8 574/633] selftests/bpf: Fix overflow tests to reflect iter size increase

2020-10-27 Thread Alan Maguire
On Tue, 27 Oct 2020, Greg Kroah-Hartman wrote: > From: Alan Maguire > > [ Upstream commit eb58bbf2e5c7917aa30bf8818761f26bbeeb2290 ] > > bpf iter size increase to PAGE_SIZE << 3 means overflow tests assuming > page size need to be bumped also. > Alexei can correc

Re: [PATCH bpf-next 1/2] bpf: use dedicated bpf_trace_printk event instead of trace_printk()

2020-07-09 Thread Alan Maguire
On Tue, 7 Jul 2020, Andrii Nakryiko wrote: > On Fri, Jul 3, 2020 at 7:47 AM Alan Maguire wrote: > > > > The bpf helper bpf_trace_printk() uses trace_printk() under the hood. > > This leads to an alarming warning message originating from trace > > buffer allocation wh

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

2020-11-13 Thread Alan Maguire
lly for vmlinux + module BTF, where the latter is much smaller. Use btf__get_nr_types() instead. Signed-off-by: Alan Maguire --- tools/lib/bpf/btf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index 2d0d064..0fccf4b 100644 --

[RFC bpf-next 0/3] bpf: support module BTF in btf display helpers

2020-11-13 Thread Alan Maguire
of a module-specific type id will fail in patch 3. Patch 3 is a selftest that uses veth (when built as a module) and a kprobe to display both a module-specific and kernel-specific type; both are arguments to veth_stats_rx(). Alan Maguire (3): bpf: add module support to btf disp

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

2020-11-13 Thread Alan Maguire
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 types. Signed-off-by: Alan Maguire --- include/l

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

2020-11-13 Thread Alan Maguire
t_device". Signed-off-by: Alan Maguire --- .../selftests/bpf/prog_tests/snprintf_btf_mod.c| 96 ++ tools/testing/selftests/bpf/progs/btf_ptr.h| 1 + tools/testing/selftests/bpf/progs/veth_stats_rx.c | 73 3 files changed, 170 insertions(+) cr

[PATCH bpf-next] libbpf: bpf__find_by_name[_kind] should use btf__get_nr_types()

2020-11-15 Thread Alan Maguire
lly for vmlinux + module BTF, where the latter is much smaller. Use btf__get_nr_types() instead. Fixes: ba451366bf44 ("libbpf: Implement basic split BTF support") Signed-off-by: Alan Maguire --- tools/lib/bpf/btf.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --gi

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

2020-11-15 Thread Alan Maguire
On Sat, 14 Nov 2020, Yonghong Song wrote: > > > On 11/14/20 8:04 AM, Alexei Starovoitov wrote: > > On Fri, Nov 13, 2020 at 10:59 PM Andrii Nakryiko > > wrote: > >> > >> On Fri, Nov 13, 2020 at 10:11 AM Alan Maguire > >> wrote: > >>>

Re: [PATCH bpf-next 5/5] tools/bpftool: add support for in-kernel and named BTF in `btf show`

2020-11-09 Thread Alan Maguire
to the latest changes etc and BTF generation seemed to work fine for modules during kernel build). For the "bpftool btf show" functionality, feel free to add Tested-by: Alan Maguire Thanks! Alan

[PATCH v2 bpf-next 1/2] bpf: use dedicated bpf_trace_printk event instead of trace_printk()

2020-07-10 Thread Alan Maguire
https://lore.kernel.org/r/20200628194334.6238b...@oasis.local.home Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Alan Maguire --- kernel/trace/Makefile| 2 ++ kernel/trace/bpf_trace.c | 41 - kernel/trace/bpf_trace.h

  1   2   >