Re: [PATCH bpf-next v1 3/4] LoongArch: Add BPF JIT support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 08/22/2022 09:58 AM, Youling Tang wrote:
On 08/20/2022 07:50 PM, Tiezhu Yang wrote:
BPF programs are normally handled by a BPF interpreter, add BPF JIT
support for LoongArch to allow the kernel to generate native code
when a program is loaded into the kernel, this will significantly
speed-up processing of BPF programs.

[...]

+#define DEF_EMIT_REG1I20_FORMAT(NAME, OP)                \
+static inline void emit_##NAME(union loongarch_instruction *insn,    \
+                   enum loongarch_gpr rd, int imm)        \
+{                                    \
+    insn->reg1i20_format.opcode = OP;                \
+    insn->reg1i20_format.immediate = imm;                \
+    insn->reg1i20_format.rd = rd;                    \
+}
+
+DEF_EMIT_REG1I20_FORMAT(lu12iw, lu12iw_op)
+DEF_EMIT_REG1I20_FORMAT(lu32id, lu32id_op)

We can delete the larch_insn_gen_{lu32id, lu52id, jirl} functions in
inst.c and use emit_xxx.

The implementation of emit_plt_entry() is similarly modified as follows:
struct plt_entry {
        union loongarch_instruction lu12iw;
        union loongarch_instruction lu32id;
        union loongarch_instruction lu52id;
        union loongarch_instruction jirl;
};

static inline struct plt_entry emit_plt_entry(unsigned long val)
{
        union loongarch_instruction *lu12iw, *lu32id, *lu52id, *jirl;

        emit_lu32id(lu12iw, LOONGARCH_GPR_T1, ADDR_IMM(val, LU12IW));
        emit_lu32id(lu32id, LOONGARCH_GPR_T1, ADDR_IMM(val, LU32ID));
        emit_lu52id(lu52id, LOONGARCH_GPR_T1, LOONGARCH_GPR_T1,
ADDR_IMM(val, LU52ID));
        emit_jirl(jirl, LOONGARCH_GPR_T1, 0, (val & 0xfff) >> 2);

        return (struct plt_entry) { *lu12iw, *lu32id, *lu52id, *jirl };
}

Thanks,
Youling

Hi Youling,

Yes, this is the benefit we define the instructions in inst.h,
but these changes are not much related with this patch series,
I think we can do it after this patch series is merged.

Thanks,
Tiezhu




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux