[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzaOSAW6cQ3DYK-WJCFs-cW8+ayt5Qk9cBJ=VRXzi81htg@mail.gmail.com>
Date: Fri, 13 Dec 2024 13:59:49 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Jiri Olsa <olsajiri@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Oleg Nesterov <oleg@...hat.com>,
Andrii Nakryiko <andrii@...nel.org>, bpf@...r.kernel.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>, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH bpf-next 00/13] uprobes: Add support to optimize usdt
probes on x86_64
On Fri, Dec 13, 2024 at 1:52 PM Jiri Olsa <olsajiri@...il.com> wrote:
>
> On Fri, Dec 13, 2024 at 07:39:54PM +0100, Peter Zijlstra wrote:
> > On Fri, Dec 13, 2024 at 03:05:54PM +0100, Jiri Olsa wrote:
> > > On Fri, Dec 13, 2024 at 02:54:33PM +0100, Peter Zijlstra wrote:
> > > > On Fri, Dec 13, 2024 at 02:07:54PM +0100, Jiri Olsa wrote:
> > > > > On Fri, Dec 13, 2024 at 11:51:05AM +0100, Peter Zijlstra wrote:
> > > > > > On Wed, Dec 11, 2024 at 02:33:49PM +0100, Jiri Olsa wrote:
> > > > > > > hi,
> > > > > > > this patchset adds support to optimize usdt probes on top of 5-byte
> > > > > > > nop instruction.
> > > > > > >
> > > > > > > The generic approach (optimize all uprobes) is hard due to emulating
> > > > > > > possible multiple original instructions and its related issues. The
> > > > > > > usdt case, which stores 5-byte nop seems much easier, so starting
> > > > > > > with that.
> > > > > > >
> > > > > > > The basic idea is to replace breakpoint exception with syscall which
> > > > > > > is faster on x86_64. For more details please see changelog of patch 8.
> > > > > >
> > > > > > So ideally we'd put a check in the syscall, which verifies it comes from
> > > > > > one of our trampolines and reject any and all other usage.
> > > > > >
> > > > > > The reason to do this is that we can then delete all this code the
> > > > > > moment it becomes irrelevant without having to worry userspace might be
> > > > > > 'creative' somewhere.
> > > > >
> > > > > yes, we do that already in SYSCALL_DEFINE0(uprobe):
> > > > >
> > > > > /* Allow execution only from uprobe trampolines. */
> > > > > vma = vma_lookup(current->mm, regs->ip);
> > > > > if (!vma || vma->vm_private_data != (void *) &tramp_mapping) {
> > > > > force_sig(SIGILL);
> > > > > return -1;
> > > > > }
> > > >
> > > > Ah, right I missed that. Doesn't that need more locking through? The
> > > > moment vma_lookup() returns that vma can go bad.
> > >
> > > ugh yes.. I guess mmap_read_lock(current->mm) should do, will check
> >
> > If you check
> > tip/perf/core:kernel/events/uprobe.c:find_active_uprobe_speculative()
> > you'll find means of doing it locklessly using RCU.
>
> right, will use that
phew, yep, came here to ask not to add mmap_read_lock() into the hot
path again :)
>
> thanks,
> jirka
Powered by blists - more mailing lists