On Thu, Jul 29, 2021 at 2:55 AM Yonghong Song <yhs@xxxxxx> wrote: > > +static int bpf_fill_long_jmp(struct bpf_test *self) > > +{ > > + unsigned int len = BPF_MAXINSNS; > > BPF_MAXINSNS is 4096 as defined in uapi/linux/bpf_common.h. > Will it be able to trigger a PC relative branch + long > conditional jump? It does, on the MIPS32 JIT. The ALU64 MUL instruction with a large immediate was chosen since it expands to a lot of MIPS32 instructions: 2 to load the immediate, 1 to zero/sign extend it, and then 9 for the 64x64 multiply. Other JITs will be different of course. On the other hand, other architectures have other limitations that this test may not trigger anyway. I added the test because I was implementing a non-trivial iterative branch conversion logic in the MIPS32 JIT. One can argue that when such complex JIT mechanisms are added, the test suite should also be updated to cover that, especially if the mechanism handles something that almost never occur in practice. Since I was able to trigger the branch conversion with BPF_MAXINSNS instructions, and no other test was using more, I left it at that. However, should I or someone else work on the MIPS64 JIT, I think updating the test suite so that similar special cases there are triggered would be a valuable contribution.