Re: [PATCH HID v3 15/16] HID: bpf: rework hid_bpf_ops_btf_struct_access

2024-06-11 Thread Benjamin Tissoires
On Jun 10 2024, Alexei Starovoitov wrote: > On Sat, Jun 8, 2024 at 2:01 AM Benjamin Tissoires wrote: > > > > The idea is to provide a list of stucts and their editable fields. > > > > Currently no functional changes are introduced here, we will add some > > more w

[PATCH HID v3 16/16] HID: bpf: make part of struct hid_device writable

2024-06-08 Thread Benjamin Tissoires
the device export 3 nodes, all with the same name. Signed-off-by: Benjamin Tissoires --- changes in v3: - amend for new WRITE_RANGE API new in v2 --- drivers/hid/bpf/hid_bpf_struct_ops.c | 3 +++ include/linux/hid_bpf.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff

[PATCH HID v3 15/16] HID: bpf: rework hid_bpf_ops_btf_struct_access

2024-06-08 Thread Benjamin Tissoires
The idea is to provide a list of stucts and their editable fields. Currently no functional changes are introduced here, we will add some more writeable fields in the next patch. Signed-off-by: Benjamin Tissoires --- changes in v3: - rewrote WRITE_RANGE macro to not deal with offset from

[PATCH HID v3 14/16] bpf: allow bpf helpers to be used into HID-BPF struct_ops

2024-06-08 Thread Benjamin Tissoires
Without this helpers like bpf_printk() or bpf_map_update() are not available, making anything but change of bytes impossible to do. Signed-off-by: Benjamin Tissoires --- no changes in v3 new in v2 --- drivers/hid/bpf/hid_bpf_struct_ops.c | 1 + 1 file changed, 1 insertion(+) diff --git

[PATCH HID v3 13/16] HID: bpf: error on warnings when compiling bpf objects

2024-06-08 Thread Benjamin Tissoires
There is no real reasons to paper over warnings for such small programs. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/progs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/bpf/progs/Makefile b/drivers/hid

[PATCH HID v3 12/16] HID: bpf: Artist24: remove unused variable

2024-06-08 Thread Benjamin Tissoires
warning: unused variable ‘tilt’ [-Wunused-variable] Signed-off-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/progs/XPPen__Artist24.bpf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/bpf/progs/XPPen__Artist24

[PATCH HID v3 11/16] Documentation: HID: add a small blurb on udev-hid-bpf

2024-06-08 Thread Benjamin Tissoires
This is the current decision we took: we don't provide automatic loading of HID-BPF by the kernel directly, but rely on an external tool for it. This tool is currently udev-hid-bpf, so let's make people aware of it. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2

[PATCH HID v3 10/16] Documentation: HID: amend HID-BPF for struct_ops

2024-06-08 Thread Benjamin Tissoires
Now that we are using struct_ops, the docs need to be changed. Signed-off-by: Benjamin Tissoires --- no changes in v3 changes in v2 - use BPF_F_BEFORE --- Documentation/hid/hid-bpf.rst | 156 +++--- include/linux/hid_bpf.h | 8 +-- 2 files changed

[PATCH HID v3 09/16] selftests/hid: add subprog call test

2024-06-08 Thread Benjamin Tissoires
I got a weird verifier error with a subprog once, so let's have a test for it. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- tools/testing/selftests/hid/hid_bpf.c | 41 + tools/testing/selftests/hid/progs/hid.c | 24

[PATCH HID v3 08/16] HID: bpf: remove tracing HID-BPF capability

2024-06-08 Thread Benjamin Tissoires
We can now rely on struct_ops as we cleared the users in-tree. Signed-off-by: Benjamin Tissoires --- no changes in v3 changes in v2: - remove now unused enum hid_bpf_attach_flags --- drivers/hid/bpf/Makefile| 2 +- drivers/hid/bpf/entrypoints/Makefile

[PATCH HID v3 07/16] HID: bpf: convert in-tree fixes into struct_ops

2024-06-08 Thread Benjamin Tissoires
Very mechanical: - Change HID_BPF_DEVICE_EVENT and HID_BPF_RDESC_FIXUP #defines - add a matching SEC(".struct_ops.link") - in ArtistPro16Gen2 make the 2 functions static and have a new one calling them Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- d

[PATCH HID v3 06/16] HID: bpf: add defines for HID-BPF SEC in in-tree bpf fixes

2024-06-08 Thread Benjamin Tissoires
We are going to switch over struct_ops, so instead of having to manually replace all fields one by one, let's have a common place to change it. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.c | 4 ++-- drivers

[PATCH HID v3 05/16] HID: samples: convert the 2 HID-BPF samples into struct_ops

