On Fri, Jun 10, 2022 at 4:21 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > > On Fri, 2022-06-10 at 16:01 -0700, Song Liu wrote: > > > > In this case, we need to initialize fit_for_inline to true, no? > > You are right... > > My Last try is below, if you don't like it I'll proceed with your > version. I just really don't like the "not-cannot" part in the > expression "!inline_state->cannot_inline" :) Yeah, this version looks good to me. Thanks, Song > > static void update_loop_inline_state(struct bpf_verifier_env *env, u32 subprogno) > { > struct bpf_loop_inline_state *state = &cur_aux(env)->loop_inline_state; > struct bpf_reg_state *regs = cur_regs(env); > struct bpf_reg_state *flags_reg = ®s[BPF_REG_4]; > int flags_is_zero = > register_is_const(flags_reg) && flags_reg->var_off.value == 0; > > if (!state->initialized) { > state->initialized = 1; > state->fit_for_inline = flags_is_zero; > state->callback_subprogno = subprogno; > return; > } > > if (!state->fit_for_inline) > return; > > state->fit_for_inline = > flags_is_zero && > state->callback_subprogno == subprogno; > } > > static int optimize_bpf_loop(struct bpf_verifier_env *env) > { > // ... > if (is_bpf_loop_call(insn) && inline_state->fit_for_inline) { ... } > // ... > } > > Thanks, > Eduard >