* [PATCH 0/2] [GIT PULL] ftrace: recordmcount fixes
@ 2010-10-15 16:13 Steven Rostedt
2010-10-15 16:13 ` [PATCH 1/2] ftrace: Do not process kernel/trace/ftrace.o with C recordmcount program Steven Rostedt
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2010-10-15 16:13 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
Ingo,
Please pull the latest tip/perf/recordmcount tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/perf/recordmcount
Steven Rostedt (2):
ftrace: Do not process kernel/trace/ftrace.o with C recordmcount program
ftrace: Use objtree for C version of recordmcount
----
scripts/Makefile.build | 2 +-
scripts/recordmcount.c | 22 ++++++++++++++++++++--
2 files changed, 21 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ftrace: Do not process kernel/trace/ftrace.o with C recordmcount program
2010-10-15 16:13 [PATCH 0/2] [GIT PULL] ftrace: recordmcount fixes Steven Rostedt
@ 2010-10-15 16:13 ` Steven Rostedt
2010-10-15 16:13 ` [PATCH 2/2] ftrace: Use objtree for C version of recordmcount Steven Rostedt
2010-10-16 12:49 ` [PATCH 0/2] [GIT PULL] ftrace: recordmcount fixes Ingo Molnar
2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2010-10-15 16:13 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, John Reiser
[-- Attachment #1: 0001-ftrace-Do-not-process-kernel-trace-ftrace.o-with-C-r.patch --]
[-- Type: text/plain, Size: 2631 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
The file kernel/trace/ftrace.c references the mcount() call to
convert the mcount() callers to nops. But because it references
mcount(), the mcount() address is placed in the relocation table.
The C version of recordmcount reads the relocation table of all
object files, and it will add all references to mcount to the
__mcount_loc table that is used to find the places that call mcount()
and change the call to a nop. When recordmcount finds the mcount reference
in kernel/trace/ftrace.o, it saves that location even though the code
is not a call, but references mcount as data.
On boot up, when all calls are converted to nops, the code has a safety
check to determine what op code it is actually replacing before it
replaces it. If that op code at the address does not match, then
a warning is printed and the function tracer is disabled.
The reference to mcount in ftrace.c, causes this warning to trigger,
since the reference is not a call to mcount(). The ftrace.c file is
not compiled with the -pg flag, so no calls to mcount() should be
expected.
This patch simply makes recordmcount.c skip the kernel/trace/ftrace.c
file. This was the same solution used by the perl version of
recordmcount.
Reported-by: Ingo Molnar <mingo@elte.hu>
Cc: John Reiser <jreiser@bitwagon.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
scripts/recordmcount.c | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 7f7f718..26e1271 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -313,12 +313,30 @@ do_file(char const *const fname)
int
main(int argc, char const *argv[])
{
+ const char ftrace[] = "kernel/trace/ftrace.o";
+ int ftrace_size = sizeof(ftrace) - 1;
int n_error = 0; /* gcc-4.3.0 false positive complaint */
- if (argc <= 1)
+
+ if (argc <= 1) {
fprintf(stderr, "usage: recordmcount file.o...\n");
- else /* Process each file in turn, allowing deep failure. */
+ return 0;
+ }
+
+ /* Process each file in turn, allowing deep failure. */
for (--argc, ++argv; 0 < argc; --argc, ++argv) {
int const sjval = setjmp(jmpenv);
+ int len;
+
+ /*
+ * The file kernel/trace/ftrace.o references the mcount
+ * function but does not call it. Since ftrace.o should
+ * not be traced anyway, we just skip it.
+ */
+ len = strlen(argv[0]);
+ if (len >= ftrace_size &&
+ strcmp(argv[0] + (len - ftrace_size), ftrace) == 0)
+ continue;
+
switch (sjval) {
default: {
fprintf(stderr, "internal error: %s\n", argv[0]);
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ftrace: Use objtree for C version of recordmcount
2010-10-15 16:13 [PATCH 0/2] [GIT PULL] ftrace: recordmcount fixes Steven Rostedt
2010-10-15 16:13 ` [PATCH 1/2] ftrace: Do not process kernel/trace/ftrace.o with C recordmcount program Steven Rostedt
@ 2010-10-15 16:13 ` Steven Rostedt
2010-10-16 12:49 ` [PATCH 0/2] [GIT PULL] ftrace: recordmcount fixes Ingo Molnar
2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2010-10-15 16:13 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Michal Marek,
linux-kbuild
[-- Attachment #1: 0002-ftrace-Use-objtree-for-C-version-of-recordmcount.patch --]
[-- Type: text/plain, Size: 957 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
The C version of recordmcount is compiled to a binary, which will
end up located in the objtree. If the kernel is built with O=path,
the srctree will not include the binary recordmcount caller.
Cc: Michal Marek <mmarek@suse.cz>
Cc: linux-kbuild@vger.kernel.org
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
scripts/Makefile.build | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 4d03a7e..4db60b2 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -210,7 +210,7 @@ endif
ifdef CONFIG_FTRACE_MCOUNT_RECORD
ifdef BUILD_C_RECORDMCOUNT
-cmd_record_mcount = $(srctree)/scripts/recordmcount "$(@)";
+cmd_record_mcount = $(objtree)/scripts/recordmcount "$(@)";
else
cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] [GIT PULL] ftrace: recordmcount fixes
2010-10-15 16:13 [PATCH 0/2] [GIT PULL] ftrace: recordmcount fixes Steven Rostedt
2010-10-15 16:13 ` [PATCH 1/2] ftrace: Do not process kernel/trace/ftrace.o with C recordmcount program Steven Rostedt
2010-10-15 16:13 ` [PATCH 2/2] ftrace: Use objtree for C version of recordmcount Steven Rostedt
@ 2010-10-16 12:49 ` Ingo Molnar
2 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2010-10-16 12:49 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-kernel, Andrew Morton, Frederic Weisbecker
* Steven Rostedt <rostedt@goodmis.org> wrote:
> Ingo,
>
> Please pull the latest tip/perf/recordmcount tree, which can be found at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/perf/recordmcount
>
>
> Steven Rostedt (2):
> ftrace: Do not process kernel/trace/ftrace.o with C recordmcount program
> ftrace: Use objtree for C version of recordmcount
>
> ----
> scripts/Makefile.build | 2 +-
> scripts/recordmcount.c | 22 ++++++++++++++++++++--
> 2 files changed, 21 insertions(+), 3 deletions(-)
Pulled, thanks Steve!
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-16 12:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-15 16:13 [PATCH 0/2] [GIT PULL] ftrace: recordmcount fixes Steven Rostedt
2010-10-15 16:13 ` [PATCH 1/2] ftrace: Do not process kernel/trace/ftrace.o with C recordmcount program Steven Rostedt
2010-10-15 16:13 ` [PATCH 2/2] ftrace: Use objtree for C version of recordmcount Steven Rostedt
2010-10-16 12:49 ` [PATCH 0/2] [GIT PULL] ftrace: recordmcount fixes Ingo Molnar
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).