2024-06-08 Thread Benjamin Tissoires
This is mostly mechanical: attach_prog is dropped, and the SEC are converted into struct_ops. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 but the commit message. --- samples/hid/Makefile | 5 ++-- samples/hid/hid_bpf_attach.bpf.c | 18

[PATCH HID v3 04/16] selftests/hid: convert the hid_bpf selftests with struct_ops

2024-06-08 Thread Benjamin Tissoires
We drop the need for the attach() bpf syscall, but we need to set up the hid_id field before calling __load(). The .bpf.c part is mechanical: we create one struct_ops per HID-BPF program, as all the tests are for one program at a time. Signed-off-by: Benjamin Tissoires --- no changes in v3

[PATCH HID v3 03/16] HID: bpf: implement HID-BPF through bpf_struct_ops

2024-06-08 Thread Benjamin Tissoires
- the "attach" is now generic through BPF-core: the caller just needs to set hid_id and flags before calling __load(). - all the BPF tough part is not handled in BPF-core through generic processing - hid_bpf_ctx is now only writable where it needs be Signed-off-by: Benjamin

[PATCH HID v3 02/16] HID: bpf: add hid_get/put_device() helpers

2024-06-08 Thread Benjamin Tissoires
no code change, but this way we reduce code duplication and we can export it later. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 47 ++ 1 file changed, 27 insertions(+), 20 deletions

[PATCH HID v3 01/16] HID: rename struct hid_bpf_ops into hid_ops

2024-06-08 Thread Benjamin Tissoires
Those operations are the ones from HID, not HID-BPF, and I'd like to reuse hid_bpf_ops as the user facing struct_ops API. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 22 +++--- drivers/hid/hid-core.c

[PATCH HID v3 00/16] HID: convert HID-BPF into using bpf_struct_ops

2024-06-08 Thread Benjamin Tissoires
). The matching user-space loader (udev-hid-bpf) MR is at https://gitlab.freedesktop.org/libevdev/udev-hid-bpf/-/merge_requests/86 I'll put it out of draft once this is merged. Cheers, Benjamin Signed-off-by: Benjamin Tissoires --- Changes in v3: - took Alexei's review into account - Link to v2

Re: [PATCH HID v2 03/16] HID: bpf: implement HID-BPF through bpf_struct_ops

