Re: [PATCH bpf-next v2 2/2] selftests/bpf: Add mptcp subflow subtest

2024-05-10 Thread Alexei Starovoitov
On Thu, May 9, 2024 at 11:31 AM Matthieu Baerts wrote: > > Hello, > > On 09/05/2024 17:49, Matthieu Baerts (NGI0) wrote: > > From: Geliang Tang > > > > This patch adds a subtest named test_subflow to load and verify the newly > > added mptcp subflow example in test_mptcp. Add a helper

Re: [PATCH bpf-next 3/4] selftests/bpf: Add mptcp subflow example

2024-05-08 Thread Alexei Starovoitov
On Wed, May 8, 2024 at 12:36 AM Matthieu Baerts wrote: > > > > > The concern with picking reno is extra deps to CI and every developer. > > Currently in selftests/bpf/config we do: > > CONFIG_TCP_CONG_DCTCP=y > > CONFIG_TCP_CONG_BBR=y > > > > I'd like to avoid adding reno there as well. > > Will

Re: [PATCH bpf-next 3/4] selftests/bpf: Add mptcp subflow example

2024-05-07 Thread Alexei Starovoitov
On Tue, May 7, 2024 at 9:03 AM Matthieu Baerts wrote: > > Hi Alexei, > > Thank you for the review! > > On 07/05/2024 16:49, Alexei Starovoitov wrote: > > On Tue, May 7, 2024 at 3:53 AM Matthieu Baerts (NGI0) > > wrote: > >> > >> From: Nicolas R

Re: [PATCH bpf-next 2/4] selftests/bpf: Add RUN_MPTCP_TEST macro

2024-05-07 Thread Alexei Starovoitov
On Tue, May 7, 2024 at 9:02 AM Matthieu Baerts wrote: > > Hi Alexei, > > Thank you for the review! > > On 07/05/2024 16:44, Alexei Starovoitov wrote: > > On Tue, May 7, 2024 at 3:53 AM Matthieu Baerts (NGI0) > > wrote: > >> > >> From:

Re: [PATCH bpf-next 3/4] selftests/bpf: Add mptcp subflow example

2024-05-07 Thread Alexei Starovoitov
On Tue, May 7, 2024 at 3:53 AM Matthieu Baerts (NGI0) wrote: > > From: Nicolas Rybowski > > Move Nicolas's patch into bpf selftests directory. This example added a > test that was adding a different mark (SO_MARK) on each subflow, and > changing the TCP CC only on the first subflow. > > This

Re: [PATCH bpf-next 2/4] selftests/bpf: Add RUN_MPTCP_TEST macro

2024-05-07 Thread Alexei Starovoitov
On Tue, May 7, 2024 at 3:53 AM Matthieu Baerts (NGI0) wrote: > > From: Geliang Tang > > Each MPTCP subtest tests test__start_subtest(suffix), then invokes > test_suffix(). It makes sense to add a new macro RUN_MPTCP_TEST to > simpolify the code. > > Signed-off-by: Geliang Tang > Reviewed-by:

Re: [PATCH bpf-next 1/4] selftests/bpf: Handle SIGINT when creating netns

2024-05-07 Thread Alexei Starovoitov
On Tue, May 7, 2024 at 3:53 AM Matthieu Baerts (NGI0) wrote: > > From: Geliang Tang > > It's necessary to delete netns during the MPTCP bpf tests interrupt, > otherwise the next tests run will fail due to unable to create netns. > > This patch adds a new SIGINT handle sig_int, and deletes

Re: [PATCH 2/3] bpf: do not walk twice the hash map on free

