Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-14 Thread Andrii Nakryiko
On Tue, Aug 13, 2024 at 9:17 PM Liao, Chang wrote: > > > > 在 2024/8/13 1:49, Andrii Nakryiko 写道: > > On Mon, Aug 12, 2024 at 4:11 AM Liao, Chang wrote: > >> > >> > >> > >> 在 2024/8/9 2:26, Andrii Nakryiko 写道: > >>> On Thu, Aug

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-14 Thread Andrii Nakryiko
On Tue, Aug 13, 2024 at 9:17 PM Liao, Chang wrote: > > > > 在 2024/8/13 1:49, Andrii Nakryiko 写道: > > On Mon, Aug 12, 2024 at 4:11 AM Liao, Chang wrote: > >> > >> > >> > >> 在 2024/8/9 2:26, Andrii Nakryiko 写道: > >>> On Thu, Aug

Re: [PATCH RFC v3 13/13] uprobes: add speculative lockless VMA to inode resolution

2024-08-15 Thread Andrii Nakryiko
On Thu, Aug 15, 2024 at 6:44 AM Mateusz Guzik wrote: > > On Tue, Aug 13, 2024 at 08:36:03AM -0700, Suren Baghdasaryan wrote: > > On Mon, Aug 12, 2024 at 11:18 PM Mateusz Guzik wrote: > > > > > > On Mon, Aug 12, 2024 at 09:29:17PM -0700, Andrii Nakryiko wrote: &g

Re: [PATCH v3 00/13] uprobes: RCU-protected hot path optimizations

