From: Will Deacon <will@kernel.org>
To: Jiping Ma <Jiping.Ma2@windriver.com>
Cc: mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
catalin.marinas@arm.com, will.deacon@arm.com,
linux-kernel@vger.kernel.org, acme@kernel.org,
peterz@infradead.org, mingo@redhat.com, namhyung@kernel.org,
jolsa@redhat.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] Perf: support to unwind userspace application stacks generated with thumb.
Date: Wed, 22 Apr 2020 09:19:15 +0100 [thread overview]
Message-ID: <20200422081914.GC29541@willie-the-truck> (raw)
In-Reply-To: <01029876-e167-a1ba-cb1a-d97adf23dde4@windriver.com>
On Wed, Apr 22, 2020 at 10:56:04AM +0800, Jiping Ma wrote:
> On 04/16/2020 03:10 PM, Will Deacon wrote:
> > On Thu, Apr 16, 2020 at 01:38:29PM +0800, Jiping Ma wrote:
> > > +void
> > > +user_backtrace_thumb(struct perf_callchain_entry_ctx *entry,
> > > + struct pt_regs *regs)
> > > +{
> > > + u32 sp;
> > > + u32 *sp_t;
> > > + /*
> > > + * Only push sp, lr to stack.
> > > + */
> > > + for (sp = regs->compat_sp; (sp < current->mm->start_stack) &&
> > > + (entry->nr < entry->max_stack); sp += 4) {
> > > + sp_t = (u32 *)(unsigned long)sp;
> > > + if ((*sp_t > regs->compat_sp) &&
> > > + (*sp_t < current->mm->start_stack)) {
> > > + if (*(sp_t + 1) < current->mm->end_code &&
> > > + *(sp_t + 1) > current->mm->start_code) {
> > > + perf_callchain_store(entry, *(sp_t + 1)-1);
> > > + sp += 4;
> > > + }
> > > + }
> > > + }
> > > +}
> > This looks like a pile of fragile heuristics to me. Why don't you just use
> > libunwind in userspace, the same way you'd have to if you compiled without
> > framepointers?
>
> Could you share more details for libunwind in userspace? Following is our
> build command for test app.
> bt_perf.thumb: arm-wrs-linux-gnueabi-gcc -march=armv7ve -mthumb -mfpu=neon
> -mfloat-abi=softfp -mcpu=cortex-a15
> --sysroot=sysroots/cortexa15t2-neon-wrs-linux-gnueabi -O0 -g -ggdb -Wall
> -funwind-tables -fno-omit-frame-pointer -frecord-gcc-switches -mapcs-frame
> bt_perf.c -o bt_perf.thumb
You can build the perf tool with support for libunwind, and then it should
handle the unwinding in userspace. I haven't used it for ages, but you may
need to pass '--call-graph dwarf'. Have a play (and you can also read the
code in tools/perf/).
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2020-04-22 8:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200416053829.130395-1-jiping.ma2@windriver.com>
2020-04-16 7:10 ` [PATCH] Perf: support to unwind userspace application stacks generated with thumb Will Deacon
[not found] ` <01029876-e167-a1ba-cb1a-d97adf23dde4@windriver.com>
2020-04-22 8:19 ` Will Deacon [this message]
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=20200422081914.GC29541@willie-the-truck \
--to=will@kernel.org \
--cc=Jiping.Ma2@windriver.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=catalin.marinas@arm.com \
--cc=jolsa@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=will.deacon@arm.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