2024-06-08 Thread Benjamin Tissoires
On Jun 07 2024, Alexei Starovoitov wrote: > On Fri, Jun 7, 2024 at 8:28 AM Benjamin Tissoires wrote: > > +struct hid_bpf_ops { > > + /* hid_id needs to stay first so we can easily change it > > +* from userspace. > > +*/ > > +

[PATCH HID v2 16/16] HID: bpf: make part of struct hid_device writable

2024-06-07 Thread Benjamin Tissoires
the device export 3 nodes, all with the same name. Signed-off-by: Benjamin Tissoires --- new in v2 --- drivers/hid/bpf/hid_bpf_struct_ops.c | 3 +++ include/linux/hid_bpf.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hid/bpf/hid_bpf_struct_ops.c b

[PATCH HID v2 15/16] HID: bpf: rework hid_bpf_ops_btf_struct_access

2024-06-07 Thread Benjamin Tissoires
The idea is to provide a list of stucts and their editable fields. Currently no functional changes are introduced here, we will add some more writeable fields in the next patch. Signed-off-by: Benjamin Tissoires --- new in v2 --- drivers/hid/bpf/hid_bpf_struct_ops.c | 91

[PATCH HID v2 14/16] bpf: allow bpf helpers to be used into HID-BPF struct_ops

2024-06-07 Thread Benjamin Tissoires
Without this helpers like bpf_printk() or bpf_map_update() are not available, making anything but change of bytes impossible to do. Signed-off-by: Benjamin Tissoires --- new in v2 --- drivers/hid/bpf/hid_bpf_struct_ops.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hid/bpf

[PATCH HID v2 13/16] HID: bpf: error on warnings when compiling bpf objects

2024-06-07 Thread Benjamin Tissoires
There is no real reasons to paper over warnings for such small programs. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- drivers/hid/bpf/progs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/bpf/progs/Makefile b/drivers/hid/bpf/progs

[PATCH HID v2 12/16] HID: bpf: Artist24: remove unused variable

2024-06-07 Thread Benjamin Tissoires
warning: unused variable ‘tilt’ [-Wunused-variable] Signed-off-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v2 --- drivers/hid/bpf/progs/XPPen__Artist24.bpf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/bpf/progs/XPPen__Artist24.bpf.c b/drivers

[PATCH HID v2 11/16] Documentation: HID: add a small blurb on udev-hid-bpf

2024-06-07 Thread Benjamin Tissoires
This is the current decision we took: we don't provide automatic loading of HID-BPF by the kernel directly, but rely on an external tool for it. This tool is currently udev-hid-bpf, so let's make people aware of it. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- Documentation/hid

[PATCH HID v2 10/16] Documentation: HID: amend HID-BPF for struct_ops

2024-06-07 Thread Benjamin Tissoires
Now that we are using struct_ops, the docs need to be changed. Signed-off-by: Benjamin Tissoires --- changes in v2 - use BPF_F_BEFORE --- Documentation/hid/hid-bpf.rst | 156 +++--- include/linux/hid_bpf.h | 8 +-- 2 files changed, 76 insertions

[PATCH HID v2 09/16] selftests/hid: add subprog call test

2024-06-07 Thread Benjamin Tissoires
I got a weird verifier error with a subprog once, so let's have a test for it. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/hid_bpf.c | 41 + tools/testing/selftests/hid/progs/hid.c | 24 +++ 2 files

[PATCH HID v2 08/16] HID: bpf: remove tracing HID-BPF capability

2024-06-07 Thread Benjamin Tissoires
We can now rely on struct_ops as we cleared the users in-tree. Signed-off-by: Benjamin Tissoires --- changes in v2: - remove now unused enum hid_bpf_attach_flags --- drivers/hid/bpf/Makefile| 2 +- drivers/hid/bpf/entrypoints/Makefile| 93 drivers

[PATCH HID v2 07/16] HID: bpf: convert in-tree fixes into struct_ops

2024-06-07 Thread Benjamin Tissoires
Very mechanical: - Change HID_BPF_DEVICE_EVENT and HID_BPF_RDESC_FIXUP #defines - add a matching SEC(".struct_ops.link") - in ArtistPro16Gen2 make the 2 functions static and have a new one calling them Signed-off-by: Benjamin Tissoires --- no changes in v2 --- drivers/hid/bp

[PATCH HID v2 06/16] HID: bpf: add defines for HID-BPF SEC in in-tree bpf fixes

2024-06-07 Thread Benjamin Tissoires
We are going to switch over struct_ops, so instead of having to manually replace all fields one by one, let's have a common place to change it. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.c | 4 ++-- drivers/hid/bpf/progs

[PATCH HID v2 05/16] HID: samples: convert the 2 HID-BPF samples into struct_ops

2024-06-07 Thread Benjamin Tissoires
This is mostly mechanical: attach_prog is dropped, and the SEC are converted into struct_ops. Signed-off-by: Benjamin Tissoires --- no changes in v2 but the commit message. --- samples/hid/Makefile | 5 ++-- samples/hid/hid_bpf_attach.bpf.c | 18 - samples/hid

[PATCH HID v2 04/16] selftests/hid: convert the hid_bpf selftests with struct_ops

2024-06-07 Thread Benjamin Tissoires
We drop the need for the attach() bpf syscall, but we need to set up the hid_id field before calling __load(). The .bpf.c part is mechanical: we create one struct_ops per HID-BPF program, as all the tests are for one program at a time. Signed-off-by: Benjamin Tissoires --- changes in v2

[PATCH HID v2 03/16] HID: bpf: implement HID-BPF through bpf_struct_ops

2024-06-07 Thread Benjamin Tissoires
- the "attach" is now generic through BPF-core: the caller just needs to set hid_id and flags before calling __load(). - all the BPF tough part is not handled in BPF-core through generic processing - hid_bpf_ctx is now only writable where it needs be Signed-off-by: Benjamin

[PATCH HID v2 02/16] HID: bpf: add hid_get/put_device() helpers

2024-06-07 Thread Benjamin Tissoires
no code change, but this way we reduce code duplication and we can export it later. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 47 ++ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git

[PATCH HID v2 01/16] HID: rename struct hid_bpf_ops into hid_ops

2024-06-07 Thread Benjamin Tissoires
Those operations are the ones from HID, not HID-BPF, and I'd like to reuse hid_bpf_ops as the user facing struct_ops API. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 22 +++--- drivers/hid/hid-core.c | 6

[PATCH HID v2 00/16] HID: convert HID-BPF into using bpf_struct_ops

2024-06-07 Thread Benjamin Tissoires
). The matching user-space loader (udev-hid-bpf) MR is at https://gitlab.freedesktop.org/libevdev/udev-hid-bpf/-/merge_requests/86 I'll put it out of draft once this is merged. Cheers, Benjamin Signed-off-by: Benjamin Tissoires --- Changes in v2: - drop HID_BPF_FLAGS enum and use BPF_F_BEFORE

