[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z_Ov4Eh_leCHMG0J@krava>
Date: Mon, 7 Apr 2025 12:58:40 +0200
From: Jiri Olsa <olsajiri@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Oleg Nesterov <oleg@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
Andrii Nakryiko <andrii@...nel.org>, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
x86@...nel.org, Song Liu <songliubraving@...com>,
Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
Hao Luo <haoluo@...gle.com>, Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Alan Maguire <alan.maguire@...cle.com>,
David Laight <David.Laight@...lab.com>,
Thomas Weißschuh <thomas@...ch.de>
Subject: Re: [PATCH RFCv3 08/23] uprobes/x86: Add uprobe syscall to speed up
uprobe
On Fri, Apr 04, 2025 at 01:33:07PM -0700, Andrii Nakryiko wrote:
> On Thu, Mar 20, 2025 at 4:43 AM Jiri Olsa <jolsa@...nel.org> wrote:
> >
> > Adding new uprobe syscall that calls uprobe handlers for given
> > 'breakpoint' address.
> >
> > The idea is that the 'breakpoint' address calls the user space
> > trampoline which executes the uprobe syscall.
> >
> > The syscall handler reads the return address of the initial call
> > to retrieve the original 'breakpoint' address. With this address
> > we find the related uprobe object and call its consumers.
> >
> > Adding the arch_uprobe_trampoline_mapping function that provides
> > uprobe trampoline mapping. This mapping is backed with one global
> > page initialized at __init time and shared by the all the mapping
> > instances.
> >
> > We do not allow to execute uprobe syscall if the caller is not
> > from uprobe trampoline mapping.
> >
> > The uprobe syscall ensures the consumer (bpf program) sees registers
> > values in the state before the trampoline was called.
> >
> > Signed-off-by: Jiri Olsa <jolsa@...nel.org>
> > ---
> > arch/x86/entry/syscalls/syscall_64.tbl | 1 +
> > arch/x86/kernel/uprobes.c | 134 +++++++++++++++++++++++++
> > include/linux/syscalls.h | 2 +
> > include/linux/uprobes.h | 1 +
> > kernel/events/uprobes.c | 22 ++++
> > kernel/sys_ni.c | 1 +
> > 6 files changed, 161 insertions(+)
> >
>
> [...]
>
> > +void handle_syscall_uprobe(struct pt_regs *regs, unsigned long bp_vaddr)
> > +{
> > + struct uprobe *uprobe;
> > + int is_swbp;
> > +
> > + rcu_read_lock_trace();
> > + uprobe = find_active_uprobe_rcu(bp_vaddr, &is_swbp);
> > + if (!uprobe)
> > + goto unlock;
> > +
> > + if (!get_utask())
> > + goto unlock;
> > +
> > + if (arch_uprobe_ignore(&uprobe->arch, regs))
> > + goto unlock;
> > +
> > + handler_chain(uprobe, regs);
> > +
> > + unlock:
> > + rcu_read_unlock_trace();
>
> we now have `guard(rcu_tasks_trace)();`, let's use that in this
> function, seems like a good fit?
yes, will use it
thanks,
jirka
>
>
> > +}
> > +
> > /*
> > * Perform required fix-ups and disable singlestep.
> > * Allow pending signals to take effect.
> > diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
> > index c00a86931f8c..bf5d05c635ff 100644
> > --- a/kernel/sys_ni.c
> > +++ b/kernel/sys_ni.c
> > @@ -392,3 +392,4 @@ COND_SYSCALL(setuid16);
> > COND_SYSCALL(rseq);
> >
> > COND_SYSCALL(uretprobe);
> > +COND_SYSCALL(uprobe);
> > --
> > 2.49.0
> >
Powered by blists - more mailing lists