[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230115175950.xa75mmt6jhjhxgdq@MacBook-Pro-6.local>
Date: Sun, 15 Jan 2023 09:59:50 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Benjamin Tissoires <benjamin.tissoires@...hat.com>
Cc: Greg KH <gregkh@...uxfoundation.org>,
Jiri Kosina <jikos@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Tero Kristo <tero.kristo@...ux.intel.com>,
linux-kernel@...r.kernel.org, linux-input@...r.kernel.org,
netdev@...r.kernel.org, bpf@...r.kernel.org,
linux-kselftest@...r.kernel.org
Subject: Re: [PATCH HID for-next v2 6/9] HID: bpf: rework how programs are
attached and stored in the kernel
On Fri, Jan 13, 2023 at 10:09:32AM +0100, Benjamin Tissoires wrote:
> Previously, HID-BPF was relying on a bpf tracing program to be notified
> when a program was released from userspace. This is error prone, as
> LLVM sometimes inline the function and sometimes not.
>
> So instead of messing up with the bpf prog ref count, we can use the
> bpf_link concept which actually matches exactly what we want:
> - a bpf_link represents the fact that a given program is attached to a
> given HID device
> - as long as the bpf_link has fd opened (either by the userspace program
> still being around or by pinning the bpf object in the bpffs), the
> program stays attached to the HID device
> - once every user has closed the fd, we get called by
> hid_bpf_link_release() that we no longer have any users, and we can
> disconnect the program to the device in 2 passes: first atomically clear
> the bit saying that the link is active, and then calling release_work in
> a scheduled work item.
>
> This solves entirely the problems of BPF tracing not showing up and is
> definitely cleaner.
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@...hat.com>
Acked-by: Alexei Starovoitov <ast@...nel.org>
Powered by blists - more mailing lists