Re: [PATCH HID 03/13] HID: bpf: implement HID-BPF through bpf_struct_ops

2024-05-29 Thread Benjamin Tissoires
On May 28 2024, Alexei Starovoitov wrote: > On Tue, May 28, 2024 at 6:15 AM Benjamin Tissoires wrote: > > > > We do this implementation in several steps to not have the CI failing: > > - first (this patch), we add struct_ops while keeping the existing infra > > ava

[PATCH HID 13/13] HID: bpf: error on warnings when compiling bpf objects

2024-05-28 Thread Benjamin Tissoires
There is no real reasons to paper over warnings for such small programs. Signed-off-by: Benjamin Tissoires --- drivers/hid/bpf/progs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/bpf/progs/Makefile b/drivers/hid/bpf/progs/Makefile index 63ed7e02adf1

[PATCH HID 12/13] HID: bpf: Artist24: remove unused variable

2024-05-28 Thread Benjamin Tissoires
warning: unused variable ‘tilt’ [-Wunused-variable] Signed-off-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- drivers/hid/bpf/progs/XPPen__Artist24.bpf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/bpf/progs/XPPen__Artist24.bpf.c b/drivers/hid/bpf/progs

[PATCH HID 11/13] Documentation: HID: add a small blurb on udev-hid-bpf

2024-05-28 Thread Benjamin Tissoires
This is the current decision we took: we don't provide automatic loading of HID-BPF by the kernel directly, but rely on an external tool for it. This tool is currently udev-hid-bpf, so let's make people aware of it. Signed-off-by: Benjamin Tissoires --- Documentation/hid/hid-bpf.rst | 17

[PATCH HID 10/13] Documentation: HID: amend HID-BPF for struct_ops

2024-05-28 Thread Benjamin Tissoires
Now that we are using struct_ops, the docs need to be changed. Signed-off-by: Benjamin Tissoires --- Documentation/hid/hid-bpf.rst | 145 +++--- include/linux/hid_bpf.h | 8 +-- 2 files changed, 71 insertions(+), 82 deletions(-) diff --git

[PATCH HID 09/13] selftests/hid: add subprog call test

2024-05-28 Thread Benjamin Tissoires
I got a weird verifier error with a subprog once, so let's have a test for it. Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/hid_bpf.c | 41 + tools/testing/selftests/hid/progs/hid.c | 24 +++ 2 files changed, 65 insertions

[PATCH HID 08/13] HID: bpf: remove tracing HID-BPF capability

2024-05-28 Thread Benjamin Tissoires
We can now rely on struct_ops as we cleared the users in-tree. Signed-off-by: Benjamin Tissoires --- drivers/hid/bpf/Makefile| 2 +- drivers/hid/bpf/entrypoints/Makefile| 93 drivers/hid/bpf/entrypoints/README | 4 - drivers/hid/bpf

[PATCH HID 07/13] HID: bpf: convert in-tree fixes into struct_ops

2024-05-28 Thread Benjamin Tissoires
Very mechanical: - Change HID_BPF_DEVICE_EVENT and HID_BPF_RDESC_FIXUP #defines - add a matching SEC(".struct_ops.link") - in ArtistPro16Gen2 make the 2 functions static and have a new one calling them Signed-off-by: Benjamin Tissoires --- drivers/hid/bpf/progs/FR-TEC__Raptor-Ma

[PATCH HID 06/13] HID: bpf: add defines for HID-BPF SEC in in-tree bpf fixes

2024-05-28 Thread Benjamin Tissoires
We are going to switch over struct_ops, so instead of having to manually replace all fields one by one, let's have a common place to change it. Signed-off-by: Benjamin Tissoires --- drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.c | 4 ++-- drivers/hid/bpf/progs/HP__Elite-Presenter.bpf.c

[PATCH HID 05/13] HID: samples: convert the 2 HID-BPF samples into struct_ops

2024-05-28 Thread Benjamin Tissoires
hid_mouse is currently failing with bpf_printk() not available in struct_ops program type. Signed-off-by: Benjamin Tissoires --- samples/hid/Makefile | 5 ++-- samples/hid/hid_bpf_attach.bpf.c | 18 - samples/hid/hid_bpf_attach.h | 14 -- samples/hid

[PATCH HID 04/13] selftests/hid: convert the hid_bpf selftests with struct_ops

2024-05-28 Thread Benjamin Tissoires
We drop the need for the attach() bpf syscall, but we need to set up the hid_id field before calling __load(). The .bpf.c part is mechanical: we create one struct_ops per HID-BPF program, as all the tests are for one program at a time. Signed-off-by: Benjamin Tissoires --- tools/testing

[PATCH HID 03/13] HID: bpf: implement HID-BPF through bpf_struct_ops

