From: Nathan Chancellor <nathan@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-api@vger.kernel.org, linux-man@vger.kernel.org,
x86@kernel.org, bpf@vger.kernel.org,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
Ingo Molnar <mingo@redhat.com>, Andy Lutomirski <luto@kernel.org>,
"Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
Deepak Gupta <debug@rivosinc.com>,
Huacai Chen <chenhuacai@kernel.org>,
loongarch@lists.linux.dev
Subject: Re: [PATCHv8 bpf-next 3/9] uprobe: Add uretprobe syscall to speed up return probe
Date: Fri, 14 Jun 2024 10:48:22 -0700 [thread overview]
Message-ID: <20240614174822.GA1185149@thelio-3990X> (raw)
In-Reply-To: <20240611112158.40795-4-jolsa@kernel.org>
Hi Jiri,
On Tue, Jun 11, 2024 at 01:21:52PM +0200, Jiri Olsa wrote:
> Adding uretprobe syscall instead of trap to speed up return probe.
...
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 2c83ba776fc7..2816e65729ac 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -1474,11 +1474,20 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
> return ret;
> }
>
> +void * __weak arch_uprobe_trampoline(unsigned long *psize)
> +{
> + static uprobe_opcode_t insn = UPROBE_SWBP_INSN;
This change as commit ff474a78cef5 ("uprobe: Add uretprobe syscall to
speed up return probe") in -next causes the following build error for
ARCH=loongarch allmodconfig:
In file included from include/linux/uprobes.h:49,
from include/linux/mm_types.h:16,
from include/linux/mmzone.h:22,
from include/linux/gfp.h:7,
from include/linux/xarray.h:16,
from include/linux/list_lru.h:14,
from include/linux/fs.h:13,
from include/linux/highmem.h:5,
from kernel/events/uprobes.c:13:
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;
| ^~~~~~~~~~~~~~~~
> + *psize = UPROBE_SWBP_INSN_SIZE;
> + return &insn;
> +}
> +
> static struct xol_area *__create_xol_area(unsigned long vaddr)
> {
> struct mm_struct *mm = current->mm;
> - uprobe_opcode_t insn = UPROBE_SWBP_INSN;
> + unsigned long insns_size;
> struct xol_area *area;
> + void *insns;
>
> area = kmalloc(sizeof(*area), GFP_KERNEL);
> if (unlikely(!area))
> @@ -1502,7 +1511,8 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
> /* Reserve the 1st slot for get_trampoline_vaddr() */
> set_bit(0, area->bitmap);
> atomic_set(&area->slot_count, 1);
> - arch_uprobe_copy_ixol(area->pages[0], 0, &insn, UPROBE_SWBP_INSN_SIZE);
> + insns = arch_uprobe_trampoline(&insns_size);
> + arch_uprobe_copy_ixol(area->pages[0], 0, insns, insns_size);
>
> if (!xol_add_vma(mm, area))
> return area;
> @@ -1827,7 +1837,7 @@ void uprobe_copy_process(struct task_struct *t, unsigned long flags)
> *
> * Returns -1 in case the xol_area is not allocated.
> */
> -static unsigned long get_trampoline_vaddr(void)
> +unsigned long uprobe_get_trampoline_vaddr(void)
> {
> struct xol_area *area;
> unsigned long trampoline_vaddr = -1;
> @@ -1878,7 +1888,7 @@ static void prepare_uretprobe(struct uprobe *uprobe, struct pt_regs *regs)
> if (!ri)
> return;
>
> - trampoline_vaddr = get_trampoline_vaddr();
> + trampoline_vaddr = uprobe_get_trampoline_vaddr();
> orig_ret_vaddr = arch_uretprobe_hijack_return_addr(trampoline_vaddr, regs);
> if (orig_ret_vaddr == -1)
> goto fail;
> @@ -2123,7 +2133,7 @@ static struct return_instance *find_next_ret_chain(struct return_instance *ri)
> return ri;
> }
>
> -static void handle_trampoline(struct pt_regs *regs)
> +void uprobe_handle_trampoline(struct pt_regs *regs)
> {
> struct uprobe_task *utask;
> struct return_instance *ri, *next;
> @@ -2187,8 +2197,8 @@ static void handle_swbp(struct pt_regs *regs)
> int is_swbp;
>
> bp_vaddr = uprobe_get_swbp_addr(regs);
> - if (bp_vaddr == get_trampoline_vaddr())
> - return handle_trampoline(regs);
> + if (bp_vaddr == uprobe_get_trampoline_vaddr())
> + return uprobe_handle_trampoline(regs);
>
> uprobe = find_active_uprobe(bp_vaddr, &is_swbp);
> if (!uprobe) {
> --
> 2.45.1
>
Cheers,
Nathan
next prev parent reply other threads:[~2024-06-14 17:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-11 11:21 [PATCHv8 bpf-next 0/9] uprobe: uretprobe speed up Jiri Olsa
2024-06-11 11:21 ` [PATCHv8 bpf-next 1/9] x86/shstk: Make return uprobe work with shadow stack Jiri Olsa
2024-06-11 11:21 ` [PATCHv8 bpf-next 2/9] uprobe: Wire up uretprobe system call Jiri Olsa
2024-06-11 11:21 ` [PATCHv8 bpf-next 3/9] uprobe: Add uretprobe syscall to speed up return probe Jiri Olsa
2024-06-14 17:48 ` Nathan Chancellor [this message]
2024-06-14 19:26 ` Jiri Olsa
2024-06-14 20:07 ` Nathan Chancellor
2024-06-20 18:19 ` Guenter Roeck
2024-06-20 18:52 ` Oleg Nesterov
2024-06-11 11:21 ` [PATCHv8 bpf-next 4/9] selftests/x86: Add return uprobe shadow stack test Jiri Olsa
2024-06-11 11:21 ` [PATCHv8 bpf-next 5/9] selftests/bpf: Add uretprobe syscall test for regs integrity Jiri Olsa
2024-06-11 11:21 ` [PATCHv8 bpf-next 6/9] selftests/bpf: Add uretprobe syscall test for regs changes Jiri Olsa
2024-06-11 11:21 ` [PATCHv8 bpf-next 7/9] selftests/bpf: Add uretprobe syscall call from user space test Jiri Olsa
2024-06-11 11:21 ` [PATCHv8 bpf-next 8/9] selftests/bpf: Add uretprobe shadow stack test Jiri Olsa
2024-06-11 11:21 ` [PATCHv8 9/9] man2: Add uretprobe syscall page Jiri Olsa
2024-06-11 14:30 ` Masami Hiramatsu
2024-06-11 14:49 ` Alejandro Colomar
2024-08-07 20:27 ` Steven Rostedt
2024-08-16 11:42 ` Alejandro Colomar
2024-08-16 17:03 ` Jiri Olsa
2024-08-16 18:55 ` Alejandro Colomar
2024-08-16 21:56 ` Alejandro Colomar
2024-08-17 8:58 ` Jiri Olsa
2024-06-11 14:52 ` [PATCHv8 bpf-next 0/9] uprobe: uretprobe speed up Masami Hiramatsu
2024-06-12 7:02 ` Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240614174822.GA1185149@thelio-3990X \
--to=nathan@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=daniel@iogearbox.net \
--cc=debug@rivosinc.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=luto@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).