From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: perf: Fix callchain parse error with kernel tracepoint events
Date: Thu, 30 Apr 2015 09:59:49 +0100 [thread overview]
Message-ID: <20150430085949.GA32373@arm.com> (raw)
In-Reply-To: <55418A4D.5010900@huawei.com>
On Thu, Apr 30, 2015 at 02:50:05AM +0100, Hou Pengyang wrote:
> On 2015/4/29 18:12, Will Deacon wrote:
> > On Tue, Apr 28, 2015 at 02:20:48PM +0100, Hou Pengyang wrote:
> >> diff --git a/arch/arm64/include/asm/perf_event.h b/arch/arm64/include/asm/perf_event.h
> >> index d26d1d5..16a074f 100644
> >> --- a/arch/arm64/include/asm/perf_event.h
> >> +++ b/arch/arm64/include/asm/perf_event.h
> >> @@ -24,4 +24,20 @@ extern unsigned long perf_misc_flags(struct pt_regs *regs);
> >> #define perf_misc_flags(regs) perf_misc_flags(regs)
> >> #endif
> >>
> >> +#define perf_arch_fetch_caller_regs(regs, __ip) { \
> >> + unsigned long sp; \
> >> + __asm__ ("mov %[sp], sp\n" : [sp] "=r" (sp)); \
> >> + (regs)->pc = (__ip); \
> >> + __asm__ ( \
> >> + "str %[sp], %[_arm64_sp] \n\t" \
> >> + "str x29, %[_arm64_fp] \n\t" \
> >> + "mrs %[_arm64_cpsr], spsr_el1 \n\t" \
> >> + : [_arm64_sp] "=m" (regs->sp), \
> >> + [_arm64_fp] "=m" (regs->regs[29]), \
> >> + [_arm64_cpsr] "=r" (regs->pstate) \
> >
> > Does this really all need to be in assembly code? Ideally we'd use something
> > like __builtin_stack_pointer and __builtin_frame_pointer. That just leaves
> > the CPSR, but given that it's (a) only used for user_mode_regs tests and (b)
> > this macro is only used by ftrace, then we just set it to a static value
> > indicating that we're at EL1.
> >
> > So I *think* we should be able to write this as three lines of C.
> >
> Hi, will, as you said, we can get fp by __builtin_frame_address() and
> pstate by setting it to a static value. However, for sp, there isn't a
> gcc builtin fuction like __builtin_stack_pointer, so assembly code is
> needed. What's more, if CONFIG_FRAME_POINTER is close, can fp be got by
> __builtin_frame_address()?
Ah yes, I forgot the history of __builtin_stack_pointer (I think the LLVM
guys proposed it and it was rejected by GCC). Anyway, we can use
current_stack_pointer() instead.
I don't think CONFIG_FRAME_POINTER is relevant here; if you don't have
frame pointers then you won't be able to backtrace. The same issue happens
with your proposed patch.
Will
WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Hou Pengyang <houpengyang@huawei.com>
Cc: "a.p.zijlstra@chello.nl" <a.p.zijlstra@chello.nl>,
"paulus@samba.org" <paulus@samba.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"acme@kernel.org" <acme@kernel.org>,
"wangnan0@huawei.com" <wangnan0@huawei.com>,
Catalin Marinas <Catalin.Marinas@arm.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Mark Rutland <Mark.Rutland@arm.com>
Subject: Re: [PATCH] arm64: perf: Fix callchain parse error with kernel tracepoint events
Date: Thu, 30 Apr 2015 09:59:49 +0100 [thread overview]
Message-ID: <20150430085949.GA32373@arm.com> (raw)
In-Reply-To: <55418A4D.5010900@huawei.com>
On Thu, Apr 30, 2015 at 02:50:05AM +0100, Hou Pengyang wrote:
> On 2015/4/29 18:12, Will Deacon wrote:
> > On Tue, Apr 28, 2015 at 02:20:48PM +0100, Hou Pengyang wrote:
> >> diff --git a/arch/arm64/include/asm/perf_event.h b/arch/arm64/include/asm/perf_event.h
> >> index d26d1d5..16a074f 100644
> >> --- a/arch/arm64/include/asm/perf_event.h
> >> +++ b/arch/arm64/include/asm/perf_event.h
> >> @@ -24,4 +24,20 @@ extern unsigned long perf_misc_flags(struct pt_regs *regs);
> >> #define perf_misc_flags(regs) perf_misc_flags(regs)
> >> #endif
> >>
> >> +#define perf_arch_fetch_caller_regs(regs, __ip) { \
> >> + unsigned long sp; \
> >> + __asm__ ("mov %[sp], sp\n" : [sp] "=r" (sp)); \
> >> + (regs)->pc = (__ip); \
> >> + __asm__ ( \
> >> + "str %[sp], %[_arm64_sp] \n\t" \
> >> + "str x29, %[_arm64_fp] \n\t" \
> >> + "mrs %[_arm64_cpsr], spsr_el1 \n\t" \
> >> + : [_arm64_sp] "=m" (regs->sp), \
> >> + [_arm64_fp] "=m" (regs->regs[29]), \
> >> + [_arm64_cpsr] "=r" (regs->pstate) \
> >
> > Does this really all need to be in assembly code? Ideally we'd use something
> > like __builtin_stack_pointer and __builtin_frame_pointer. That just leaves
> > the CPSR, but given that it's (a) only used for user_mode_regs tests and (b)
> > this macro is only used by ftrace, then we just set it to a static value
> > indicating that we're at EL1.
> >
> > So I *think* we should be able to write this as three lines of C.
> >
> Hi, will, as you said, we can get fp by __builtin_frame_address() and
> pstate by setting it to a static value. However, for sp, there isn't a
> gcc builtin fuction like __builtin_stack_pointer, so assembly code is
> needed. What's more, if CONFIG_FRAME_POINTER is close, can fp be got by
> __builtin_frame_address()?
Ah yes, I forgot the history of __builtin_stack_pointer (I think the LLVM
guys proposed it and it was rejected by GCC). Anyway, we can use
current_stack_pointer() instead.
I don't think CONFIG_FRAME_POINTER is relevant here; if you don't have
frame pointers then you won't be able to backtrace. The same issue happens
with your proposed patch.
Will
next prev parent reply other threads:[~2015-04-30 8:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-28 13:20 [PATCH] arm64: perf: Fix callchain parse error with kernel tracepoint events Hou Pengyang
2015-04-28 13:20 ` Hou Pengyang
2015-04-29 10:12 ` Will Deacon
2015-04-29 10:12 ` Will Deacon
2015-04-30 1:50 ` Hou Pengyang
2015-04-30 1:50 ` Hou Pengyang
2015-04-30 8:59 ` Will Deacon [this message]
2015-04-30 8:59 ` Will Deacon
2015-04-30 13:55 ` Hou Pengyang
2015-04-30 13:55 ` Hou Pengyang
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=20150430085949.GA32373@arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.