2024-08-15 Thread Andrii Nakryiko
On Thu, Aug 15, 2024 at 6:25 AM Oleg Nesterov wrote: > > On 08/12, Andrii Nakryiko wrote: > > > > ( In addition to previously posted first 8 patches, I'm sending 5 more as an > > RFC for people to get the general gist of where this work heading and what > > upro

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-15 Thread Andrii Nakryiko
On Wed, Aug 14, 2024 at 7:58 PM Liao, Chang wrote: > > > > 在 2024/8/15 2:42, Andrii Nakryiko 写道: > > On Tue, Aug 13, 2024 at 9:17 PM Liao, Chang wrote: > >> > >> > >> > >> 在 2024/8/13 1:49, Andrii Nakryiko 写道: &g

Re: [PATCH] uprobes: Optimize the allocation of insn_slot for performance

2024-08-15 Thread Andrii Nakryiko
On Thu, Aug 15, 2024 at 12:59 AM Liao, Chang wrote: > > > > 在 2024/8/15 0:57, Andrii Nakryiko 写道: > > On Tue, Aug 13, 2024 at 9:17 PM Liao, Chang wrote: > >> > >> > >> > >> 在 2024/8/13 1:49, Andrii Nakryiko 写道: &g

Re: [PATCH] arm64: insn: Simulate nop and push instruction for better uprobe performance

2024-08-15 Thread Andrii Nakryiko
On Thu, Aug 15, 2024 at 2:58 AM Mark Rutland wrote: > > On Wed, Aug 14, 2024 at 08:03:56AM +, Liao Chang wrote: > > As Andrii pointed out, the uprobe/uretprobe selftest bench run into a > > counterintuitive result that nop and push variants are much slower than > > ret variant [0]. The root ca

Re: [PATCH RFC v3 13/13] uprobes: add speculative lockless VMA to inode resolution

2024-08-15 Thread Andrii Nakryiko
On Thu, Aug 15, 2024 at 11:58 AM Jann Horn wrote: > > +brauner for "struct file" lifetime > > On Thu, Aug 15, 2024 at 7:45 PM Suren Baghdasaryan wrote: > > On Thu, Aug 15, 2024 at 9:47 AM Andrii Nakryiko > > wrote: > > > > > >

Re: [PATCH bpf-next v5 1/2] bpf: enable generic kfuncs for BPF_CGROUP_* programs

2024-08-15 Thread Andrii Nakryiko
On Tue, Aug 13, 2024 at 6:28 AM Matteo Croce wrote: > > From: Matteo Croce > > These kfuncs are enabled even in BPF_PROG_TYPE_TRACING, so they > should be safe also in BPF_CGROUP_* programs. > > In enum btf_kfunc_hook, rename BTF_KFUNC_HOOK_CGROUP_SKB to a more > generic BTF_KFUNC_HOOK_CGROUP, si

Re: [PATCH bpf-next v5 2/2] bpf: allow bpf_current_task_under_cgroup() with BPF_CGROUP_*

2024-08-15 Thread Andrii Nakryiko
On Tue, Aug 13, 2024 at 6:28 AM Matteo Croce wrote: > > From: Matteo Croce > > The helper bpf_current_task_under_cgroup() currently is only allowed for > tracing programs, allow its usage also in the BPF_CGROUP_* program types. > > Move the code from kernel/trace/bpf_trace.c to kernel/bpf/helpers

Re: [PATCH RFC v3 09/13] uprobes: SRCU-protect uretprobe lifetime (with timeout)

2024-08-19 Thread Andrii Nakryiko
On Mon, Aug 19, 2024 at 6:41 AM Oleg Nesterov wrote: > > On 08/12, Andrii Nakryiko wrote: > > > > Avoid taking refcount on uprobe in prepare_uretprobe(), instead take > > uretprobe-specific SRCU lock and keep it active as kernel transfers > > control back to user s

Re: [PATCH RFC v3 09/13] uprobes: SRCU-protect uretprobe lifetime (with timeout)

2024-08-20 Thread Andrii Nakryiko
On Tue, Aug 20, 2024 at 8:06 AM Oleg Nesterov wrote: > > On 08/19, Andrii Nakryiko wrote: > > > > On Mon, Aug 19, 2024 at 6:41 AM Oleg Nesterov wrote: > > > > > > On 08/12, Andrii Nakryiko wrote: > > > > > > > > Avoid ta

Re: [PATCH v3] uprobes: turn trace_uprobe's nhit counter to be per-CPU one

2024-08-21 Thread Andrii Nakryiko
On Tue, Aug 13, 2024 at 1:34 PM Andrii Nakryiko wrote: > > trace_uprobe->nhit counter is not incremented atomically, so its value > is questionable in when uprobe is hit on multiple CPUs simultaneously. > > Also, doing this shared counter increment across many CPUs causes

Re: [PATCH v3 00/13] uprobes: RCU-protected hot path optimizations

2024-08-21 Thread Andrii Nakryiko
On Thu, Aug 15, 2024 at 9:49 AM Andrii Nakryiko wrote: > > On Thu, Aug 15, 2024 at 6:25 AM Oleg Nesterov wrote: > > > > On 08/12, Andrii Nakryiko wrote: > > > > > > ( In addition to previously posted first 8 patches, I'm sending 5 more as > > >

Re: [PATCH v3 04/13] uprobes: travers uprobe's consumer list locklessly under SRCU protection

2024-08-22 Thread Andrii Nakryiko
On Thu, Aug 22, 2024 at 7:22 AM Jiri Olsa wrote: > > On Mon, Aug 12, 2024 at 09:29:08PM -0700, Andrii Nakryiko wrote: > > SNIP > > > @@ -1125,18 +1103,31 @@ void uprobe_unregister(struct uprobe *uprobe, > > struct uprobe_consumer *uc) > > int err;

Re: [PATCH v3 04/13] uprobes: travers uprobe's consumer list locklessly under SRCU protection

2024-08-22 Thread Andrii Nakryiko
On Thu, Aug 22, 2024 at 10:35 AM Jiri Olsa wrote: > > On Thu, Aug 22, 2024 at 09:59:29AM -0700, Andrii Nakryiko wrote: > > On Thu, Aug 22, 2024 at 7:22 AM Jiri Olsa wrote: > > > > > > On Mon, Aug 12, 2024 at 09:29:08PM -0700, Andrii Nakryiko wrote: > > &g

Re: [PATCH v2] uprobes: make trace_uprobe->nhit counter a per-CPU one

2024-08-26 Thread Andrii Nakryiko
On Sun, Aug 25, 2024 at 3:15 AM Masami Hiramatsu wrote: > > On Tue, 13 Aug 2024 17:41:04 +0200 > Oleg Nesterov wrote: > > > On 08/13, Masami Hiramatsu wrote: > > > > > > > @@ -62,7 +63,7 @@ struct trace_uprobe { > > > > struct uprobe *uprobe; > > > > > > BTW, what is this chan

Re: [PATCH v3] uprobes: turn trace_uprobe's nhit counter to be per-CPU one

2024-08-29 Thread Andrii Nakryiko
On Tue, Aug 27, 2024 at 8:55 PM Masami Hiramatsu wrote: > > On Tue, 13 Aug 2024 13:34:09 -0700 > Andrii Nakryiko wrote: > > > trace_uprobe->nhit counter is not incremented atomically, so its value > > is questionable in when uprobe is hit on multiple CPUs simultaneousl

[PATCH v4 0/8] uprobes: RCU-protected hot path optimizations

2024-08-29 Thread Andrii Nakryiko
->v3: - undid rcu and rb_node fields colocation which were causing crashes (Oleg); - ensure synchronize_srcu() on registration failure in patch #4 (Oleg); v1->v2: - added back missed kfree() in patch #1 (Oleg); - forgot the rest, but there were a few small things here and there. Andrii N

[PATCH v4 1/8] uprobes: revamp uprobe refcounting and lifetime management

2024-08-29 Thread Andrii Nakryiko
orking together: __insert_uprobe() will remove uprobe from RB-tree, if it can't bump refcount and will retry to insert the new uprobe instance. put_uprobe() won't attempt to remove uprobe from RB-tree, if it's already not there. All that is protected by uprobes_treelock, which

[PATCH v4 2/8] uprobes: protected uprobe lifetime with SRCU

2024-08-29 Thread Andrii Nakryiko
ollow up patches by making them use SRCU with timeout. Signed-off-by: Andrii Nakryiko --- kernel/events/uprobes.c | 94 +++-- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 147561c

[PATCH v4 3/8] uprobes: get rid of enum uprobe_filter_ctx in uprobe filter callbacks

2024-08-29 Thread Andrii Nakryiko
It serves no purpose beyond adding unnecessray argument passed to the filter callback. Just get rid of it, no one is actually using it. Signed-off-by: Andrii Nakryiko --- include/linux/uprobes.h | 10 +- kernel/events/uprobes.c | 18 +++--- kernel/trace/bpf_trace.c

[PATCH v4 4/8] uprobes: travers uprobe's consumer list locklessly under SRCU protection

2024-08-29 Thread Andrii Nakryiko
s extra lock won't hurt performance, overall, but we also avoid the need for any extra protection (e.g., seqcount locks). Signed-off-by: Andrii Nakryiko --- include/linux/uprobes.h | 2 +- kernel/events/uprobes.c | 104 +++- 2 files changed, 62 insertions(+), 4

[PATCH v4 5/8] perf/uprobe: split uprobe_unregister()

2024-08-29 Thread Andrii Nakryiko
r Zijlstra (Intel) Co-developed-by: Andrii Nakryiko Signed-off-by: Andrii Nakryiko --- include/linux/uprobes.h | 8 +-- kernel/events/uprobes.c | 21 +-- kernel/trace/bpf_trace.c | 5 - kernel/trace/trac

[PATCH v4 6/8] rbtree: provide rb_find_rcu() / rb_find_add_rcu()

2024-08-29 Thread Andrii Nakryiko
From: Peter Zijlstra Much like latch_tree, add two RCU methods for the regular RB-tree, which can be used in conjunction with a seqcount to provide lockless lookups. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Masami Hiramatsu (Google) --- include/linux/rbtree.h | 67 ++

[PATCH v4 7/8] uprobes: perform lockless SRCU-protected uprobes_tree lookup

2024-08-29 Thread Andrii Nakryiko
:3.723 ± 0.002M/s ( 0.058M/s/cpu) Peak througput increased from 3.7 mln/s (uprobe triggerings) up to about 8 mln/s. For uretprobes it's a bit more modest with bump from 2.4 mln/s to 5mln/s. Suggested-by: Peter Zijlstra (Intel) Signed-off-by: Andrii Nakryiko --- kernel/events

[PATCH v4 8/8] uprobes: switch to RCU Tasks Trace flavor for better performance

2024-08-29 Thread Andrii Nakryiko
do on uretprobes side. Even single-thread (no contention) performance is slightly better: 3.276 mln/s to 3.396 mln/s (+3.5%) for uprobes, and 2.055 mln/s to 2.174 mln/s (+5.8%) for uretprobes. Signed-off-by: Andrii Nakryiko --- kernel/events/uprobes.c | 37 +++-- 1

Re: [PATCH] arm64: insn: Simulate nop and push instruction for better uprobe performance

2024-08-29 Thread Andrii Nakryiko
On Tue, Aug 27, 2024 at 4:34 AM Liao, Chang wrote: > > Hi, Mark > > Would you like to discuss this patch further, or do you still believe > emulating > STP to push FP/LR into the stack in kernel is not a good idea? > Please send an updated version of your patches taking into account various smal

Re: [PATCH v4 4/8] uprobes: travers uprobe's consumer list locklessly under SRCU protection

2024-08-29 Thread Andrii Nakryiko
On Thu, Aug 29, 2024 at 4:10 PM Jiri Olsa wrote: > > On Thu, Aug 29, 2024 at 11:37:37AM -0700, Andrii Nakryiko wrote: > > uprobe->register_rwsem is one of a few big bottlenecks to scalability of > > uprobes, so we need to get rid of it to improve uprobe performance and >

Re: [PATCH v4 4/8] uprobes: travers uprobe's consumer list locklessly under SRCU protection

2024-08-30 Thread Andrii Nakryiko
On Fri, Aug 30, 2024 at 7:33 AM Oleg Nesterov wrote: > > On 08/30, Jiri Olsa wrote: > > > > with this change the probe will not get removed in the attached test, > > it'll get 2 hits, without this change just 1 hit > > I don't understand the code in tools/...bpf../ at all, can't comment, > > > but

Re: [PATCH v4 8/8] uprobes: switch to RCU Tasks Trace flavor for better performance

2024-08-30 Thread Andrii Nakryiko
gt; > url: > https://github.com/intel-lab-lkp/linux/commits/Andrii-Nakryiko/uprobes-revamp-uprobe-refcounting-and-lifetime-management/20240830-024135 > base: tip/perf/core > patch link: > https://lore.kernel.org/r/20240829183741.3331213-9-andrii%40kernel.org > patch su

Re: [PATCH v4 4/8] uprobes: travers uprobe's consumer list locklessly under SRCU protection

2024-08-30 Thread Andrii Nakryiko
On Fri, Aug 30, 2024 at 1:21 PM Oleg Nesterov wrote: > > On 08/30, Andrii Nakryiko wrote: > > > > Andrii, let me reply to your email "out of order". First of all: > > > Can we please let me land these patches first? It's been a while. I > > don&

Re: [PATCH bpf-next 2/2] selftests/bpf: Add uprobe pid filter test for multiple processes

2024-08-30 Thread Andrii Nakryiko
On Thu, Aug 29, 2024 at 12:45 PM Jiri Olsa wrote: > > The idea is to create and monitor 3 uprobes, each trigered in separate typo: triggered > process and make sure the bpf program gets executed just for the proper > PID specified via pid filter. > > Signed-off-by: Jiri Olsa > --- > .../bpf/pr

Re: [PATCH rcu 0/11] Add light-weight readers for SRCU

2024-09-03 Thread Andrii Nakryiko
On Tue, Sep 3, 2024 at 9:32 AM Paul E. McKenney wrote: > > Hello! > > This series provides light-weight readers for SRCU. This lightness > is selected by the caller by using the new srcu_read_lock_lite() and > srcu_read_unlock_lite() flavors instead of the usual srcu_read_lock() and > srcu_read_u

Re: [PATCH bpf-next v2 0/2] selftests/bpf: Enable vmtest for cross-compile arm64 on x86_64 host, and fix some issues.

2024-09-05 Thread Andrii Nakryiko
On Wed, Aug 28, 2024 at 5:17 AM Lin Yikai wrote: > > These two patch enable the use of "vmtest.sh" for cross-compile arm64 on > x86_64 host. > This is essential for utilizing BPF on Android (arm64), > as the compilation server is running on Ubuntu (x86). > > Following previous guidance from V1, t

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-10 Thread Andrii Nakryiko
On Tue, Sep 10, 2024 at 11:36 AM Alexei Starovoitov wrote: > > On Mon, Sep 9, 2024 at 5:55 PM Daniel Xu wrote: > > > > Right now there exists prog produce / userspace consume and userspace > > produce / prog consume support. But it is also useful to have prog > > produce / prog consume. > > > > F

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-10 Thread Andrii Nakryiko
On Tue, Sep 10, 2024 at 2:07 PM Daniel Xu wrote: > > On Tue, Sep 10, 2024 at 01:41:41PM GMT, Andrii Nakryiko wrote: > > On Tue, Sep 10, 2024 at 11:36 AM Alexei Starovoitov > > wrote: > > > > > > On Mon, Sep 9, 2024 at 5:55 PM Daniel Xu wrote: > > >

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-10 Thread Andrii Nakryiko
On Tue, Sep 10, 2024 at 3:16 PM Daniel Xu wrote: > > > > On Tue, Sep 10, 2024, at 2:07 PM, Daniel Xu wrote: > > On Tue, Sep 10, 2024 at 01:41:41PM GMT, Andrii Nakryiko wrote: > >> On Tue, Sep 10, 2024 at 11:36 AM Alexei Starovoitov > [...] > > > >> >

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-10 Thread Andrii Nakryiko
On Tue, Sep 10, 2024 at 4:44 PM Daniel Xu wrote: > > On Tue, Sep 10, 2024 at 03:21:04PM GMT, Andrii Nakryiko wrote: > > On Tue, Sep 10, 2024 at 3:16 PM Daniel Xu wrote: > > > > > > > > > > > > On Tue, Sep 10, 2024, at 2:07 PM, Daniel Xu wrote

Re: [PATCH bpf-next] bpf: ringbuf: Support consuming BPF_MAP_TYPE_RINGBUF from prog

2024-09-11 Thread Andrii Nakryiko
On Tue, Sep 10, 2024 at 8:31 PM Daniel Xu wrote: > > On Tue, Sep 10, 2024 at 05:39:55PM GMT, Andrii Nakryiko wrote: > > On Tue, Sep 10, 2024 at 4:44 PM Daniel Xu wrote: > > > > > > On Tue, Sep 10, 2024 at 03:21:04PM GMT, Andrii Nakryiko wrote: > > > >

Re: [PATCH v3 bpf-next 11/11] bpf: Test BPF_SK_REUSEPORT_SELECT_OR_MIGRATE.

2021-04-20 Thread Andrii Nakryiko
On Tue, Apr 20, 2021 at 8:45 AM Kuniyuki Iwashima wrote: > > This patch adds a test for BPF_SK_REUSEPORT_SELECT_OR_MIGRATE and > removes 'static' from settimeo() in network_helpers.c. > > Signed-off-by: Kuniyuki Iwashima > --- Almost everything in prog_tests/migrate_reuseport.c should be static,

Re: [PATCH bpf-next v2 2/3] libbpf: selftests: refactor 'BPF_PERCPU_TYPE()' and 'bpf_percpu()' macros

2021-04-07 Thread Andrii Nakryiko
On Tue, Apr 6, 2021 at 11:55 AM Pedro Tammela wrote: > > This macro was refactored out of the bpf selftests. > > Since percpu values are rounded up to '8' in the kernel, a careless > user in userspace might encounter unexpected values when parsing the > output of the batched operations. I wonder

Re: [syzbot] memory leak in bpf (2)

2021-04-07 Thread Andrii Nakryiko
On Wed, Mar 31, 2021 at 6:08 PM syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit:0f4498ce Merge tag 'for-5.12/dm-fixes-2' of git://git.kern.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=1250e126d0 > kernel config:

Re: [PATCH bpf-next v2 2/3] libbpf: selftests: refactor 'BPF_PERCPU_TYPE()' and 'bpf_percpu()' macros

2021-04-07 Thread Andrii Nakryiko
On Wed, Apr 7, 2021 at 12:30 PM Pedro Tammela wrote: > > Em qua., 7 de abr. de 2021 às 15:31, Andrii Nakryiko > escreveu: > > > > On Tue, Apr 6, 2021 at 11:55 AM Pedro Tammela wrote: > > > > > > This macro was refactored out of the bpf selftests. > &g

Re: [PATCH bpf-next] libbpf: clarify flags in ringbuf helpers

2021-04-07 Thread Andrii Nakryiko
On Wed, Apr 7, 2021 at 11:43 AM Joe Stringer wrote: > > Hi Pedro, > > On Tue, Apr 6, 2021 at 11:58 AM Pedro Tammela wrote: > > > > In 'bpf_ringbuf_reserve()' we require the flag to '0' at the moment. > > > > For 'bpf_ringbuf_{discard,submit,output}' a flag of '0' might send a > > notification to

Re: [PATCH bpf-next] libbpf: clarify flags in ringbuf helpers

2021-04-07 Thread Andrii Nakryiko
On Wed, Apr 7, 2021 at 1:10 PM Pedro Tammela wrote: > > Em qua., 7 de abr. de 2021 às 16:58, Andrii Nakryiko > escreveu: > > > > On Wed, Apr 7, 2021 at 11:43 AM Joe Stringer wrote: > > > > > > Hi Pedro, > > > > > > On Tue, Apr 6,

Re: [PATCH bpf-next v2 1/6] bpf: Factorize bpf_trace_printk and bpf_seq_printf

2021-04-07 Thread Andrii Nakryiko
On Tue, Apr 6, 2021 at 8:35 AM Florent Revest wrote: > > [Sorry for the late replies, I'm just back from a long easter break :)] > > On Fri, Mar 26, 2021 at 11:51 PM Andrii Nakryiko > wrote: > > On Fri, Mar 26, 2021 at 2:53 PM Andrii Nakryiko > > wrote: >

Re: [PATCH bpf-next v2 3/6] bpf: Add a bpf_snprintf helper

2021-04-07 Thread Andrii Nakryiko
On Tue, Apr 6, 2021 at 9:06 AM Florent Revest wrote: > > On Fri, Mar 26, 2021 at 11:55 PM Andrii Nakryiko > wrote: > > On Tue, Mar 23, 2021 at 7:23 PM Florent Revest wrote: > > > The implementation takes inspiration from the existing bpf_trace_printk > > > helpe

Re: memory leak in bpf

2021-04-07 Thread Andrii Nakryiko
On Wed, Apr 7, 2021 at 4:24 PM Rustam Kovhaev wrote: > > On Mon, Mar 01, 2021 at 09:43:00PM +0100, Dmitry Vyukov wrote: > > On Mon, Mar 1, 2021 at 9:39 PM Rustam Kovhaev wrote: > > > > > > On Mon, Mar 01, 2021 at 08:05:42PM +0100, Dmitry Vyukov wrote: > > > > On Mon, Mar 1, 2021 at 5:21 PM Rustam

Re: [PATCH 03/44] perf augmented_raw_syscalls: Use a PERCPU_ARRAY map to copy more string bytes

2019-04-02 Thread Andrii Nakryiko
4168, cachelines: 66, members: 2 */ > /* last cacheline: 8 bytes */ > }; > # > > Then looking if PATH_MAX leaves some signature in the tests: > >│if (augmented_args->filename.size < > sizeof(augmented_args->filename.value)) {

Re: [PATCH] libbpf: Remove unnecessary conversion to bool

2021-02-22 Thread Andrii Nakryiko
On Sat, Feb 20, 2021 at 1:11 AM Jiapeng Chong wrote: > > Fix the following coccicheck warnings: > > ./tools/lib/bpf/libbpf.c:1487:43-48: WARNING: conversion to bool not > needed here. > > Reported-by: Abaci Robot > Signed-off-by: Jiapeng Chong > --- I think this came up before already. I did th

Re: [PATCH v4 bpf-next 2/6] bpf: prevent deadlock from recursive bpf_task_storage_[get|delete]

2021-02-22 Thread Andrii Nakryiko
On Mon, Feb 22, 2021 at 5:23 PM Song Liu wrote: > > BPF helpers bpf_task_storage_[get|delete] could hold two locks: > bpf_local_storage_map_bucket->lock and bpf_local_storage->lock. Calling > these helpers from fentry/fexit programs on functions in bpf_*_storage.c > may cause deadlock on either lo

Re: [PATCH v4 bpf-next 5/6] bpf: runqslower: prefer using local vmlimux to generate vmlinux.h

2021-02-22 Thread Andrii Nakryiko
On Mon, Feb 22, 2021 at 5:24 PM Song Liu wrote: > > Update the Makefile to prefer using $(O)/mvlinux, $(KBUILD_OUTPUT)/vmlinux > (for selftests) or ../../../vmlinux. These two files should have latest > definitions for vmlinux.h. > > Signed-off-by: Song Liu > --- Acke

Re: [PATCH v4 bpf-next 2/6] bpf: prevent deadlock from recursive bpf_task_storage_[get|delete]

2021-02-22 Thread Andrii Nakryiko
On Mon, Feb 22, 2021 at 11:16 PM Song Liu wrote: > > > > > On Feb 22, 2021, at 10:21 PM, Andrii Nakryiko > > wrote: > > > > On Mon, Feb 22, 2021 at 5:23 PM Song Liu wrote: > >> > >> BPF helpers bpf_task_storage_[get|delete] could hold two

Re: [PATCH bpf-next v7 2/5] bpf: Expose bpf_get_socket_cookie to tracing programs

2021-02-10 Thread Andrii Nakryiko
; --- It's customary to send cover letter with patch sets of 2 or more related patches. It's a good place to explain the motivation of a patch set. And a good place to ack all patches in one go ;) Acked-by: Andrii Nakryiko > include/linux/bpf.h| 1 + > include/u

Re: [PATCH] bpf_lru_list: Read double-checked variable once without lock

2021-02-10 Thread Andrii Nakryiko
On Tue, Feb 9, 2021 at 10:00 PM Martin KaFai Lau wrote: > > On Tue, Feb 09, 2021 at 12:27:01PM +0100, Marco Elver wrote: > > For double-checked locking in bpf_common_lru_push_free(), node->type is > > read outside the critical section and then re-checked under the lock. > > However, concurrent wri

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

2021-02-03 Thread Andrii Nakryiko
On Wed, Feb 3, 2021 at 5:31 PM Nick Desaulniers wrote: > > On Sun, Jan 17, 2021 at 12:14 PM Arnaldo Carvalho de Melo > wrote: > > > > Em Fri, Jan 15, 2021 at 03:43:06PM -0800, Yonghong Song escreveu: > > > > > > > > > On 1/15/21 3:34 PM, Nick Desaulniers wrote: > > > > On Fri, Jan 15, 2021 at 3:2

Re: [PATCH bpf-next] samples/bpf: Add hello world sample for newbies

2021-02-04 Thread Andrii Nakryiko
On Thu, Feb 4, 2021 at 11:27 AM Song Liu wrote: > > On Thu, Feb 4, 2021 at 3:42 AM Tiezhu Yang wrote: > > > > The program is made in a way that everytime an execve syscall > > is executed it prints Hello, BPF World! > > > > This is inspired and based on the code example for the book > > Linux Obs

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

2021-02-04 Thread Andrii Nakryiko
On Wed, Feb 3, 2021 at 7:13 PM Nick Desaulniers wrote: > > On Wed, Feb 3, 2021 at 6:58 PM Andrii Nakryiko > wrote: > > > > On Wed, Feb 3, 2021 at 5:31 PM Nick Desaulniers > > wrote: > > > > > > On Sun, Jan 17, 2021 at 12:14 PM Arnaldo Carvalho de M

Re: ANNOUNCE: pahole v1.20 (gcc11 DWARF5's default, lots of ELF sections, BTF)

2021-02-04 Thread Andrii Nakryiko
On Thu, Feb 4, 2021 at 2:09 PM Arnaldo Carvalho de Melo wrote: > > Hi, > > The v1.20 release of pahole and its friends is out, mostly > addressing problems related to gcc 11 defaulting to DWARF5 for -g, > available at the usual places: Great, thanks, Arnaldo! Do you plan to build RPMs soo

Re: ANNOUNCE: pahole v1.20 (gcc11 DWARF5's default, lots of ELF sections, BTF)

2021-02-04 Thread Andrii Nakryiko
On Thu, Feb 4, 2021 at 8:34 PM Arnaldo Carvalho de Melo wrote: > > > > On February 4, 2021 9:01:51 PM GMT-03:00, Andrii Nakryiko > wrote: > >On Thu, Feb 4, 2021 at 2:09 PM Arnaldo Carvalho de Melo> > >wrote: > >> The v1.20 release o

Re: [PATCH] selftests: bpf: remove unneeded semicolon

2021-02-08 Thread Andrii Nakryiko
On Mon, Feb 8, 2021 at 2:30 AM Yang Li wrote: > > Eliminate the following coccicheck warning: > ./tools/testing/selftests/bpf/test_flow_dissector.c:506:2-3: Unneeded > semicolon > > Reported-by: Abaci Robot > Signed-off-by: Yang Li > --- Applied to bpf-next, changing subject to have more canoni

Re: [PATCH] selftests/bpf: Simplify the calculation of variables

2021-02-08 Thread Andrii Nakryiko
On Thu, Feb 4, 2021 at 10:27 PM Jiapeng Chong wrote: > > Fix the following coccicheck warnings: > > ./tools/testing/selftests/bpf/xdpxceiver.c:954:28-30: WARNING !A || A && > B is equivalent to !A || B. > > ./tools/testing/selftests/bpf/xdpxceiver.c:932:28-30: WARNING !A || A && > B is equivalent

Re: [PATCH bpf-next 4/4] bpf: Add selftests for local_storage

2020-06-01 Thread Andrii Nakryiko
On Tue, May 26, 2020 at 9:34 AM KP Singh wrote: > > From: KP Singh > > inode_local_storage: > > * Hook to the file_open and inode_unlink LSM hooks. > * Create and unlink a temporary file. > * Store some information in the inode's bpf_local_storage during > file_open. > * Verify that this inform

Re: UBSAN: array-index-out-of-bounds in kernel/bpf/arraymap.c:177

2020-05-18 Thread Andrii Nakryiko
On Sun, May 17, 2020 at 7:45 PM Qian Cai wrote: > > With Clang 9.0.1, > > return array->value + array->elem_size * (index & array->index_mask); > > but array->value is, > > char value[0] __aligned(8); This, and ptrs and pptrs, should be flexible arrays. But they are in a union, and unions don't s

Re: UBSAN: array-index-out-of-bounds in kernel/bpf/arraymap.c:177

2020-05-18 Thread Andrii Nakryiko
On Mon, May 18, 2020 at 5:09 PM Qian Cai wrote: > > On Mon, May 18, 2020 at 7:55 PM Andrii Nakryiko > wrote: > > > > On Sun, May 17, 2020 at 7:45 PM Qian Cai wrote: > > > > > > With Clang 9.0.1, > > > > > > return array->value + arr

Re: UBSAN: array-index-out-of-bounds in kernel/bpf/arraymap.c:177

2020-05-18 Thread Andrii Nakryiko
On Mon, May 18, 2020 at 6:00 PM Yonghong Song wrote: > > > > On 5/18/20 5:25 PM, Andrii Nakryiko wrote: > > On Mon, May 18, 2020 at 5:09 PM Qian Cai wrote: > >> > >> On Mon, May 18, 2020 at 7:55 PM Andrii Nakryiko > >> wrote: > >>&

Re: UBSAN: array-index-out-of-bounds in kernel/bpf/arraymap.c:177

2020-05-19 Thread Andrii Nakryiko
On Tue, May 19, 2020 at 8:00 AM Qian Cai wrote: > > On Mon, May 18, 2020 at 8:25 PM Andrii Nakryiko > wrote: > > > > On Mon, May 18, 2020 at 5:09 PM Qian Cai wrote: > > > > > > On Mon, May 18, 2020 at 7:55 PM Andrii Nakryiko > > > wrote: > >

Re: UBSAN: array-index-out-of-bounds in kernel/bpf/arraymap.c:177

2020-05-19 Thread Andrii Nakryiko
On Tue, May 19, 2020 at 1:18 PM Qian Cai wrote: > > On Tue, May 19, 2020 at 3:30 PM Andrii Nakryiko > wrote: > > > > On Tue, May 19, 2020 at 8:00 AM Qian Cai wrote: > > > > > > On Mon, May 18, 2020 at 8:25 PM Andrii Nakryiko > > > wrote: > >

Re: [PATCH bpf-next v2 29/35] bpf: libbpf: cleanup RLIMIT_MEMLOCK usage

2020-07-30 Thread Andrii Nakryiko
On Wed, Jul 29, 2020 at 6:38 PM Roman Gushchin wrote: > > On Mon, Jul 27, 2020 at 10:59:33PM -0700, Andrii Nakryiko wrote: > > On Mon, Jul 27, 2020 at 4:15 PM Roman Gushchin wrote: > > > > > > On Mon, Jul 27, 2020 at 03:05:11PM -0700, Andrii Nakryiko wrote: > &g

Re: [PATCH net-next] Extending bpf_setsockopt with SO_BINDTODEVICE sockopt

2020-05-21 Thread Andrii Nakryiko
On Thu, May 21, 2020 at 5:54 AM Ferenc Fejes wrote: > > This option makes possible to programatically bind sockets to netdevices. > With the help of this option sockets of VRF unaware applications > could be distributed between multiple VRFs with eBPF sock_ops program. > This let the applications

Re: [PATCH 13/23] bpf: rework the compat kernel probe handling

2020-05-21 Thread Andrii Nakryiko
; shared by the proper kernel and user probe helpers. This slightly > changes behavior as the compat probe on a user address doesn't check > the lockdown flags, just as the pure user probes do. > > Signed-off-by: Christoph Hellwig > --- Looks good, thanks. Acked-by: Andrii Nak

Re: [PATCH 11/23] bpf: factor out a bpf_trace_copy_string helper

2020-05-21 Thread Andrii Nakryiko
On Thu, May 21, 2020 at 8:25 AM Christoph Hellwig wrote: > > Split out a helper to do the fault free access to the string pointer > to get it out of a crazy indentation level. > > Signed-off-by: Christoph Hellwig > --- LGTM. Acked-by: Andrii Nakryiko > kernel/t

Re: [PATCH 12/23] bpf: handle the compat string in bpf_trace_copy_string better

2020-05-21 Thread Andrii Nakryiko
On Thu, May 21, 2020 at 8:24 AM Christoph Hellwig wrote: > > User the proper helper for kernel or userspace addresses based on > TASK_SIZE instead of the dangerous strncpy_from_unsafe function. > > Signed-off-by: Christoph Hellwig > --- Acked-by: Andrii Nakryiko > ker

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] bpf: fix compilation warning of selftests

2020-07-31 Thread Andrii Nakryiko
On Thu, Jul 30, 2020 at 11:18 PM Jianlin Lv wrote: > > Clang compiler version: 12.0.0 > The following warning appears during the selftests/bpf compilation: > > prog_tests/send_signal.c:51:3: warning: ignoring return value of ‘write’, > declared with attribute warn_unused_result [-Wunused-result] >

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 for >

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 > --- > .../selftests/b

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 other

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, i

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: [RFC PATCH bpf-next 3/4] bpf: add bpf_trace_btf helper

2020-08-19 Thread Andrii Nakryiko
On Thu, Aug 6, 2020 at 1:24 PM Alan Maguire wrote: > > A helper is added to support tracing kernel type information in BPF > using the BPF Type Format (BTF). Its signature is > > long bpf_trace_btf(struct btf_ptr *ptr, u32 btf_ptr_size, u32 trace_id, >u64 flags); > > struct bt

Re: unregister_netdevice: waiting for DEV to become free (4)

2020-08-20 Thread Andrii Nakryiko
On Wed, Aug 19, 2020 at 7:06 AM Dmitry Vyukov wrote: > > On Wed, Aug 19, 2020 at 3:54 PM syzbot > wrote: > > > > Hello, > > > > syzbot found the following issue on: > > > > HEAD commit:18445bf4 Merge tag 'spi-fix-v5.9-rc1' of git://git.kernel... > > git tree: upstream > > console output

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 percp

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 Liu

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

2020-08-06 Thread Andrii Nakryiko
On Fri, Jul 31, 2020 at 8:47 PM Andrii Nakryiko wrote: > > 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: > &g

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

2020-08-06 Thread Andrii Nakryiko
On Thu, Aug 6, 2020 at 12:42 PM Ian Rogers wrote: > > On Thu, Aug 6, 2020 at 10:58 AM Andrii Nakryiko > wrote: > > > > On Fri, Jul 31, 2020 at 8:47 PM Andrii Nakryiko > > wrote: > > > > > > On Fri, Jul 31, 2020 at 6:47 PM Ian Rogers wrote: >

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

2020-08-07 Thread Andrii Nakryiko
On Fri, Aug 7, 2020 at 10:21 AM Jianlin Lv wrote: > > test_progs reports the segmentation fault as below > > $ sudo ./test_progs -t mmap --verbose > test_mmap:PASS:skel_open_and_load 0 nsec > .. > test_mmap:PASS:adv_mmap1 0 nsec > test_mmap:PASS:adv_mmap2 0 nsec > test_mmap:PASS:adv_mmap3 0 ns

Re: [PATCH] Signed-off-by: giladreti

2021-01-11 Thread Andrii Nakryiko
On Mon, Jan 11, 2021 at 8:06 AM Gilad Reti wrote: > > On Mon, Jan 11, 2021, 17:55 Daniel Borkmann wrote: > > > > Hello Gilad, > > > > On 1/11/21 4:31 PM, giladreti wrote: > > > Added support for pointer to mem register spilling, to allow the verifier > > > to track pointer to valid memory address

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

2021-01-11 Thread Andrii Nakryiko
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 > > wrote: > > > > > > On Tue, Jan 12, 2021 at 04:19:01AM +0900, Masahiro Yamada wrote: > > > > On Tue, Jan 12, 2021

Re: [PATCH bpf-next 2/4] selftests/bpf: add non-BPF_LSM test for task local storage

2021-01-11 Thread Andrii Nakryiko
On Fri, Jan 8, 2021 at 3:30 PM Song Liu wrote: > > Task local storage is enabled for tracing programs. Add a test for it > without CONFIG_BPF_LSM. > > Signed-off-by: Song Liu > --- > .../bpf/prog_tests/test_task_local_storage.c | 34 + > .../selftests/bpf/progs/task_local_storag

Re: [PATCH bpf-next 4/4] bpf: runqslower: use task local storage

2021-01-11 Thread Andrii Nakryiko
On Mon, Jan 11, 2021 at 7:24 PM Yonghong Song wrote: > > > > On 1/11/21 2:54 PM, Song Liu wrote: > > > > > >> On Jan 11, 2021, at 9:49 AM, Yonghong Song wrote: > >> > >> > >> > >> On 1/8/21 3:19 PM, Song Liu wrote: > >>> Replace hashtab with task local storage in runqslower. This improves the > >

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

2021-01-11 Thread Andrii Nakryiko
On Mon, Jan 11, 2021 at 10:20 AM Qais Yousef wrote: > > Reuse module_attach infrastructure to add a new bare tracepoint to check > we can attach to it as a raw tracepoint. > > Signed-off-by: Qais Yousef > --- > > Andrii > > I was getting the error below when I was trying to run the test. > I had

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

2021-01-11 Thread Andrii Nakryiko
On Mon, Jan 11, 2021 at 9:34 AM Alan Maguire wrote: > > libbpf already supports a "dumper" API for dumping type information, > but there is currently no support for dumping typed _data_ via libbpf. > However this functionality does exist in the kernel, in part to > facilitate the bpf_snprintf_btf(

<    1   2   3   4   5   6   7   8   >