2024-05-28 Thread Benjamin Tissoires
- the "attach" is now generic through BPF-core: the caller just needs to set hid_id and flags before calling __load(). - all the BPF tough part is not handled in BPF-core through generic processing - hid_bpf_ctx is now only writable where it needs be Signed-off-by: Benjamin Tissoires --

[PATCH HID 02/13] HID: bpf: add hid_get/put_device() helpers

2024-05-28 Thread Benjamin Tissoires
no code change, but this way we reduce code duplication and we can export it later. Signed-off-by: Benjamin Tissoires --- drivers/hid/bpf/hid_bpf_dispatch.c | 47 ++ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/drivers/hid/bpf

[PATCH HID 01/13] HID: rename struct hid_bpf_ops into hid_ops

2024-05-28 Thread Benjamin Tissoires
Those operations are the ones from HID, not HID-BPF, and I'd like to reuse hid_bpf_ops as the user facing struct_ops API. Signed-off-by: Benjamin Tissoires --- drivers/hid/bpf/hid_bpf_dispatch.c | 22 +++--- drivers/hid/hid-core.c | 6 +++--- include/linux/hid_bpf.h

[PATCH HID 00/13] HID: convert HID-BPF into using bpf_struct_ops

2024-05-28 Thread Benjamin Tissoires
). The matching user-space loader (udev-hid-bpf) MR is at https://gitlab.freedesktop.org/libevdev/udev-hid-bpf/-/merge_requests/86 I'll put it out of draft once this is merged. Cheers, Benjamin Signed-off-by: Benjamin Tissoires --- Benjamin Tissoires (13): HID: rename struct hid_bpf_ops

Re: [PATCH 00/18] HID: Include current HID-BPF fixes in tree

2024-05-07 Thread Benjamin Tissoires
On Wed, 10 Apr 2024 19:19:20 +0200, Benjamin Tissoires wrote: > When I introduced HID-BPF, I mentioned that we should ship the HID-BPF > programs in the kernel when they are fixes so that everybody can benefit > from them. > > I tried multiple times to do so but I was confro

[PATCH RFC bpf-next 8/8] bpf: rely on __aux suffix for bpf_wq_set_callback_impl

2024-05-07 Thread Benjamin Tissoires
And then cleanup the verifier about the special cases about this kfunc. Signed-off-by: Benjamin Tissoires --- This is an RFC, and is not meant to be fully reviewed/applied as it is. I'm posting this to show what I wanted to explain in https://lore.kernel.org/bpf

[PATCH RFC bpf-next 7/8] bpf: implement __aux kfunc argument suffix to fetch prog_aux

2024-05-07 Thread Benjamin Tissoires
This allows kfunc to request the prog_aux environment in their implementation, to have access to the originated bpf_prog for example. Signed-off-by: Benjamin Tissoires --- This is an RFC, and is not meant to be fully reviewed/applied as it is. I'm posting this to show what I wanted to explain

[PATCH RFC bpf-next 6/8] bpf: remove one special case of is_bpf_wq_set_callback_impl_kfunc

2024-05-07 Thread Benjamin Tissoires
It looks like the generic implementation based on __s_async suffix works well enough. So let's use it. Note: - currently we lose the return value range - the second argument is not of type PTR_TO_MAP_KEY Signed-off-by: Benjamin Tissoires --- This is an RFC, and is not meant to be fully

[PATCH RFC bpf-next 5/8] selftests/bpf: rely on wq_callback_fn_t

2024-05-07 Thread Benjamin Tissoires
The type of bpf_wq callbacks changed. So adapt to it and make use of wq_callback_fn_t. Signed-off-by: Benjamin Tissoires --- This is an RFC, and is not meant to be fully reviewed/applied as it is. I'm posting this to show what I wanted to explain in https://lore.kernel.org/bpf

[PATCH RFC bpf-next 4/8] bpf: typedef a type for the bpf_wq callbacks

2024-05-07 Thread Benjamin Tissoires
This allows users to rely on it by using it from the vmlinux.h Signed-off-by: Benjamin Tissoires --- This is an RFC, and is not meant to be fully reviewed/applied as it is. I'm posting this to show what I wanted to explain in https://lore.kernel.org/bpf

[PATCH RFC bpf-next 3/8] bpf: implement __async and __s_async kfunc suffixes

2024-05-07 Thread Benjamin Tissoires
still mostly a WIP, but it seems to be working for the couple of tests. Signed-off-by: Benjamin Tissoires --- This is an RFC, and is not meant to be fully reviewed/applied as it is. I'm posting this to show what I wanted to explain in https://lore.kernel.org/bpf

