Re: [PATCH v1 1/4] LoongArch: Move three functions from kprobes.c to inst.h
From: Xi Ruoyao
Date: Wed Apr 12 2023 - 06:39:19 EST
On Wed, 2023-04-12 at 18:04 +0800, Tiezhu Yang wrote:
> +static inline bool insns_not_supported(union loongarch_instruction insn)
This function seems long enough (to me) not to use "static inline".
Note that most part of this function belongs to a cold path, and IMO
it's bad to inline a cold path into every caller.
> +{
> + switch (insn.reg2i14_format.opcode) {
> + case llw_op:
> + case lld_op:
> + case scw_op:
> + case scd_op:
> + pr_notice("kprobe: ll and sc instructions are not supported\n");
> + return true;
> + }
> +
> + switch (insn.reg1i21_format.opcode) {
> + case bceqz_op:
> + pr_notice("kprobe: bceqz and bcnez instructions are not supported\n");
> + return true;
> + }
> +
> + return false;
> +}
> +
> +static inline bool insns_need_simulation(union loongarch_instruction insn)
> +{
> + if (is_pc_ins(&insn))
> + return true;
> +
> + if (is_branch_ins(&insn))
> + return true;
> +
> + return false;
I'd write "return is_pc_ins(&insn) || is_branch_ins(&insn);" here, but
there is no behavioral difference anyway.
> +}
--
Xi Ruoyao <xry111@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University