On 2026/7/1 下午2:21, Leon Hwang wrote:
On 1/7/26 09:26, Tiezhu Yang wrote:
[...]

Hi all,

Alexei said in another thread like this:

```
[3] https://lore.kernel.org/bpf/20260615025316.24429-1-
[email protected]/

I don't think we need such fallback in patch [3].
```
https://lore.kernel.org/bpf/[email protected]/

Should I just drop my previous patch? To be honest, I'm not sure how to
solve the issue mentioned in it. Is that a real problem, and does it
need to be fixed? What is the next step?


It is a real issue.

Instead of fixing up helper calls, it seems better to prevent
interpreter fallback if the prog has any JIT-inlineable helper call.

Hi Alexei and Leon,

What about the following: (not tested yet, if it is good, I can test it)

----->8-----
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 649cce41e13f..806e1ec85ff4 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -2608,6 +2608,19 @@ static struct bpf_prog *bpf_prog_jit_compile(struct bpf_verifier_env *env, struc
        return prog;
 }

+static bool bpf_prog_has_inline_helpers(const struct bpf_prog *fp)
+{
+       struct bpf_insn *insn = fp->insnsi;
+       int i;
+
+       for (i = 0; i < fp->len; i++, insn++) {
+ if (bpf_helper_call(insn) && bpf_jit_inlines_helper_call(insn->imm))
+                       return true;
+       }
+
+       return false;
+}
+
struct bpf_prog *__bpf_prog_select_runtime(struct bpf_verifier_env *env, struct bpf_prog *fp,
                                           int *err)
 {
@@ -2620,7 +2633,8 @@ struct bpf_prog *__bpf_prog_select_runtime(struct bpf_verifier_env *env, struct
                goto finalize;

        if (IS_ENABLED(CONFIG_BPF_JIT_ALWAYS_ON) ||
-           bpf_prog_has_kfunc_call(fp))
+           bpf_prog_has_kfunc_call(fp) ||
+           bpf_prog_has_inline_helpers(fp))
                jit_needed = true;

        if (!bpf_prog_select_interpreter(fp))
----->8-----

If you are OK with the above changes, I will test it again and send
a new version later.

Thanks,
Tiezhu


Reply via email to