On Mon, 18 Nov 2019 at 20:36, Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> wrote: > [...] > > + sort(&ips[0], num_progs, sizeof(ips[i]), cmp_ips, NULL); > > nit: sizeof(ips[i]) looks weird... > Ick! Thanks for spotting. > > + return emit_bpf_dispatcher(&prog, 0, num_progs - 1, &ips[0], fallback); > > +} > > + > > struct x64_jit_data { > > struct bpf_binary_header *header; > > int *addrs; > > [...] > > > + > > +static int bpf_dispatcher_add_prog(struct bpf_dispatcher *d, > > + struct bpf_prog *prog) > > +{ > > + struct bpf_prog **entry = NULL; > > + int i, err = 0; > > + > > + if (d->num_progs == BPF_DISPATCHER_MAX) > > + return err; > > err == 0, not what you want, probably > No, the error handling in this RFC is bad. I'll fix that in the patch proper! [...] > > +static void bpf_dispatcher_remove_prog(struct bpf_dispatcher *d, > > + struct bpf_prog *prog) > > +{ > > + int i; > > + > > + for (i = 0; i < BPF_DISPATCHER_MAX; i++) { > > + if (d->progs[i] == prog) { > > + bpf_prog_put(prog); > > + d->progs[i] = NULL; > > + d->num_progs--; > > instead of allowing holes, why not swap removed prog with the last on > in d->progs? > Yeah, holes is a no go. I'll redo that. [...] > > + > > + WARN_ON(bpf_dispatcher_update(d)); > > shouldn't dispatcher be removed from the list before freed? It seems > like handling dispatches freeing is better done here explicitly (and > you won't need to leave a NB remark) > I agree. Let's make that explicit. I'll send out a patch proper in a day or two. Thanks for looking at the code, Andrii! Björn