[PATCH RFC bpf-next 2/8] bpf: add kfunc_meta parameter to push_callback_call()

2024-05-07 Thread Benjamin Tissoires
No code change but is a preparatory patch for being able to declare async callbacks from bpf kfuncs. Signed-off-by: Benjamin Tissoires --- This is an RFC, and is not meant to be fully reviewed/applied as it is. I'm posting this to show what I wanted to explain in https://lore.kernel.org/bpf

[PATCH RFC bpf-next 1/8] bpf: ignore sleepable prog parameter for kfuncs

2024-05-07 Thread Benjamin Tissoires
There is no change of behavior: for each kfunc, we store the prog sleepable state. But this allows to declare an async non sleepable callback from a syscall, where everything is sleepable. Signed-off-by: Benjamin Tissoires --- This is an RFC, and is not meant to be fully reviewed/applied

[PATCH RFC bpf-next 0/8] Implement generic bpf_async cb

2024-05-07 Thread Benjamin Tissoires
This is a RFC, following[0]. It works, still needs some care but this is mainly to see if this will have a chance to get upsrteamed or if I should rely on struct_ops instead. Cheers, Benjamin Signed-off-by: Benjamin Tissoires --- Benjamin Tissoires (8): bpf: ignore sleepable prog

[PATCH bpf-next v3 3/3] selftests/bpf: drop an unused local variable

2024-04-30 Thread Benjamin Tissoires
Some copy/paste leftover, this is never used Fixes: e3d9eac99afd ("selftests/bpf: wq: add bpf_wq_init() checks") Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- tools/testing/selftests/bpf/prog_tests/wq.c | 2 -- 1 file changed, 2 deletions(-) diff --g

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

2024-04-30 Thread Benjamin Tissoires
t;) Signed-off-by: Benjamin Tissoires --- changes in v3: - fix unloading of bpf_wq, again changes in v2: - fix wq being not freed (and static call not used) --- kernel/bpf/hashtab.c | 49 + 1 file changed, 13 insertions(+), 36 deletions(-)

[PATCH bpf-next v3 1/3] bpf: do not walk twice the map on free

2024-04-30 Thread Benjamin Tissoires
Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- kernel/bpf/arraymap.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index 580d07b15471..feabc0193852 100644 --- a/kernel/bpf/arraymap.c +++ b/

[PATCH bpf-next v3 0/3] bpf_wq followup series

2024-04-30 Thread Benjamin Tissoires
Few patches that should have been there from day 1. Anyway, they are coming now. Signed-off-by: Benjamin Tissoires --- Changes in v3: - fixed bpf_test module not being able to be removed, because the bpf_wq was never freed - Link to v2: https://lore.kernel.org/r/20240430-bpf-next-v2-0

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

2024-04-30 Thread Benjamin Tissoires
On Apr 30 2024, 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 (

[PATCH v2 3/3] selftests/bpf: drop an unused local variable

2024-04-30 Thread Benjamin Tissoires
Some copy/paste leftover, this is never used Fixes: e3d9eac99afd ("selftests/bpf: wq: add bpf_wq_init() checks") Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/bpf/prog_tests/wq.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/testing

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

2024-04-30 Thread Benjamin Tissoires
t;) Signed-off-by: Benjamin Tissoires --- changes in v2: - fix wq being not freed (and static call not used) --- kernel/bpf/hashtab.c | 49 + 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hasht

[PATCH v2 1/3] bpf: do not walk twice the map on free

2024-04-30 Thread Benjamin Tissoires
Signed-off-by: Benjamin Tissoires --- no changes in v2 --- kernel/bpf/arraymap.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index 580d07b15471..feabc0193852 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c

[PATCH v2 0/3] bpf_wq followup series

2024-04-30 Thread Benjamin Tissoires
Few patches that should have been there from day 1. Anyway, they are coming now. Signed-off-by: Benjamin Tissoires --- Changes in v2: - fix wq in hashtabs not being freed (and static call not being used) - Link to v1: https://lore.kernel.org/r/20240425-bpf-next-v1-0-1d8330e6c...@kernel.org

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

2024-04-30 Thread Benjamin Tissoires
On Apr 25 2024, Alexei Starovoitov wrote: > 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_timer

[PATCH 3/3] selftests/bpf: drop an unused local variable

2024-04-25 Thread Benjamin Tissoires
Some copy/paste leftover, this is never used Fixes: e3d9eac99afd ("selftests/bpf: wq: add bpf_wq_init() checks") Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/bpf/prog_tests/wq.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tes

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

2024-04-25 Thread Benjamin Tissoires
t;) Signed-off-by: Benjamin Tissoires --- kernel/bpf/hashtab.c | 16 +--- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c index 0179183c543a..20162ae741e9 100644 --- a/kernel/bpf/hashtab.c +++ b/kernel/bpf/hashtab.c @@ -1515

[PATCH 1/3] bpf: do not walk twice the map on free

2024-04-25 Thread Benjamin Tissoires
Signed-off-by: Benjamin Tissoires --- kernel/bpf/arraymap.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index 580d07b15471..feabc0193852 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -436,13 +436,14 @@ s

[PATCH 0/3] bpf_wq followup series

2024-04-25 Thread Benjamin Tissoires
Few patches that should have been there from day 1. Anyway, they are coming now. Signed-off-by: Benjamin Tissoires --- Benjamin Tissoires (3): bpf: do not walk twice the map on free bpf: do not walk twice the hash map on free selftests/bpf: drop an unused local variable

Re: [PATCH bpf-next v2 12/16] selftests/bpf: wq: add bpf_wq_init() checks

2024-04-25 Thread Benjamin Tissoires
On Apr 24 2024, Andrii Nakryiko wrote: > On Sat, Apr 20, 2024 at 2:10 AM Benjamin Tissoires wrote: > > > > Allows to test if allocation/free works > > > > Signed-off-by: Benjamin Tissoires > > > > --- > > > > changes in v2: > > - dropped

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

2024-04-25 Thread Benjamin Tissoires
On Apr 24 2024, Alexei Starovoitov wrote: > 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 >

[PATCH bpf-next v2 16/16] selftests/bpf: wq: add bpf_wq_start() checks

2024-04-20 Thread Benjamin Tissoires
Allows to test if allocation/free works Signed-off-by: Benjamin Tissoires --- changes in v2: - remove #define CLOCK_MONOTONIC 1 leftover --- tools/testing/selftests/bpf/bpf_experimental.h | 1 + tools/testing/selftests/bpf/prog_tests/wq.c| 22 ++ tools/testing

[PATCH bpf-next v2 15/16] bpf: add bpf_wq_start

2024-04-20 Thread Benjamin Tissoires
again, copy/paste from bpf_timer_start(). Signed-off-by: Benjamin Tissoires --- changes in v2: - dropped spinlock and use READ_ONCE() instead --- kernel/bpf/helpers.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index

[PATCH bpf-next v2 14/16] selftests/bpf: add checks for bpf_wq_set_callback()

2024-04-20 Thread Benjamin Tissoires
We assign the callback and set everything up. The actual tests of these callbacks will be done when bpf_wq_start() is available. Signed-off-by: Benjamin Tissoires --- changes in v2: - removed mark_precise checks - adapted without BPF_F_WQ_SLEEPABLE --- tools/testing/selftests/bpf

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

2024-04-20 Thread Benjamin Tissoires
To support sleepable async callbacks, we need to tell push_async_cb() whether the cb is sleepable or not. The verifier now detects that we are in bpf_wq_set_callback_impl and can allow a sleepable callback to happen. Signed-off-by: Benjamin Tissoires --- changes in v2: - dropped flags check

[PATCH bpf-next v2 12/16] selftests/bpf: wq: add bpf_wq_init() checks

2024-04-20 Thread Benjamin Tissoires
Allows to test if allocation/free works Signed-off-by: Benjamin Tissoires --- changes in v2: - dropped mark_precise checks --- tools/testing/selftests/bpf/bpf_experimental.h | 1 + tools/testing/selftests/bpf/prog_tests/wq.c | 8 +++ tools/testing/selftests/bpf/progs/wq.c | 10

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

2024-04-20 Thread Benjamin Tissoires
. We also need to duplicate the timer code for the checking if the map argument is matching the provided workqueue. Signed-off-by: Benjamin Tissoires --- FWIW, I still have one concern with this implementation: - bpf_wq_work() access ->prog without protection, but I think this might be rac

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

2024-04-20 Thread Benjamin Tissoires
We simply try in all supported map types if we can store/load a bpf_wq. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/bpf/prog_tests/wq.c | 11 +++ tools/testing/selftests/bpf/progs/wq.c | 135 2 files changed, 146

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

2024-04-20 Thread Benjamin Tissoires
Currently bpf_wq_cancel_and_free() is just a placeholder as there is no memory allocation for bpf_wq just yet. Again, duplication of the bpf_timer approach Signed-off-by: Benjamin Tissoires --- changes in v2: - removed extra fallthrough --- include/linux/bpf.h | 2 ++ kernel/bpf

[PATCH bpf-next v2 08/16] bpf: add support for KF_ARG_PTR_TO_WORKQUEUE

