[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzbN4Li2iesQm28ZYEV2nXsLre8_qknmvkSy510EV7h=SA@mail.gmail.com>
Date: Thu, 20 Jun 2024 12:00:55 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Jiri Olsa <jolsa@...nel.org>
Cc: Steven Rostedt <rostedt@...dmis.org>, Masami Hiramatsu <mhiramat@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>, Oleg Nesterov <oleg@...hat.com>,
Nathan Chancellor <nathan@...nel.org>, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH] uprobe: Do not use UPROBE_SWBP_INSN as static initializer
On Tue, Jun 18, 2024 at 12:43 PM Jiri Olsa <jolsa@...nel.org> wrote:
>
> Nathan reported compilation fail for loongarch arch:
>
> kernel/events/uprobes.c: In function 'arch_uprobe_trampoline':
> arch/loongarch/include/asm/uprobes.h:12:33: error: initializer element is not constant
> 12 | #define UPROBE_SWBP_INSN larch_insn_gen_break(BRK_UPROBE_BP)
> | ^~~~~~~~~~~~~~~~~~~~
> kernel/events/uprobes.c:1479:39: note: in expansion of macro 'UPROBE_SWBP_INSN'
> 1479 | static uprobe_opcode_t insn = UPROBE_SWBP_INSN;
>
> Loongarch defines UPROBE_SWBP_INSN as function call, so we can't
> use it to initialize static variable.
>
> Cc: Oleg Nesterov <oleg@...hat.com>
> Fixes: ff474a78cef5 ("uprobe: Add uretprobe syscall to speed up return probe")
> Reported-by: Nathan Chancellor <nathan@...nel.org>
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> ---
> kernel/events/uprobes.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
Can we instead ask loongarch folks to rewrite it to be a constant?
Having this as a function call is both an inconvenience and potential
performance problem (a minor one, but still). I would imagine it's not
hard to hard-code an instruction as a constant here.
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 2816e65729ac..6986bd993702 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -1476,8 +1476,9 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
>
> void * __weak arch_uprobe_trampoline(unsigned long *psize)
> {
> - static uprobe_opcode_t insn = UPROBE_SWBP_INSN;
> + static uprobe_opcode_t insn;
>
> + insn = insn ?: UPROBE_SWBP_INSN;
> *psize = UPROBE_SWBP_INSN_SIZE;
> return &insn;
> }
> --
> 2.45.1
>
Powered by blists - more mailing lists