2024-04-25 Thread Alexei Starovoitov
On Thu, Apr 25, 2024 at 6:59 AM Benjamin Tissoires wrote: > > If someone stores both a timer and a workqueue in a hash map, on free, we > would walk it twice. > Add a check in htab_free_malloced_timers_or_wq and free the timers > and workqueues if they are present. > > Fixes: 246331e3f1ea ("bpf:

Re: [PATCH bpf-next v2 10/16] selftests/bpf: add bpf_wq tests

2024-04-24 Thread Alexei Starovoitov
On Tue, Apr 23, 2024 at 7:56 PM Alexei Starovoitov wrote: > > On Sat, Apr 20, 2024 at 2:10 AM Benjamin Tissoires wrote: > > > > + > > +SEC("tc") > > +/* test that workqueues can be used from an array > > + */ > > +__retval(0) > > +long t

Re: [PATCH bpf-next v2 11/16] bpf: wq: add bpf_wq_init

2024-04-24 Thread Alexei Starovoitov
On Wed, Apr 24, 2024 at 8:06 AM Alexei Starovoitov wrote: > > On Tue, Apr 23, 2024 at 7:55 PM Alexei Starovoitov > wrote: > > > > On Sat, Apr 20, 2024 at 2:10 AM Benjamin Tissoires > > wrote: > > > > > > We need to teach the verifier about the se

Re: [PATCH bpf-next v2 11/16] bpf: wq: add bpf_wq_init

2024-04-24 Thread Alexei Starovoitov
On Tue, Apr 23, 2024 at 7:55 PM Alexei Starovoitov wrote: > > On Sat, Apr 20, 2024 at 2:10 AM Benjamin Tissoires wrote: > > > > We need to teach the verifier about the second argument which is declared > > as void * but which is of type KF_ARG_PTR_TO_MAP. We could hav

Re: [PATCH bpf-next v2 10/16] selftests/bpf: add bpf_wq tests

2024-04-23 Thread Alexei Starovoitov
On Sat, Apr 20, 2024 at 2:10 AM Benjamin Tissoires wrote: > > + > +SEC("tc") > +/* test that workqueues can be used from an array > + */ > +__retval(0) > +long test_call_array_sleepable(void *ctx) > +{ > + int key = 0; > + > + return test_elem_callback(, ); > +} > + > +SEC("syscall")

Re: [PATCH bpf-next v2 13/16] bpf: wq: add bpf_wq_set_callback_impl

2024-04-23 Thread Alexei Starovoitov
On Sat, Apr 20, 2024 at 2:10 AM Benjamin Tissoires wrote: > @@ -11018,6 +11027,7 @@ enum special_kfunc_type { > KF_bpf_percpu_obj_drop_impl, > KF_bpf_throw, > KF_bpf_iter_css_task_new, > + KF_bpf_wq_set_callback_impl, > }; > > BTF_SET_START(special_kfunc_set) > @@

Re: [PATCH bpf-next v2 11/16] bpf: wq: add bpf_wq_init

2024-04-23 Thread Alexei Starovoitov
On Sat, Apr 20, 2024 at 2:10 AM Benjamin Tissoires wrote: > > We need to teach the verifier about the second argument which is declared > as void * but which is of type KF_ARG_PTR_TO_MAP. We could have dropped > this extra case if we declared the second argument as struct bpf_map *, > but that

Re: [PATCH bpf-next v2 09/16] bpf: allow struct bpf_wq to be embedded in arraymaps and hashmaps

2024-04-23 Thread Alexei Starovoitov
On Sat, Apr 20, 2024 at 2:09 AM Benjamin Tissoires wrote: > > > -static void htab_map_free_timers(struct bpf_map *map) > +static void htab_map_free_timers_and_wq(struct bpf_map *map) > { > struct bpf_htab *htab = container_of(map, struct bpf_htab, map); > > - /* We only free timer

Re: [PATCH bpf-next 17/18] bpf: add bpf_wq_start

2024-04-19 Thread Alexei Starovoitov
On Fri, Apr 19, 2024 at 8:14 AM Benjamin Tissoires wrote: > > > Honestly I just felt the patch series was big enough for a PoC and > comparison with sleepable bpf_timer. But if we think this needs not to > be added, I guess that works too :) It certainly did its job to compare the two and imo

Re: [PATCH bpf-next 11/18] bpf: wq: add bpf_wq_init

2024-04-19 Thread Alexei Starovoitov
On Fri, Apr 19, 2024 at 8:12 AM Benjamin Tissoires wrote: > > > It's something I added while adding the tests. And some tests were passing > in case I was having a non sleepable callback. But if we have > bpf_rcu_read_lock(), we are all fine and can reduce the complexity. Not quite following

Re: [PATCH bpf-next 17/18] bpf: add bpf_wq_start

2024-04-19 Thread Alexei Starovoitov
On Tue, Apr 16, 2024 at 04:08:30PM +0200, Benjamin Tissoires wrote: > again, copy/paste from bpf_timer_start(). > > Signed-off-by: Benjamin Tissoires > --- > kernel/bpf/helpers.c | 24 > 1 file changed, 24 insertions(+) > > diff --git a/kernel/bpf/helpers.c

Re: [PATCH bpf-next 09/18] bpf: allow struct bpf_wq to be embedded in arraymaps and hashmaps

2024-04-19 Thread Alexei Starovoitov
On Tue, Apr 16, 2024 at 04:08:22PM +0200, Benjamin Tissoires wrote: > WRITE_ONCE(*(u64 *)field_ptr, 0); > @@ -1119,6 +1127,8 @@ static int map_check_btf(struct bpf_map *map, struct > bpf_token *token, > } > break; >

Re: [PATCH bpf-next 06/18] bpf: add support for bpf_wq user type

2024-04-19 Thread Alexei Starovoitov
On Tue, Apr 16, 2024 at 04:08:19PM +0200, Benjamin Tissoires wrote: > Mostly a copy/paste from the bpf_timer API, without the initialization > and free, as they will be done in a separate patch. > > Signed-off-by: Benjamin Tissoires Patches 2-6 look good.

Re: [PATCH bpf-next 08/18] bpf: add support for KF_ARG_PTR_TO_WORKQUEUE

2024-04-19 Thread Alexei Starovoitov
On Tue, Apr 16, 2024 at 04:08:21PM +0200, Benjamin Tissoires wrote: > Introduce support for KF_ARG_PTR_TO_WORKQUEUE. The kfuncs will use bpf_wq > as argument and that will be recognized as workqueue argument by verifier. > bpf_wq_kern casting can happen inside kfunc, but using bpf_wq in > argument

Re: [PATCH bpf-next 11/18] bpf: wq: add bpf_wq_init

2024-04-18 Thread Alexei Starovoitov
On Tue, Apr 16, 2024 at 04:08:24PM +0200, Benjamin Tissoires wrote: > We need to teach the verifier about the second argument which is declared > as void * but which is of type KF_ARG_PTR_TO_MAP. We could have dropped > this extra case if we declared the second argument as struct bpf_map *, > but

Re: [PATCH net-next 3/4] selftests: net: declare section names for bpf_offload

2024-04-09 Thread Alexei Starovoitov
s/testing/selftests/net/sample_map_ret0.bpf.c > @@ -17,7 +17,7 @@ struct { > } array SEC(".maps"); > > /* Sample program which should always load for testing control paths. */ > -SEC(".text") int func() > +SEC("xdp") int func() It bitrotted so much.. ouch. For the series: Acked-by: Alexei Starovoitov

Re: [PATCH RFC bpf-next v6 0/6] sleepable bpf_timer (was: allow HID-BPF to do device IOs)

2024-04-08 Thread Alexei Starovoitov
On Mon, Apr 8, 2024 at 1:09 AM Benjamin Tissoires wrote: > > New version of the sleepable bpf_timer code. > > I'm posting this as this is the result of the previous review, so we can > have a baseline to compare to. > > The plan is now to introduce a new user API struct bpf_wq, as the timer > API

Re: [PATCH RFC bpf-next v6 6/6] selftests/bpf: add sleepable timer tests

2024-04-08 Thread Alexei Starovoitov
On Mon, Apr 8, 2024 at 4:01 PM Eduard Zingerman wrote: > > > +SEC("tc") > > +/* check that calling bpf_timer_start() with a delay on a sleepable > > + * callback is returning -EINVAL > > + */ > > +__retval(-22) > > +long test_call_sleepable_delay(void *ctx) > > +{ > > + int key = 2; > > +

Re: [PATCH RFC bpf-next v6 5/6] tools: sync include/uapi/linux/bpf.h

2024-04-08 Thread Alexei Starovoitov
On Mon, Apr 8, 2024 at 1:10 AM Benjamin Tissoires wrote: > > cp include/uapi/linux/bpf.h tools/include/uapi/linux/bpf.h > > Signed-off-by: Benjamin Tissoires > > --- > > updated in v6 > > no changes in v5 > > new in v4 > --- > tools/include/uapi/linux/bpf.h | 20 +--- > 1 file

Re: [PATCH RFC bpf-next v6 4/6] bpf/helpers: mark the callback of bpf_timer_set_sleepable_cb() as sleepable

2024-04-08 Thread Alexei Starovoitov
On Mon, Apr 8, 2024 at 3:36 PM Eduard Zingerman wrote: > > On Mon, 2024-04-08 at 10:09 +0200, Benjamin Tissoires wrote: > > Now that we have bpf_timer_set_sleepable_cb() available and working, we > > can tag the attached callback as sleepable, and let the verifier check > > in the correct context

Re: [PATCH RFC bpf-next v6 1/6] bpf/helpers: introduce sleepable bpf_timers

2024-04-08 Thread Alexei Starovoitov
On Mon, Apr 8, 2024 at 10:20 AM Benjamin Tissoires wrote: > > On Mon, Apr 8, 2024 at 7:08 PM Eduard Zingerman wrote: > > > > On Mon, 2024-04-08 at 10:09 +0200, Benjamin Tissoires wrote: > > > > [...] > > > > > diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c > > > index

Re: [PATCH bpf-next v5 1/6] bpf/helpers: introduce sleepable bpf_timers

2024-04-05 Thread Alexei Starovoitov
On Fri, Apr 5, 2024 at 8:46 AM Benjamin Tissoires wrote: > > Alright, as of today (and I'm about to be AFK for the weekend), I got > your changes in and working (I think). I'll review the series on > Monday and send it back so we have a baseline to compare it to with > bpf_wq. Nice! Looking

Re: [PATCH bpf-next v5 1/6] bpf/helpers: introduce sleepable bpf_timers

2024-04-04 Thread Alexei Starovoitov
On Thu, Apr 4, 2024 at 10:56 AM Benjamin Tissoires wrote: > > On Thu, Apr 4, 2024 at 6:41 PM Alexei Starovoitov > wrote: > > > > On Thu, Apr 4, 2024 at 8:27 AM Benjamin Tissoires > > wrote: > > > > > > > > > > > > &g

Re: [PATCH bpf-next v5 1/6] bpf/helpers: introduce sleepable bpf_timers

2024-04-04 Thread Alexei Starovoitov
On Thu, Apr 4, 2024 at 8:27 AM Benjamin Tissoires wrote: > > > > > > So we need something like: > > > > struct bpf_hrtimer { > > union { > > struct hrtimer timer; > > + struct work_struct work; > > }; > > struct bpf_map *map; > > struct bpf_prog *prog; > > void __rcu *callback_fn;

Re: [PATCH bpf-next v5 1/6] bpf/helpers: introduce sleepable bpf_timers

2024-04-03 Thread Alexei Starovoitov
On Wed, Apr 3, 2024 at 6:01 PM Alexei Starovoitov wrote: > > On Wed, Apr 3, 2024 at 11:50 AM Alexei Starovoitov > wrote: > > > > On Wed, Mar 27, 2024 at 10:02 AM Benjamin Tissoires > > wrote: > > > > > goto out; > > > > &

Re: [PATCH bpf-next v5 1/6] bpf/helpers: introduce sleepable bpf_timers

2024-04-03 Thread Alexei Starovoitov
On Wed, Apr 3, 2024 at 11:50 AM Alexei Starovoitov wrote: > > On Wed, Mar 27, 2024 at 10:02 AM Benjamin Tissoires > wrote: > > > > goto out; > > > > } > > > > + spin_lock(>sleepable_lock); > > > &

Re: [PATCH bpf-next v5 1/6] bpf/helpers: introduce sleepable bpf_timers

2024-04-03 Thread Alexei Starovoitov
On Wed, Mar 27, 2024 at 10:02 AM Benjamin Tissoires wrote: > > > goto out; > > > } > > > + spin_lock(>sleepable_lock); > > > drop_prog_refcnt(t); > > > + spin_unlock(>sleepable_lock); > > > > this also looks odd. > > I basically need to protect "t->prog

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-29 Thread Alexei Starovoitov
On Fri, Mar 29, 2024 at 2:39 PM Tejun Heo wrote: > > Hello, > > On Fri, Mar 29, 2024 at 02:22:28PM +0100, Djalal Harouni wrote: > > It would be easy at least for me if I just start with cgroupv2 and > > ensure that it has same available filenames as if we go through kernfs. > > Not a root cgroup

Re: [External] Re: [PATCH bpf-next v2 1/9] bpf: tracing: add support to record and check the accessed args

2024-03-28 Thread Alexei Starovoitov
On Thu, Mar 28, 2024 at 8:10 AM Steven Rostedt wrote: > > On Thu, 28 Mar 2024 22:43:46 +0800 > 梦龙董 wrote: > > > I have done a simple benchmark on creating 1000 > > trampolines. It is slow, quite slow, which consume up to > > 60s. We can't do it this way. > > > > Now, I have a bad idea. How about

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Alexei Starovoitov
On Thu, Mar 28, 2024 at 2:01 PM Tejun Heo wrote: > > Hello, > > On Thu, Mar 28, 2024 at 01:45:56PM -0700, Alexei Starovoitov wrote: > > On Thu, Mar 28, 2024 at 1:02 PM Tejun Heo wrote: > > > > > > There's also cgroup.kill which would be useful for simila

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Alexei Starovoitov
On Thu, Mar 28, 2024 at 1:02 PM Tejun Heo wrote: > > There's also cgroup.kill which would be useful for similar use cases. We can > add interface for both but idk. Let's say we have something like the > following (pardon the bad naming): > > bpf_cgroup_knob_write(struct cgroup *cgrp, char

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Alexei Starovoitov
On Thu, Mar 28, 2024 at 10:58 AM Tejun Heo wrote: > > Hello, Alexei. > > On Thu, Mar 28, 2024 at 10:32:24AM -0700, Alexei Starovoitov wrote: > > > It bothers me a bit that it's adding a dedicated interface for something > > > which already has a defined userspace

Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf

2024-03-28 Thread Alexei Starovoitov
On Thu, Mar 28, 2024 at 10:22 AM Tejun Heo wrote: > > Hello, Djalal. > > On Wed, Mar 27, 2024 at 11:53:22PM +0100, Djalal Harouni wrote: > > This patch series adds support to freeze the task cgroup hierarchy > > that is on a default cgroup v2 without going through kernfs interface. > > > > For

Re: [PATCH bpf-next v5 1/6] bpf/helpers: introduce sleepable bpf_timers

2024-03-25 Thread Alexei Starovoitov
On Fri, Mar 22, 2024 at 7:56 AM Benjamin Tissoires wrote: > > They are implemented as a workqueue, which means that there are no > guarantees of timing nor ordering. > > Signed-off-by: Benjamin Tissoires > > --- > > no changes in v5 > > changes in v4: > - dropped __bpf_timer_compute_key() > -

Re: [PATCH bpf-next v5 2/6] bpf/verifier: add bpf_timer as a kfunc capable type

2024-03-24 Thread Alexei Starovoitov
On Sat, Mar 23, 2024 at 9:57 PM Kumar Kartikeya Dwivedi wrote: > > > > > > > > Observation is correct. The patch is buggy, > > > > but the suggestion to follow process_dynptr_func() will lead > > > > to unnecessary complexity. > > > > dynptr-s are on stack with plenty of extra checks. > > > > >

Re: [PATCH bpf-next v5 2/6] bpf/verifier: add bpf_timer as a kfunc capable type

2024-03-23 Thread Alexei Starovoitov
On Sat, Mar 23, 2024 at 9:01 PM Kumar Kartikeya Dwivedi wrote: > > On Sun, 24 Mar 2024 at 04:53, Alexei Starovoitov > wrote: > > > > On Fri, Mar 22, 2024 at 9:31 AM Kumar Kartikeya Dwivedi > > wrote: > > > > > > On Fri, 22 Mar 2024 at 15:57, Benjami

Re: [PATCH bpf-next v5 2/6] bpf/verifier: add bpf_timer as a kfunc capable type

2024-03-23 Thread Alexei Starovoitov
On Fri, Mar 22, 2024 at 9:31 AM Kumar Kartikeya Dwivedi wrote: > > On Fri, 22 Mar 2024 at 15:57, Benjamin Tissoires wrote: > > > > We need to extend the bpf_timer API, but the way forward relies on kfuncs. > > So make bpf_timer known for kfuncs from the verifier PoV > > > > Signed-off-by:

Re: [PATCH V3 bpf-next 1/2] bpf: add bpf_task_get_cgroup kfunc

2024-03-20 Thread Alexei Starovoitov
On Wed, Mar 20, 2024 at 7:41 AM Tejun Heo wrote: > > On Mon, Mar 18, 2024 at 11:03:01PM -0600, Jose Fernandez wrote: > > This patch enhances the BPF helpers by adding a kfunc to retrieve the > > cgroup v2 of a task, addressing a previous limitation where only > > bpf_task_get_cgroup1 was

Re: [PATCH V3 bpf-next 1/2] bpf: add bpf_task_get_cgroup kfunc

2024-03-20 Thread Alexei Starovoitov
On Mon, Mar 18, 2024 at 10:04 PM Jose Fernandez wrote: > > This patch enhances the BPF helpers by adding a kfunc to retrieve the > cgroup v2 of a task, addressing a previous limitation where only > bpf_task_get_cgroup1 was available for cgroup v1. The new kfunc is > particularly useful for

Re: [PATCH V2 bpf-next 2/2] selftests/bpf: add selftest for bpf_task_get_cgroup

2024-03-17 Thread Alexei Starovoitov
On Sun, Mar 17, 2024 at 8:10 PM Ratheesh Kannoth wrote: > > On 2024-03-16 at 21:52:41, Jose Fernandez (jo...@netflix.com) wrote: > > This patch adds a selftest for the `bpf_task_get_cgroup` kfunc. The test > > focuses on the use case of obtaining the cgroup ID of the previous task > > in a

Re: [External] Re: [PATCH bpf-next v2 1/9] bpf: tracing: add support to record and check the accessed args

2024-03-13 Thread Alexei Starovoitov
On Tue, Mar 12, 2024 at 6:53 PM 梦龙董 wrote: > > On Wed, Mar 13, 2024 at 12:42 AM Alexei Starovoitov > wrote: > > > > On Mon, Mar 11, 2024 at 7:42 PM 梦龙董 wrote: > > > > [..] > > > > I see. > > I thought you're sharing the trampoline

Re: [External] Re: [PATCH bpf-next v2 1/9] bpf: tracing: add support to record and check the accessed args

2024-03-12 Thread Alexei Starovoitov
On Mon, Mar 11, 2024 at 7:42 PM 梦龙董 wrote: > > On Tue, Mar 12, 2024 at 10:09 AM Alexei Starovoitov > wrote: > > > > On Mon, Mar 11, 2024 at 7:01 PM 梦龙董 wrote: > > > > > > On Tue, Mar 12, 2024 at 9:46 AM Alexei Starovoitov > > > wrote: > >

Re: [External] Re: [PATCH bpf-next v2 8/9] libbpf: add support for the multi-link of tracing

2024-03-12 Thread Alexei Starovoitov
On Mon, Mar 11, 2024 at 7:44 PM 梦龙董 wrote: > > On Tue, Mar 12, 2024 at 9:56 AM Alexei Starovoitov > wrote: > > > > On Mon, Mar 11, 2024 at 2:35 AM Menglong Dong > > wrote: > > > > > > > > > - err = libbpf_find_att

Re: [External] Re: [PATCH bpf-next v2 7/9] libbpf: don't free btf if program of multi-link tracing existing

2024-03-11 Thread Alexei Starovoitov
On Mon, Mar 11, 2024 at 7:05 PM 梦龙董 wrote: > > > > > > > +LIBBPF_API void bpf_object__free_btfs(struct bpf_object *obj); > > > + > > > > It shouldn't be exported. > > libbpf should clean it up when bpf_object is freed. > > Yes, libbpf will clean up the btfs when bpf_object is freed in > this

Re: [External] Re: [PATCH bpf-next v2 1/9] bpf: tracing: add support to record and check the accessed args

2024-03-11 Thread Alexei Starovoitov
On Mon, Mar 11, 2024 at 7:01 PM 梦龙董 wrote: > > On Tue, Mar 12, 2024 at 9:46 AM Alexei Starovoitov > wrote: > > > > On Mon, Mar 11, 2024 at 2:34 AM Menglong Dong > > wrote: > > > > > > In this commit, we add the 'accessed_args' field to struc

Re: [PATCH bpf-next v2 8/9] libbpf: add support for the multi-link of tracing

2024-03-11 Thread Alexei Starovoitov
On Mon, Mar 11, 2024 at 2:35 AM Menglong Dong wrote: > > > - err = libbpf_find_attach_btf_id(prog, attach_name, > _obj_fd, _type_id); > + name_end = strchr(attach_name, ','); > + /* for multi-link tracing, use the first target symbol during > +

Re: [PATCH bpf-next v2 7/9] libbpf: don't free btf if program of multi-link tracing existing

2024-03-11 Thread Alexei Starovoitov
On Mon, Mar 11, 2024 at 2:35 AM Menglong Dong wrote: > > By default, the kernel btf that we load during loading program will be > freed after the programs are loaded in bpf_object_load(). However, we > still need to use these btf for tracing of multi-link during attaching. > Therefore, we don't

Re: [PATCH bpf-next v2 5/9] bpf: verifier: add btf to the function args of bpf_check_attach_target

2024-03-11 Thread Alexei Starovoitov
On Mon, Mar 11, 2024 at 2:35 AM Menglong Dong wrote: > > Add target btf to the function args of bpf_check_attach_target(), then > the caller can specify the btf to check. > > Signed-off-by: Menglong Dong > --- > include/linux/bpf_verifier.h | 1 + > kernel/bpf/syscall.c | 6 -- >

Re: [PATCH bpf-next v2 2/9] bpf: refactor the modules_array to ptr_array

2024-03-11 Thread Alexei Starovoitov
On Mon, Mar 11, 2024 at 2:34 AM Menglong Dong wrote: > > Refactor the struct modules_array to more general struct ptr_array, which > is used to store the pointers. > > Meanwhiles, introduce the bpf_try_add_ptr(), which checks the existing of > the ptr before adding it to the array. > > Seems it

Re: [PATCH bpf-next v2 1/9] bpf: tracing: add support to record and check the accessed args

2024-03-11 Thread Alexei Starovoitov
On Mon, Mar 11, 2024 at 2:34 AM Menglong Dong wrote: > > In this commit, we add the 'accessed_args' field to struct bpf_prog_aux, > which is used to record the accessed index of the function args in > btf_ctx_access(). > > Meanwhile, we add the function btf_check_func_part_match() to compare the

Re: [PATCH RFC bpf-next v3 08/16] bpf/verifier: do_misc_fixups for is_bpf_timer_set_sleepable_cb_kfunc

2024-02-27 Thread Alexei Starovoitov
On Tue, Feb 27, 2024 at 8:51 AM Benjamin Tissoires wrote: > > On Tue, Feb 27, 2024 at 5:36 PM Eduard Zingerman wrote: > > > > On Tue, 2024-02-27 at 17:18 +0100, Benjamin Tissoires wrote: > > [...] > > > > > Hmm, I must still be missing a piece of the puzzle: > > > if I declare

Re: [PATCH RFC bpf-next v3 02/16] bpf/verifier: introduce in_sleepable() helper

2024-02-22 Thread Alexei Starovoitov
On Wed, Feb 21, 2024 at 8:25 AM Benjamin Tissoires wrote: > @@ -18193,7 +18198,7 @@ static int resolve_pseudo_ldimm64(struct > bpf_verifier_env *env) > return -E2BIG; > } > > - if (env->prog->aux->sleepable) > +

Re: [PATCH RFC bpf-next v3 06/16] bpf/helpers: introduce bpf_timer_set_sleepable_cb() kfunc

2024-02-22 Thread Alexei Starovoitov
On Wed, Feb 21, 2024 at 8:25 AM Benjamin Tissoires wrote: > > In this patch, bpf_timer_set_sleepable_cb() is functionally equivalent > to bpf_timer_set_callback(), to the exception that it enforces > the timer to be started with BPF_F_TIMER_SLEEPABLE. > > But given that bpf_timer_set_callback()

Re: [PATCH RFC bpf-next v3 04/16] bpf/helpers: introduce sleepable bpf_timers

2024-02-22 Thread Alexei Starovoitov
On Wed, Feb 21, 2024 at 8:25 AM Benjamin Tissoires wrote: > /* the actual struct hidden inside uapi struct bpf_timer */ > @@ -1113,6 +1120,55 @@ struct bpf_timer_kern { > struct bpf_spin_lock lock; > } __attribute__((aligned(8))); > > +static u32 __bpf_timer_compute_key(struct

Re: [External] Re: [PATCH bpf-next 0/5] bpf: make tracing program support multi-attach

2024-02-20 Thread Alexei Starovoitov
On Tue, Feb 20, 2024 at 7:06 PM 梦龙董 wrote: > > On Wed, Feb 21, 2024 at 11:02 AM Alexei Starovoitov > wrote: > > > > On Tue, Feb 20, 2024 at 6:45 PM 梦龙董 wrote: > > > > > > On Wed, Feb 21, 2024 at 10:35 AM 梦龙董 wrote: > > > > > > > >

Re: [External] Re: [PATCH bpf-next 0/5] bpf: make tracing program support multi-attach

2024-02-20 Thread Alexei Starovoitov
On Tue, Feb 20, 2024 at 6:45 PM 梦龙董 wrote: > > On Wed, Feb 21, 2024 at 10:35 AM 梦龙董 wrote: > > > > Hello, > > > > On Wed, Feb 21, 2024 at 9:24 AM Alexei Starovoitov > > wrote: > > > > > > On Mon, Feb 19, 2024 at 7:51 PM Menglong Dong

Re: [PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-20 Thread Alexei Starovoitov
On Fri, Feb 16, 2024 at 10:50:10AM +0100, Benjamin Tissoires wrote: > static bool is_rbtree_lock_required_kfunc(u32 btf_id) > { > return is_bpf_rbtree_api_kfunc(btf_id); > @@ -12140,6 +12143,16 @@ static int check_kfunc_call(struct bpf_verifier_env > *env, struct bpf_insn *insn, >

Re: [PATCH RFC bpf-next v2 03/10] bpf/verifier: allow more maps in sleepable bpf programs

2024-02-20 Thread Alexei Starovoitov
On Wed, Feb 14, 2024 at 06:18:32PM +0100, Benjamin Tissoires wrote: > These 2 maps types are required for HID-BPF when a user wants to do > IO with a device from a sleepable tracing point. > > Allowing BPF_MAP_TYPE_QUEUE (and therefore BPF_MAP_TYPE_STACK) allows > for a BPF program to prepare

Re: [PATCH RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-20 Thread Alexei Starovoitov
On Fri, Feb 16, 2024 at 03:58:20PM +0100, Benjamin Tissoires wrote: > > So (and this also answers your second email today) I'm thinking at: > - have multiple flags to control the timer (with dedicated timer_cb > kernel functions): > - BPF_F_TIMER_HRTIMER (default) > - BPF_F_TIMER_WORKER (no

Re: [PATCH bpf-next 0/5] bpf: make tracing program support multi-attach

2024-02-20 Thread Alexei Starovoitov
On Mon, Feb 19, 2024 at 7:51 PM Menglong Dong wrote: > > For now, the BPF program of type BPF_PROG_TYPE_TRACING is not allowed to > be attached to multiple hooks, and we have to create a BPF program for > each kernel function, for which we want to trace, even through all the > program have the

Re: [PATCH RFC bpf-next 0/9] allow HID-BPF to do device IOs

2024-02-13 Thread Alexei Starovoitov
On Tue, Feb 13, 2024 at 08:51:26PM +0100, Toke Høiland-Jørgensen wrote: > Kumar Kartikeya Dwivedi writes: > > > On Tue, 13 Feb 2024 at 18:46, Benjamin Tissoires wrote: > >> > >> On Feb 12 2024, Alexei Starovoitov wrote: > >> > On Mon, Feb 12, 2024 at

Re: [PATCH RFC bpf-next 0/9] allow HID-BPF to do device IOs

2024-02-13 Thread Alexei Starovoitov
On Tue, Feb 13, 2024 at 08:23:17PM +0100, Kumar Kartikeya Dwivedi wrote: > On Tue, 13 Feb 2024 at 18:46, Benjamin Tissoires wrote: > > > > On Feb 12 2024, Alexei Starovoitov wrote: > > > On Mon, Feb 12, 2024 at 10:21 AM Benjamin Tissoires > > > wrote: > > &

Re: [PATCH RFC bpf-next 0/9] allow HID-BPF to do device IOs

2024-02-12 Thread Alexei Starovoitov
On Mon, Feb 12, 2024 at 10:21 AM Benjamin Tissoires wrote: > > On Mon, Feb 12, 2024 at 6:46 PM Toke Høiland-Jørgensen > wrote: > > > > Benjamin Tissoires writes: > > > > [...] > > >> IIUC, the bpf_timer callback is just a function (subprog) from the > > >> verifier PoV, so it is verified as

Re: Re: lsm_cgroup.c selftest fails to compile when CONFIG_PACKET!=y

2024-01-19 Thread Alexei Starovoitov
On Fri, Jan 19, 2024 at 7:00 AM Vincent Li wrote: > > On Fri, Jan 19, 2024 at 4:23 AM Eduard Zingerman wrote: > > > > On Fri, 2024-01-19 at 16:04 +0800, Shung-Hsi Yu wrote: > > > > [...] > > > > > Final goal would be have BPF selftests compiled and test against our own > > > kernel, without

Re: [PATCH bpf-next v2 10/15] bpf: Track spilled unbounded scalars

2024-01-12 Thread Alexei Starovoitov
On Fri, Jan 12, 2024 at 12:44 PM Maxim Mikityanskiy wrote: > > On Fri, 12 Jan 2024 at 11:10:57 -0800, Alexei Starovoitov wrote: > > On Mon, Jan 8, 2024 at 12:53 PM Maxim Mikityanskiy > > wrote: > > > > > > From: Maxim Mikityanskiy > > > > &

Re: [PATCH bpf-next v2 10/15] bpf: Track spilled unbounded scalars

2024-01-12 Thread Alexei Starovoitov
On Mon, Jan 8, 2024 at 12:53 PM Maxim Mikityanskiy wrote: > > From: Maxim Mikityanskiy > > Support the pattern where an unbounded scalar is spilled to the stack, > then boundary checks are performed on the src register, after which the > stack frame slot is refilled into a register. > > Before

Re: [PATCH 1/3] selftests/bpf: Update LLVM Phabricator links

2024-01-11 Thread Alexei Starovoitov
On Thu, Jan 11, 2024 at 11:40 AM Nathan Chancellor wrote: > > Hi Yonghong, > > On Wed, Jan 10, 2024 at 08:05:36PM -0800, Yonghong Song wrote: > > > > On 1/9/24 2:16 PM, Nathan Chancellor wrote: > > > reviews.llvm.org was LLVM's Phabricator instances for code review. It > > > has been abandoned in

Re: [PATCH bpf-next 08/15] bpf: Assign ID to scalars on spill

2023-12-25 Thread Alexei Starovoitov
On Mon, Dec 25, 2023 at 1:11 PM Maxim Mikityanskiy wrote: > > On Sun, 24 Dec 2023 at 19:15:42 -0800, Alexei Starovoitov wrote: > > On Wed, Dec 20, 2023 at 1:40 PM Maxim Mikityanskiy > > wrote: > > > > > > From: Maxim Mikityanskiy > > > > > >

Re: [PATCH bpf-next 08/15] bpf: Assign ID to scalars on spill

2023-12-24 Thread Alexei Starovoitov
On Wed, Dec 20, 2023 at 1:40 PM Maxim Mikityanskiy wrote: > > From: Maxim Mikityanskiy > > Currently, when a scalar bounded register is spilled to the stack, its > ID is preserved, but only if was already assigned, i.e. if this register > was MOVed before. > > Assign an ID on spill if none is

Re: [PATCH bpf-next 2/3] bpf: selftests: Add bpf_assert_if() and bpf_assert_with_if() macros

2023-12-16 Thread Alexei Starovoitov
On Thu, Dec 14, 2023 at 7:10 PM Alexei Starovoitov wrote: > > Just realized that we can go the other way instead. > > We can get rid of bpf_assert_eq/ne/... and replace with: > > diff --git a/tools/testing/selftests/bpf/bpf_experimental.h > b/tools/testing/selftests/bpf/bpf_e

Re: [PATCH bpf-next 2/3] bpf: selftests: Add bpf_assert_if() and bpf_assert_with_if() macros

2023-12-14 Thread Alexei Starovoitov
On Thu, Dec 14, 2023 at 6:46 PM Alexei Starovoitov wrote: > > On Thu, Dec 14, 2023 at 2:56 PM Daniel Xu wrote: > > > > These macros are a temporary stop-gap until bpf exceptions support > > unwinding acquired entities. Basically these macros act as if they take >

Re: [PATCH bpf-next 2/3] bpf: selftests: Add bpf_assert_if() and bpf_assert_with_if() macros

2023-12-14 Thread Alexei Starovoitov
On Thu, Dec 14, 2023 at 2:56 PM Daniel Xu wrote: > > These macros are a temporary stop-gap until bpf exceptions support > unwinding acquired entities. Basically these macros act as if they take > a callback which only get executed if the assertion fails. > > Signed-off-by: Daniel Xu > --- >

Re: [PATCH bpf-next v5 9/9] bpf: xfrm: Add selftest for bpf_xdp_get_xfrm_state()

2023-12-14 Thread Alexei Starovoitov
On Thu, Dec 14, 2023 at 12:24 PM Daniel Xu wrote: > > > Looks like only x86 supports exceptions (looking at > bpf_jit_supports_exceptions()). > > This causes selftests in this patchset to fail on !x86, which is > unfortunate. We probably want to be running these tests on all the major > archs, so

Re: [PATCH bpf-next v5 9/9] bpf: xfrm: Add selftest for bpf_xdp_get_xfrm_state()

2023-12-12 Thread Alexei Starovoitov
On Tue, Dec 12, 2023 at 8:17 AM Daniel Xu wrote: > > > If you don't mind (and there no more comments), I would prefer to send a > follow up fixing the nits in this revision. So that I stop blasting the > list (as well as people who may not be as concerned with these details). Resending patches

Re: [PATCH ipsec-next v3 0/9] Add bpf_xdp_get_xfrm_state() kfunc

2023-12-01 Thread Alexei Starovoitov
On Fri, Dec 1, 2023 at 12:23 PM Daniel Xu wrote: > > This patchset adds two kfunc helpers, bpf_xdp_get_xfrm_state() and > bpf_xdp_xfrm_state_release() that wrap xfrm_state_lookup() and > xfrm_state_put(). The intent is to support software RSS (via XDP) for > the ongoing/upcoming ipsec pcpu work

Re: [PATCH ipsec-next v1 6/7] bpf: selftests: test_tunnel: Disable CO-RE relocations

2023-11-25 Thread Alexei Starovoitov
On Sat, Nov 25, 2023 at 4:52 PM Yonghong Song wrote: > > > > > diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c > > b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c > > index 3065a716544d..ec7e04e012ae 100644 > > --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c >

Re: [PATCH ipsec-next v1 7/7] bpf: xfrm: Add selftest for bpf_xdp_get_xfrm_state()

2023-11-22 Thread Alexei Starovoitov
On Wed, Nov 22, 2023 at 10:21 AM Daniel Xu wrote: > > + > + bpf_printk("replay-window %d\n", x->replay_esn->replay_window); Pls no printk in tests. Find a different way to validate.

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-10-17 Thread Alexei Starovoitov
On Mon, Oct 16, 2023 at 7:38 PM Jason Wang wrote: > > On Tue, Oct 17, 2023 at 7:53 AM Alexei Starovoitov > wrote: > > > > On Sun, Oct 15, 2023 at 10:10 AM Akihiko Odaki > > wrote: > > > > > > On 2023/10/16 1:07, Alexei Starovoitov wrote: > >

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-10-16 Thread Alexei Starovoitov
On Sun, Oct 15, 2023 at 10:10 AM Akihiko Odaki wrote: > > On 2023/10/16 1:07, Alexei Starovoitov wrote: > > On Sun, Oct 15, 2023 at 7:17 AM Akihiko Odaki > > wrote: > >> > >> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > >

Re: [RFC PATCH v2 1/7] bpf: Introduce BPF_PROG_TYPE_VNET_HASH

2023-10-15 Thread Alexei Starovoitov
On Sun, Oct 15, 2023 at 7:17 AM Akihiko Odaki wrote: > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > index 0448700890f7..298634556fab 100644 > --- a/include/uapi/linux/bpf.h > +++ b/include/uapi/linux/bpf.h > @@ -988,6 +988,7 @@ enum bpf_prog_type { >

Re: [PATCH 2/3] Revert "bpf: Fix issue in verifying allow_ptr_leaks"

2023-09-19 Thread Alexei Starovoitov
On Mon, Sep 18, 2023 at 4:26 AM Luis Gerhorst wrote: > > It is true that this is not easily possible using the method most exploits > use, > at least to my knowledge (i.e., accessing the same address from another core). > However, it is still possible to evict the cacheline with

Re: [PATCH bpf-next v3 9/9] MAINTAINERS: Add myself for ARM32 BPF JIT maintainer.

2023-09-15 Thread Alexei Starovoitov
On Fri, Sep 8, 2023 at 7:50 AM Puranjay Mohan wrote: > > On Fri, Sep 8, 2023 at 3:49 PM Daniel Borkmann wrote: > > > > On 9/8/23 10:37 AM, Russell King (Oracle) wrote: > > > On Thu, Sep 07, 2023 at 11:05:50PM +, Puranjay Mohan wrote: > > >> As Shubham has been inactive since 2017, Add myself

Re: [PATCH 2/3] Revert "bpf: Fix issue in verifying allow_ptr_leaks"

2023-09-14 Thread Alexei Starovoitov
On Thu, Sep 14, 2023 at 10:24 AM Daniel Borkmann wrote: > > On 9/14/23 6:20 PM, Alexei Starovoitov wrote: > > On Wed, Sep 13, 2023 at 5:30 AM Luis Gerhorst wrote: > >> > >> This reverts commit d75e30dddf73449bc2d10bb8e2f1a2c446bc67a2. > >> > >

Re: [PATCH 2/3] Revert "bpf: Fix issue in verifying allow_ptr_leaks"

2023-09-14 Thread Alexei Starovoitov
On Wed, Sep 13, 2023 at 5:30 AM Luis Gerhorst wrote: > > This reverts commit d75e30dddf73449bc2d10bb8e2f1a2c446bc67a2. > > To mitigate Spectre v1, the verifier relies on static analysis to deduct > constant pointer bounds, which can then be enforced by rewriting pointer > arithmetic [1] or index