2024-04-20 Thread Benjamin Tissoires
. Signed-off-by: Benjamin Tissoires --- changes in v2: - clean up already done checks in process_wq_func() - adjust comment - gate check_kfunc_args check with map->record->wq_off. --- kernel/bpf/verifier.c | 65 +++ 1 file changed, 65 inse

[PATCH bpf-next v2 07/16] bpf: verifier: bail out if the argument is not a map

2024-04-20 Thread Benjamin Tissoires
When a kfunc is declared with a KF_ARG_PTR_TO_MAP, we should have reg->map_ptr set to a non NULL value, otherwise, that means that the underlying type is not a map. Signed-off-by: Benjamin Tissoires --- new in v2 --- kernel/bpf/verifier.c | 5 + 1 file changed, 5 insertions(+) diff --

[PATCH bpf-next v2 06/16] tools: sync include/uapi/linux/bpf.h

2024-04-20 Thread Benjamin Tissoires
cp include/uapi/linux/bpf.h tools/include/uapi/linux/bpf.h Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/include/uapi/linux/bpf.h | 4 1 file changed, 4 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index cee0a7915c08

[PATCH bpf-next v2 05/16] bpf: add support for bpf_wq user type

2024-04-20 Thread Benjamin Tissoires
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 --- no changes in v2 --- include/linux/bpf.h | 11 ++- include/uapi/linux/bpf.h | 4 kernel/bpf/btf.c | 17

[PATCH bpf-next v2 04/16] bpf: replace bpf_timer_cancel_and_free with a generic helper

2024-04-20 Thread Benjamin Tissoires
Same reason than most bpf_timer* functions, we need almost the same for workqueues. So extract the generic part out of it so bpf_wq_cancel_and_free can reuse it. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- kernel/bpf/helpers.c | 42 +- 1

[PATCH bpf-next v2 03/16] bpf: replace bpf_timer_set_callback with a generic helper

2024-04-20 Thread Benjamin Tissoires
In the same way we have a generic __bpf_async_init(), we also need to share code between timer and workqueue for the set_callback call. We just add an unused flags parameter, as it will be used for workqueues. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- kernel/bpf/helpers.c

[PATCH bpf-next v2 02/16] bpf: replace bpf_timer_init with a generic helper

2024-04-20 Thread Benjamin Tissoires
No code change except for the new flags argument being stored in the local data struct. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- kernel/bpf/helpers.c | 91 1 file changed, 63 insertions(+), 28 deletions(-) diff --git

[PATCH bpf-next v2 01/16] bpf: make timer data struct more generic

2024-04-20 Thread Benjamin Tissoires
changed. Everything related to async callback is now on top of bpf_hrtimer. Signed-off-by: Benjamin Tissoires --- no changes in v2 --- kernel/bpf/helpers.c | 71 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/kernel/bpf

[PATCH bpf-next v2 00/16] Introduce bpf_wq

2024-04-20 Thread Benjamin Tissoires
ann To: Andrii Nakryiko To: Martin KaFai Lau To: Eduard Zingerman To: Song Liu To: Yonghong Song To: John Fastabend To: KP Singh To: Stanislav Fomichev To: Hao Luo To: Jiri Olsa To: Mykola Lysenko To: Shuah Khan Cc: Cc: Cc: Signed-off-by: Benjamin Tissoires [0] https://lore.kernel.org/

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

2024-04-19 Thread Benjamin Tissoires
On Apr 19 2024, Alexei Starovoitov wrote: > 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 > >

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

2024-04-19 Thread Benjamin Tissoires
On Apr 19 2024, Alexei Starovoitov wrote: > 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

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

2024-04-19 Thread Benjamin Tissoires
On Apr 18 2024, Alexei Starovoitov wrote: > 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 +++

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

2024-04-19 Thread Benjamin Tissoires
On Apr 18 2024, Alexei Starovoitov wrote: > 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 > >

Re: [PATCH bpf-next 16/18] selftests/bpf: add checks for bpf_wq_set_callback()

2024-04-18 Thread Benjamin Tissoires
On Thu, Apr 18, 2024 at 5:25 AM Song Liu wrote: > > On Tue, Apr 16, 2024 at 7:11 AM Benjamin Tissoires wrote: > [...] > > > +SEC("?tc") > > +__log_level(2) > > +__failure > > +/* check that the first argument of bpf_wq_set_callback() > >

[PATCH bpf-next 18/18] selftests/bpf: wq: add bpf_wq_start() checks

2024-04-16 Thread Benjamin Tissoires
Allows to test if allocation/free works Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/bpf/bpf_experimental.h | 1 + tools/testing/selftests/bpf/prog_tests/wq.c| 22 ++ tools/testing/selftests/bpf/progs/wq.c | 22 +++--- 3 files

  1   2   3   >