From: Will Deacon <will@kernel.org>
To: John Garry <john.garry@huawei.com>
Cc: Leo Yan <leo.yan@linaro.org>, Marco Elver <elver@google.com>,
Thomas Richter <tmricht@linux.ibm.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
acme@kernel.org, svens@linux.ibm.com, gor@linux.ibm.com,
sumanthk@linux.ibm.com, hca@linux.ibm.com,
Mark Rutland <mark.rutland@arm.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
dvyukov@google.com
Subject: Re: Test 73 Sig_trap fails on arm64 (was Re: [PATCH] perf test: Test 73 Sig_trap fails on s390)
Date: Tue, 15 Feb 2022 14:35:00 +0000 [thread overview]
Message-ID: <20220215143459.GB7592@willie-the-truck> (raw)
In-Reply-To: <06412caf-42e4-5c4b-c9b3-9691075405bd@huawei.com>
On Tue, Feb 15, 2022 at 11:16:16AM +0000, John Garry wrote:
> On 24/01/2022 09:19, John Garry wrote:
>
> Hi Will,
>
> Have you had a chance to check this or the mail from Dmitry?
>
> https://lore.kernel.org/linux-perf-users/CACT4Y+YVyJcqbR5j2fsSQ+C5hy78X+aobrUHaZKghFf0_NMv=A@mail.gmail.com/
>
> If we can't make progress then we just need to skip the test on arm64 for
> now.
Sorry, I haven't had time to look at this (or the thousands of other mails
in my inbox) lately.
I don't recall all of the details, but basically hw_breakpoint really
doesn't work well on arm/arm64 -- the sticking points are around handling
the stepping and whether to step into or over exceptions. Sadly, our ptrace
interface (which is what is used by GDB) is built on top of hw_breakpoint,
so we can't just rip it out and any significant changes are pretty risky.
What I would like to happen is that we rework our debug exception handling
as outlined by [1] so that kernel debug is better defined and the ptrace
interface can interact directly with the debug architecture instead of being
funnelled through hw_breakpoint. Once we have that, I think we could try to
improve hw_breakpoint much more comfortably (or at least defeature it
considerably without having to worry about breaking GDB). I started this a
couple of years ago, but I haven't found time to get back to it for ages.
Anyway, to this specific test...
When we hit a break/watchpoint the faulting PC points at the instruction
which faulted and the exception is reported before the instruction has had
any other side-effects (e.g. if a watchpoint triggers on a store, then
memory will not have been updated when the watchpoint handler runs), so if
we were to return as usual after reporting the exception to perf then we
would just hit the same break/watchpoint again and we'd get stuck. GDB
handles stepping over the faulting instruction, but for perf (and assumedly
these tests), the kernel is expected to handle the step. This handling
amounts to disabling the break/watchpoint which we think we hit and then
attempting a hardware single-step. During the step we could run into more
break/watchpoints on the same instruction, so we'll keep disabling things
until we eventually manage to complete the step, which is signalled by a
specific type of debug exception. At this point, we re-enable the
break/watchpoints and we're good.
Signals make this messy, as the step logic will step _into_ the signal
handler -- we have to do this, otherwise we would miss break/watchpoints
triggered by the signal handler if we had disabled them for the step.
However, it means that when we return back from the signal handler we will
run back into the break/watchpoint which we initially stepped over. When
perf uses SIGTRAP to notify userspace that we hit a break/watchpoint,
then we'll get stuck because we'll step into the handler every time.
Hopefully that clears things up a bit. Ideally, the kernel wouldn't
pretend to handle this stepping at all for arm64 as it adds a bunch of
complexity, overhead to our context-switch and I don't think the current
behaviour is particularly useful.
Will
[1] https://lore.kernel.org/all/20200626095551.GA9312@willie-the-truck/
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-02-15 14:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211216151454.752066-1-tmricht@linux.ibm.com>
[not found] ` <CANpmjNNMWtjcKa961SjEvRbbPXyw5M5SkrXbb3tnyL3_XyniCw@mail.gmail.com>
2022-01-17 15:39 ` [PATCH] perf test: Test 73 Sig_trap fails on s390 John Garry
2022-01-18 9:18 ` Leo Yan
2022-01-18 10:20 ` John Garry
2022-01-18 11:18 ` Leo Yan
2022-01-18 11:40 ` Marco Elver
2022-01-18 12:43 ` Leo Yan
2022-01-24 9:19 ` Test 73 Sig_trap fails on arm64 (was Re: [PATCH] perf test: Test 73 Sig_trap fails on s390) John Garry
2022-01-31 17:55 ` Test 73 Sig_trap fails on arm64 Dmitry Vyukov
2022-02-01 10:03 ` Dmitry Vyukov
2022-02-15 11:16 ` Test 73 Sig_trap fails on arm64 (was Re: [PATCH] perf test: Test 73 Sig_trap fails on s390) John Garry
2022-02-15 14:35 ` Will Deacon [this message]
2022-02-16 11:46 ` John Garry
2022-02-16 11:54 ` Dmitry Vyukov
2022-02-16 13:13 ` Leo Yan
2022-02-17 9:53 ` John Garry
2022-02-17 11:04 ` Leo Yan
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=20220215143459.GB7592@willie-the-truck \
--to=will@kernel.org \
--cc=acme@kernel.org \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=john.garry@huawei.com \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=sumanthk@linux.ibm.com \
--cc=svens@linux.ibm.com \
--cc=tmricht@linux.ibm.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).