On Tue, Nov 19, 2024 at 2:17 AM Anton Protopopov <aspsk@xxxxxxxxxxxxx> wrote: > > Move some inlined map/prog compatibility checks from the > resolve_pseudo_ldimm64() function to the dedicated > check_map_prog_compatibility() function. Call the latter function > from the add_used_map_from_fd() function directly. > > This simplifies code and optimizes logic a bit, as before these > changes the check_map_prog_compatibility() function was executed on > every map usage, which doesn't make sense, as it doesn't include any > per-instruction checks, only map type vs. prog type. > > (This patch also simplifies a consequent patch which will call the > add_used_map_from_fd() function from another code path.) > > Signed-off-by: Anton Protopopov <aspsk@xxxxxxxxxxxxx> > --- > kernel/bpf/verifier.c | 101 +++++++++++++++++++----------------------- > 1 file changed, 46 insertions(+), 55 deletions(-) > LGTM, I think this is a good improvement. As far as I can tell the laziness of all those checks are preserved and shouldn't interfere with the dead code elimination and CO-RE Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c > index 1c4ebb326785..8e034a22aa2a 100644 > --- a/kernel/bpf/verifier.c > +++ b/kernel/bpf/verifier.c > @@ -19064,6 +19064,12 @@ static bool is_tracing_prog_type(enum bpf_prog_type type) > } > } > [...]