From: Mark Rutland <mark.rutland@arm.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: "Liao, Chang" <liaochang1@huawei.com>,
catalin.marinas@arm.com, will@kernel.org, mhiramat@kernel.org,
oleg@redhat.com, peterz@infradead.org, puranjay@kernel.org,
ast@kernel.org, andrii@kernel.org, xukuohai@huawei.com,
revest@chromium.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH] arm64: insn: Simulate nop and push instruction for better uprobe performance
Date: Mon, 9 Sep 2024 11:18:01 +0100 [thread overview]
Message-ID: <Zt7LWaoZ0PTFqVLF@J2N7QTR9R3> (raw)
In-Reply-To: <CAEf4BzYn3EkVVk4dnWMBMKa16y_ZFvQp3ZcdM44a2LeS08S6FQ@mail.gmail.com>
On Fri, Sep 06, 2024 at 10:46:00AM -0700, Andrii Nakryiko wrote:
> On Fri, Sep 6, 2024 at 2:39 AM Mark Rutland <mark.rutland@arm.com> wrote:
> >
> > On Tue, Aug 27, 2024 at 07:33:55PM +0800, Liao, Chang wrote:
> > > Hi, Mark
> > >
> > > Would you like to discuss this patch further, or do you still believe emulating
> > > STP to push FP/LR into the stack in kernel is not a good idea?
> >
> > I'm happy with the NOP emulation in principle, so please send a new
> > version with *just* the NOP emulation, and I can review that.
>
> Let's definitely start with that, this is important for faster USDT tracing.
>
> > Regarding STP emulation, I stand by my earlier comments, and in addition
> > to those comments, AFAICT it's currently unsafe to use any uaccess
> > routine in the uprobe BRK handler anyway, so that's moot. The uprobe BRK
> > handler runs with preemption disabled and IRQs (and all other maskable
> > exceptions) masked, and faults cannot be handled. IIUC
> > CONFIG_DEBUG_ATOMIC_SLEEP should scream about that.
>
> This part I don't really get, and this might be some very
> ARM64-specific issue, so I'm sorry ahead of time.
>
> But in general, at the lowest level uprobes work in two logical steps.
> First, there is a breakpoint that user space hits, kernel gets
> control, and if VMA which hit breakpoint might contain uprobe, kernel
> sets TIF_UPROBE thread flag and exits. This is the only part that's in
> hard IRQ context. See uprobe_notify_resume() and comments around it.
>
> Then uprobe infrastructure gets called in user context on the way back
> to user space. This is where we confirm that this is uprobe/uretprobe
> hit, and, if supported, perform instruction emulation.
>
> So I'm wondering if your above comment refers to instruction emulation
> within the first part of uprobe handling? If yes, then, no, that's not
> where emulation will happen.
You're right -- I had misunderstood that the emulation happened during
handling of the breakpoint, rather than on the return-to-userspace path.
Looking at the arm64 entry code, the way uprobe_notify_resume() is
plumbed in is safe as it happens after we've re-enabled preemption and
unmasked other exceptions.
Sorry about that.
For the moment I'd still prefer to get the NOP case out of the way
first, so I'll review the NOP-only patch shortly.
Mark.
next prev parent reply other threads:[~2024-09-09 10:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 8:03 [PATCH] arm64: insn: Simulate nop and push instruction for better uprobe performance Liao Chang
2024-08-15 9:58 ` Mark Rutland
2024-08-15 17:07 ` Andrii Nakryiko
2024-08-21 7:55 ` Liao, Chang
2024-08-27 11:33 ` Liao, Chang
2024-08-29 19:26 ` Andrii Nakryiko
2024-08-30 9:25 ` Liao, Chang
2024-09-05 20:17 ` Andrii Nakryiko
2024-09-09 7:40 ` Liao, Chang
2024-09-06 9:39 ` Mark Rutland
2024-09-06 17:46 ` Andrii Nakryiko
2024-09-09 7:24 ` Liao, Chang
2024-09-09 10:18 ` Mark Rutland [this message]
2024-09-09 16:57 ` Andrii Nakryiko
2024-09-09 7:42 ` Liao, Chang
2024-09-10 6:36 ` Liao, Chang
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=Zt7LWaoZ0PTFqVLF@J2N7QTR9R3 \
--to=mark.rutland@arm.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=catalin.marinas@arm.com \
--cc=liaochang1@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=puranjay@kernel.org \
--cc=revest@chromium.org \
--cc=will@kernel.org \
--cc=xukuohai@huawei.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