2012-08-07 19:41:03

by Steven Rostedt

[permalink] [raw]
Subject: [RFC PATCH 1/4] ftrace: Make recordmcount.c handle __fentry__

From: Steven Rostedt <[email protected]>

With gcc 4.6.0 the -mfentry feature places the function profiling
call at the start of the function. When this is used, the call is
to __fentry__ and not mcount.

Change recordmcount.c to record both callers to __fentry__ and
mcount.

Cc: John Reiser <[email protected]>
Cc: Andi Kleen <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
scripts/recordmcount.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index 54e35c1..9d1421e 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -261,11 +261,13 @@ static unsigned get_mcountsym(Elf_Sym const *const sym0,
&sym0[Elf_r_sym(relp)];
char const *symname = &str0[w(symp->st_name)];
char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
+ char const *fentry = "__fentry__";

if (symname[0] == '.')
++symname; /* ppc64 hack */
if (strcmp(mcount, symname) == 0 ||
- (altmcount && strcmp(altmcount, symname) == 0))
+ (altmcount && strcmp(altmcount, symname) == 0) ||
+ (strcmp(fentry, symname) == 0))
mcountsym = Elf_r_sym(relp);

return mcountsym;
--
1.7.10.4



Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2012-08-08 00:05:23

by Steven Rostedt

[permalink] [raw]
Subject: Re: [RFC PATCH 1/4] ftrace: Make recordmcount.c handle __fentry__

On Tue, 2012-08-07 at 16:57 -0700, John Reiser wrote:

> If the user changes compilers (or changes CFLAGS by insert/remove "-mfentry")
> without doing a "make clean", then recordmcount will omit some calls.

The make dependencies of such a change should (hopefully) cause a full
recompile of the code. Yeah, I expect that we only have "mcount" or
"fentry" as something that can be called. If we had both mcount and
fentry, it would fail to link anyway, as we only define mcount or fentry
in the assembly, never both.

>
> Those restrictions are easy to guess, and recovery is easy. Therefore,
> Ack'ed by: John Reiser <[email protected]>
>

Thanks!

-- Steve

2012-08-08 00:06:56

by John Reiser

[permalink] [raw]
Subject: Re: [RFC PATCH 1/4] ftrace: Make recordmcount.c handle __fentry__

On 08/07/2012 12:38 PM, Steven Rostedt wrote:
> From: Steven Rostedt <[email protected]>
>
> With gcc 4.6.0 the -mfentry feature places the function profiling call at the start of the function. When this is used, the call is to __fentry__ and not mcount.
>
> Change recordmcount.c to record both callers to __fentry__ and mcount.
[snip]
> - (altmcount && strcmp(altmcount, symname) == 0))
> + (altmcount && strcmp(altmcount, symname) == 0) ||
> + (strcmp(fentry, symname) == 0))


The proposed change will work as long as all the *.o use the same name.
Only one of {"__fentry__", "mcount", "_mcount", altmcount} is allowed
for all the *.o as input for a particular run. [Modulo the hack
of ignoring a leading '.' for 64-bit PowerPC, of course.]

If the user changes compilers (or changes CFLAGS by insert/remove "-mfentry")
without doing a "make clean", then recordmcount will omit some calls.

Those restrictions are easy to guess, and recovery is easy. Therefore,
Ack'ed by: John Reiser <[email protected]>

--

2012-08-27 17:04:12

by Steven Rostedt

[permalink] [raw]
Subject: [tip:perf/core] ftrace: Make recordmcount.c handle __fentry__

Commit-ID: 48bb5dc6cd9d30fe0d594947563da1f8bd9abada
Gitweb: http://git.kernel.org/tip/48bb5dc6cd9d30fe0d594947563da1f8bd9abada
Author: Steven Rostedt <[email protected]>
AuthorDate: Wed, 9 Feb 2011 13:13:23 -0500
Committer: Steven Rostedt <[email protected]>
CommitDate: Thu, 23 Aug 2012 11:24:43 -0400

ftrace: Make recordmcount.c handle __fentry__

With gcc 4.6.0 the -mfentry feature places the function profiling
call at the start of the function. When this is used, the call is
to __fentry__ and not mcount.

Change recordmcount.c to record both callers to __fentry__ and
mcount.

Link: http://lkml.kernel.org/r/[email protected]

Acked-by: H. Peter Anvin <[email protected]>
Acked-by: John Reiser <[email protected]>
Acked-by: Ingo Molnar <[email protected]>
Cc: Andi Kleen <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
scripts/recordmcount.h | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index 54e35c1..9d1421e 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -261,11 +261,13 @@ static unsigned get_mcountsym(Elf_Sym const *const sym0,
&sym0[Elf_r_sym(relp)];
char const *symname = &str0[w(symp->st_name)];
char const *mcount = gpfx == '_' ? "_mcount" : "mcount";
+ char const *fentry = "__fentry__";

if (symname[0] == '.')
++symname; /* ppc64 hack */
if (strcmp(mcount, symname) == 0 ||
- (altmcount && strcmp(altmcount, symname) == 0))
+ (altmcount && strcmp(altmcount, symname) == 0) ||
+ (strcmp(fentry, symname) == 0))
mcountsym = Elf_r_sym(relp);

return mcountsym;