[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAADnVQLJGNq5SqwuNcqMCxg_YbxH8R+QOrzZZrZSyRk75_zt5g@mail.gmail.com>
Date: Wed, 6 Aug 2025 13:35:30 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Florian Lehner <dev@...-flo.net>
Cc: Yonghong Song <yonghong.song@...ux.dev>, bpf <bpf@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>, Eduard <eddyz87@...il.com>,
Song Liu <song@...nel.org>, John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, "David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>, Network Development <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf-next] bpf: Add LINK_DETACH for iter and perf links
On Wed, Aug 6, 2025 at 11:39 AM Florian Lehner <dev@...-flo.net> wrote:
>
> On Tue, Aug 05, 2025 at 02:07:20PM -0700, Yonghong Song wrote:
> >
> >
> > On 8/1/25 5:10 AM, Florian Lehner wrote:
> > > 73b11c2a introduced LINK_DETACH and implemented it for some link types,
> > > like xdp, netns and others.
> > >
> > > This patch implements LINK_DETACH for perf and iter links, re-using
> > > existing link release handling code.
> [..]
> > > static void bpf_iter_link_dealloc(struct bpf_link *link)
> > > {
> > > struct bpf_iter_link *iter_link =
> > > @@ -490,6 +496,7 @@ static int bpf_iter_link_fill_link_info(const struct bpf_link *link,
> > > static const struct bpf_link_ops bpf_iter_link_lops = {
> > > .release = bpf_iter_link_release,
> > > + .detach = bpf_iter_link_detach,
> >
> > Not sure how useful for this one. For bpf_iter programs,
> > the loaded prog will expect certain bpt_iter (e.g., bpf_map_elem, bpf_map, ...).
> > So even if you have detach, you won't be able to attach to a different
> > bpf_iter flavor.
> >
> > Do you have a use case for this one?
> >
>
> A key reason for adding this was to enable the temporary disabling and re-enabling of
> an attached BPF program while keeping the same bpf_iter flavor. If you don't think
> this is a strong enough use case, I'm open to removing this from the patch.
>
> > > static void bpf_perf_link_dealloc(struct bpf_link *link)
> > > {
> > > struct bpf_perf_link *perf_link = container_of(link, struct bpf_perf_link, link);
> > > @@ -4027,6 +4033,7 @@ static void bpf_perf_link_show_fdinfo(const struct bpf_link *link,
> > > static const struct bpf_link_ops bpf_perf_link_lops = {
> > > .release = bpf_perf_link_release,
> > > + .detach = bpf_perf_link_detach,
> >
> > This one may be possible. You might be able to e.g., try a different bpf_cookie, or
> > different perf event.
> >
>
> The primary use case for this feature is to allow for the temporary disabling of
> uprobes that are attached using bpf_perf_links.
I guess the use case makes sense, but pls provide
corresponding libbpf and selftest that demonstrates such usage.
--
pw-bot: cr
Powered by blists - more mailing lists