Re: [PATCH bpf v2 1/2] bpf: Skip detached progs in trampoline images that are still in use

From: Alexei Starovoitov

Date: Sat Sep 12 2026 - 12:50:28 EST


On Sat Sep 12, 2026 at 2:59 AM PDT, Florent Revest (Anthropic) wrote:
> +/*
> + * Each prog call in a trampoline image is preceded by a nop. When the prog is
> + * detached, the nop is patched to a jump to target, right after the call, so
> + * that tasks still running in the image skip the prog.
> + */
> +struct bpf_tramp_skip {
> + struct bpf_prog *prog;

prog pointer shouldn't be necessary.

> + void *nop;
> + void *target;
> +};
> +
> struct bpf_tramp_image {
> void *image;
> int size;
> @@ -1374,8 +1389,27 @@ struct bpf_tramp_image {
> struct rcu_head rcu;
> struct work_struct work;
> };
> + /* entry in tr->images, the image holds a reference on tr */
> + struct bpf_trampoline *tr;
> + struct list_head list;
> + struct bpf_tramp_skip *skips;
> + int nr_skips;

I don't follow why you need link list and 'tr' pointer here.
Also why keep ip_after_call ?

Replace ip_after_call with array of bpf_tramp_skip { void *nop, *target; }
and then in bpf_tramp_image_put() instead of ip_after_call do:
for (i = 0; i < im->nr_skips; i++) {
struct bpf_tramp_skip *skip = &im->skips[i];

err = bpf_arch_text_poke(skip->nop, BPF_MOD_NOP, BPF_MOD_JUMP,
NULL, skip->target);
}

what am I missing?