From: Steven Rostedt <rostedt@goodmis.org> To: Vineet Gupta <Vineet.Gupta1@synopsys.com> Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>, "linux-snps-arc@lists.infradead.org" <linux-snps-arc@lists.infradead.org>, Alexey Brodkin <Alexey.Brodkin@synopsys.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@redhat.com>, Claudiu Zissulescu <claziss@gmail.com> Subject: Re: [RFC] ARC: initial ftrace support Date: Thu, 2 Apr 2020 13:52:57 -0400 [thread overview] Message-ID: <20200402135257.7dd14f36@gandalf.local.home> (raw) In-Reply-To: <fe7ae84c-745a-04b4-dcc0-5df8cc35ee0c@synopsys.com> On Thu, 2 Apr 2020 01:17:01 +0000 Vineet Gupta <Vineet.Gupta1@synopsys.com> wrote: > +CC Claudiu > > On 3/27/20 10:10 AM, Steven Rostedt wrote: > > On Fri, 27 Mar 2020 18:53:55 +0300 > > Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> wrote: > > Maybe add a comment that gcc does the heavy lifting: I have following in glibc > > +/* this is very simple as gcc does all the heavy lifting at _mcount call site > + * - sets up caller's blink in r0, so frompc is setup correctly > + * - preserve argument registers for original call */ > > >> +noinline void _mcount(unsigned long parent_ip) > >> +{ > >> + unsigned long ip = (unsigned long)__builtin_return_address(0); > >> + > >> + if (unlikely(ftrace_trace_function != ftrace_stub)) > >> + ftrace_trace_function(ip - MCOUNT_INSN_SIZE, parent_ip, > >> + NULL, NULL); > >> +} > >> +EXPORT_SYMBOL(_mcount); > > > > So, ARCv2 allows the _mcount code to be written in C? Nice! > > Yeah, the gcc backend for -pg was overhauled recently so it is a first class "lib > call" meaning we get all the register save/restore for free as well as caller PC > (blink) as explicit argument to _mcount > > void bar(int a, int b, int c) { > printf("%d\n", a, b, c); > } > > bar: > push_s blink > std.a r14,[sp,-8] > push_s r13 > mov_s r14,r1 > mov_s r13,r0 > mov_s r0,blink > bl.d @_mcount > mov_s r15,r2 > > mov_s r3,r15 <-- restore args for call We really don't want this. :-/ This will make it really difficult to implement the dynamic ftrace, and this causes more overhead when tracing is not enabled. Also, ftrace is much more complex, and this will make it difficult to have function graph tracing and other features. Gcc has an "instrument-functions" which people asked me why I didn't go that route, as it lets you do the same (call C code), and its because of the overhead it adds to each function that I turned it down. -- Steve > mov_s r2,r14 > mov_s r1,r13 > mov_s r0,@.LC0 > ld blink,[sp,12] > pop_s r13 > b.d @printf > ldd.ab r14,[sp,12] > > @Eugeniy, this patch looks ok to me, but a word of caution. This won't work with > elf32 toolchain which some of the build systems tend to use (Alexey ?) > > The above _mcount semantics is only implemented for the linux tool-chains. > elf32-gcc generates "legacy" __mcount (2 underscores, blink not provided as arg) > likely done by Claudiu to keep newlib stuff unchanged. Perhaps elf32 gcc can add a > toggle to get new _mcount. > > And this is conditional to ARCv2 due to future ties into dynamic ftrace and > instruction fudging etc ? We may have to revisit that for BE anyhow given such a > customer lining up. > > -Vineet
WARNING: multiple messages have this Message-ID (diff)
From: Steven Rostedt <rostedt@goodmis.org> To: Vineet Gupta <Vineet.Gupta1@synopsys.com> Cc: Claudiu Zissulescu <claziss@gmail.com>, Alexey Brodkin <Alexey.Brodkin@synopsys.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@redhat.com>, "linux-snps-arc@lists.infradead.org" <linux-snps-arc@lists.infradead.org>, Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> Subject: Re: [RFC] ARC: initial ftrace support Date: Thu, 2 Apr 2020 13:52:57 -0400 [thread overview] Message-ID: <20200402135257.7dd14f36@gandalf.local.home> (raw) In-Reply-To: <fe7ae84c-745a-04b4-dcc0-5df8cc35ee0c@synopsys.com> On Thu, 2 Apr 2020 01:17:01 +0000 Vineet Gupta <Vineet.Gupta1@synopsys.com> wrote: > +CC Claudiu > > On 3/27/20 10:10 AM, Steven Rostedt wrote: > > On Fri, 27 Mar 2020 18:53:55 +0300 > > Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> wrote: > > Maybe add a comment that gcc does the heavy lifting: I have following in glibc > > +/* this is very simple as gcc does all the heavy lifting at _mcount call site > + * - sets up caller's blink in r0, so frompc is setup correctly > + * - preserve argument registers for original call */ > > >> +noinline void _mcount(unsigned long parent_ip) > >> +{ > >> + unsigned long ip = (unsigned long)__builtin_return_address(0); > >> + > >> + if (unlikely(ftrace_trace_function != ftrace_stub)) > >> + ftrace_trace_function(ip - MCOUNT_INSN_SIZE, parent_ip, > >> + NULL, NULL); > >> +} > >> +EXPORT_SYMBOL(_mcount); > > > > So, ARCv2 allows the _mcount code to be written in C? Nice! > > Yeah, the gcc backend for -pg was overhauled recently so it is a first class "lib > call" meaning we get all the register save/restore for free as well as caller PC > (blink) as explicit argument to _mcount > > void bar(int a, int b, int c) { > printf("%d\n", a, b, c); > } > > bar: > push_s blink > std.a r14,[sp,-8] > push_s r13 > mov_s r14,r1 > mov_s r13,r0 > mov_s r0,blink > bl.d @_mcount > mov_s r15,r2 > > mov_s r3,r15 <-- restore args for call We really don't want this. :-/ This will make it really difficult to implement the dynamic ftrace, and this causes more overhead when tracing is not enabled. Also, ftrace is much more complex, and this will make it difficult to have function graph tracing and other features. Gcc has an "instrument-functions" which people asked me why I didn't go that route, as it lets you do the same (call C code), and its because of the overhead it adds to each function that I turned it down. -- Steve > mov_s r2,r14 > mov_s r1,r13 > mov_s r0,@.LC0 > ld blink,[sp,12] > pop_s r13 > b.d @printf > ldd.ab r14,[sp,12] > > @Eugeniy, this patch looks ok to me, but a word of caution. This won't work with > elf32 toolchain which some of the build systems tend to use (Alexey ?) > > The above _mcount semantics is only implemented for the linux tool-chains. > elf32-gcc generates "legacy" __mcount (2 underscores, blink not provided as arg) > likely done by Claudiu to keep newlib stuff unchanged. Perhaps elf32 gcc can add a > toggle to get new _mcount. > > And this is conditional to ARCv2 due to future ties into dynamic ftrace and > instruction fudging etc ? We may have to revisit that for BE anyhow given such a > customer lining up. > > -Vineet _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
next prev parent reply other threads:[~2020-04-02 17:53 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-27 15:53 [RFC] ARC: initial ftrace support Eugeniy Paltsev 2020-03-27 15:53 ` Eugeniy Paltsev 2020-03-27 17:10 ` Steven Rostedt 2020-03-27 17:10 ` Steven Rostedt 2020-04-02 1:17 ` Vineet Gupta 2020-04-02 1:17 ` Vineet Gupta 2020-04-02 8:10 ` Claudiu Zissulescu Ianculescu 2020-04-02 8:10 ` Claudiu Zissulescu Ianculescu 2020-04-02 14:15 ` Alexey Brodkin 2020-04-02 14:15 ` Alexey Brodkin 2020-05-14 13:09 ` Eugeniy Paltsev 2020-05-14 13:09 ` Eugeniy Paltsev 2020-04-02 17:52 ` Steven Rostedt [this message] 2020-04-02 17:52 ` Steven Rostedt
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=20200402135257.7dd14f36@gandalf.local.home \ --to=rostedt@goodmis.org \ --cc=Alexey.Brodkin@synopsys.com \ --cc=Eugeniy.Paltsev@synopsys.com \ --cc=Vineet.Gupta1@synopsys.com \ --cc=claziss@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-snps-arc@lists.infradead.org \ --cc=mingo@redhat.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: linkBe 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.