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

2024-02-21 Thread Benjamin Tissoires
[replying to both of your messages here] On Wed, Feb 21, 2024 at 3:59 AM Alexei Starovoitov wrote: > > 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); > > @@

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 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 RFC bpf-next v2 02/10] bpf/helpers: introduce sleepable timers

2024-02-17 Thread Toke Høiland-Jørgensen
Benjamin Tissoires writes: > On Feb 16 2024, Toke Høiland-Jørgensen wrote: >> Benjamin Tissoires writes: >> >> > On Feb 15 2024, Martin KaFai Lau wrote: >> >> On 2/14/24 9:18 AM, Benjamin Tissoires wrote: >> >> > +static void bpf_timer_work_cb(struct work_struct *work) >> >> > +{ >> >> > +

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

2024-02-16 Thread Kui-Feng Lee
On 2/14/24 09:18, Benjamin Tissoires wrote: +static void bpf_timer_work_cb(struct work_struct *work) +{ + struct bpf_hrtimer *t = container_of(work, struct bpf_hrtimer, work); + struct bpf_map *map = t->map; + void *value = t->value; + bpf_callback_t callback_fn; + void *key; + u32 idx; + +

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

2024-02-16 Thread Benjamin Tissoires
On Feb 16 2024, Toke Høiland-Jørgensen wrote: > Benjamin Tissoires writes: > > > On Feb 15 2024, Martin KaFai Lau wrote: > >> On 2/14/24 9:18 AM, Benjamin Tissoires wrote: > >> > +static void bpf_timer_work_cb(struct work_struct *work) > >> > +{ > >> > +struct bpf_hrtimer *t =

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

2024-02-16 Thread Toke Høiland-Jørgensen
Just one comment on one of your FIXMEs: > + rcu_assign_pointer(t->sleepable_cb_fn, NULL); > + /* FIXME: probably do something about the SLEEPABLE flag */ I guess we should store the flag in the timer struct somewhere, and then restrict the set_callback() functions so that the regular

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

2024-02-16 Thread Toke Høiland-Jørgensen
Benjamin Tissoires writes: > On Feb 15 2024, Martin KaFai Lau wrote: >> On 2/14/24 9:18 AM, Benjamin Tissoires wrote: >> > +static void bpf_timer_work_cb(struct work_struct *work) >> > +{ >> > + struct bpf_hrtimer *t = container_of(work, struct bpf_hrtimer, work); >> > + struct bpf_map *map =

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

2024-02-16 Thread Benjamin Tissoires
On Feb 15 2024, Benjamin Tissoires wrote: > On Feb 14 2024, Benjamin Tissoires wrote: > > They are implemented as a kfunc, which means a little bit of tweaks in > > the verifier. > > > > Signed-off-by: Benjamin Tissoires > > > > --- > > > > changes in v2 (compared to the one attaches to v1

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

2024-02-16 Thread Benjamin Tissoires
On Feb 15 2024, Martin KaFai Lau wrote: > On 2/14/24 9:18 AM, Benjamin Tissoires wrote: > > +static void bpf_timer_work_cb(struct work_struct *work) > > +{ > > + struct bpf_hrtimer *t = container_of(work, struct bpf_hrtimer, work); > > + struct bpf_map *map = t->map; > > + void *value =

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

2024-02-15 Thread Martin KaFai Lau
On 2/14/24 9:18 AM, Benjamin Tissoires wrote: +static void bpf_timer_work_cb(struct work_struct *work) +{ + struct bpf_hrtimer *t = container_of(work, struct bpf_hrtimer, work); + struct bpf_map *map = t->map; + void *value = t->value; + bpf_callback_t callback_fn; +

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

2024-02-15 Thread Benjamin Tissoires
On Feb 14 2024, Benjamin Tissoires wrote: > They are implemented as a kfunc, which means a little bit of tweaks in > the verifier. > > Signed-off-by: Benjamin Tissoires > > --- > > changes in v2 (compared to the one attaches to v1 0/9): > - make use of a kfunc > - add a (non-used)

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

2024-02-14 Thread Benjamin Tissoires
They are implemented as a kfunc, which means a little bit of tweaks in the verifier. Signed-off-by: Benjamin Tissoires --- changes in v2 (compared to the one attaches to v1 0/9): - make use of a kfunc - add a (non-used) BPF_F_TIMER_SLEEPABLE - the callback is *not* called, it makes the kernel