Skip to contentSkip to conversation

explictly ignore a file in recordmcount.pl

PATCH In review Shaohua Li 2 participants 4 messages Dec 23, 2008 – Dec 24, 2008

lore
Share & tools
lore

Shaohua Li

author
#0 lore raw

PATCH 3/5 explictly ignore a file in recordmcount.pl

In IA64, a function pointer isn't a 'unsigned long' but a 'struct {unsigned long ip, unsigned long gp}'. MCOUNT_ADDR is determined at link time not compile time, so explictly ignore kernel/trace/ftrace.o in recordmcount.pl.

---
 kernel/trace/ftrace.c   |   10 +---------
 scripts/recordmcount.pl |    5 +++++
 2 files changed, 6 insertions(+), 9 deletions(-)

Index: linux/kernel/trace/ftrace.c
=================================--- linux.orig/kernel/trace/ftrace.c 2008-12-23 13:11:28.000000000 +0800
+++ linux/kernel/trace/ftrace.c 2008-12-23 13:24:59.000000000 +0800
@@ -263,14 +263,6 @@ static void ftrace_update_pid_func(void)

 # error Dynamic ftrace depends on MCOUNT_RECORD
 #endif

-/*
- * Since MCOUNT_ADDR may point to mcount itself, we do not want
- * to get it confused by reading a reference in the code as we
- * are parsing on objcopy output of text. Use a variable for
- * it instead.
- */
-static unsigned long mcount_addr = MCOUNT_ADDR;
-
enum {
FTRACE_ENABLE_CALLS = (1 << 0),
FTRACE_DISABLE_CALLS = (1 << 1),
@@ -575,7 +567,7 @@ ftrace_code_disable(struct module *mod,

ip = rec->ip;

- ret = ftrace_make_nop(mod, rec, mcount_addr);
+ ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
if (ret) {
ftrace_bug(ret, ip);
rec->flags |= FTRACE_FL_FAILED;
Index: linux/scripts/recordmcount.pl
=================================--- linux.orig/scripts/recordmcount.pl 2008-12-23 13:24:38.000000000 +0800
+++ linux/scripts/recordmcount.pl 2008-12-23 13:24:59.000000000 +0800
@@ -109,6 +109,11 @@ if ($#ARGV < 7) {
my ($arch, $bits, $objdump, $objcopy, $cc,

     $ld, $nm, $rm, $mv, $is_module, $inputfile) = @ARGV;

+# This file refers to mcount and shouldn't be ftraced, so lets' ignore it +if ($inputfile eq "kernel/trace/ftrace.o") {
+ exit(0);
+}
+
# Acceptable sections to record.
my %text_sections = (

      ".text" => 1,
#1 lore raw
Quoted 30 lines · Shaohua Li

In IA64, a function pointer isn't a 'unsigned long' but a 'struct {unsigned long ip, unsigned long gp}'. MCOUNT_ADDR is determined at link time not compile time, so explictly ignore kernel/trace/ftrace.o in recordmcount.pl.

---
 kernel/trace/ftrace.c   |   10 +---------
 scripts/recordmcount.pl |    5 +++++
 2 files changed, 6 insertions(+), 9 deletions(-)

Index: linux/kernel/trace/ftrace.c
=================================> --- linux.orig/kernel/trace/ftrace.c 2008-12-23 13:11:28.000000000 +0800
+++ linux/kernel/trace/ftrace.c 2008-12-23 13:24:59.000000000 +0800

(quoted diff) +0 -8
@@ -263,14 +263,6 @@ static void ftrace_update_pid_func(void)
 # error Dynamic ftrace depends on MCOUNT_RECORD
 #endif
 
-/*
- * Since MCOUNT_ADDR may point to mcount itself, we do not want
- * to get it confused by reading a reference in the code as we
- * are parsing on objcopy output of text. Use a variable for
- * it instead.
- */
-static unsigned long mcount_addr = MCOUNT_ADDR;
-
 enum {
 	FTRACE_ENABLE_CALLS		= (1 << 0),
 	FTRACE_DISABLE_CALLS		= (1 << 1),

Review ftrace_code_disable(struct module *mod, · line 570

Quoted 5 lines
(quoted diff) +1 -1
@@ -575,7 +567,7 @@ ftrace_code_disable(struct module *mod, 
 
 	ip = rec->ip;
 
-	ret = ftrace_make_nop(mod, rec, mcount_addr);
+	ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);

This change will make dynamic ftrace fail on other archs (ppc and x86). Please read the comment you deleted. By using MCOUNT_ADDR directly in the code, you will create a reference to mcount in a text section that will confuse recordmcount.pl. It will think this reference is a call to mcount and when it tries to modify it, it will fail because the code is not a call.

-- Steve

Quoted 20 lines
(quoted diff) +0 -0
 	if (ret) {
 		ftrace_bug(ret, ip);
 		rec->flags |= FTRACE_FL_FAILED;

Index: linux/scripts/recordmcount.pl
=================================> --- linux.orig/scripts/recordmcount.pl 2008-12-23 13:24:38.000000000 +0800
+++ linux/scripts/recordmcount.pl 2008-12-23 13:24:59.000000000 +0800

(quoted diff) +5 -0
@@ -109,6 +109,11 @@ if ($#ARGV < 7) {
 my ($arch, $bits, $objdump, $objcopy, $cc,
     $ld, $nm, $rm, $mv, $is_module, $inputfile) = @ARGV;
 
+# This file refers to mcount and shouldn't be ftraced, so lets' ignore it
+if ($inputfile eq "kernel/trace/ftrace.o") {
+    exit(0);
+}
+
 # Acceptable sections to record.
 my %text_sections = (
      ".text" => 1,
author
#2 lore raw
In reply to Shaohua Li
Quoted 35 lines · Steven Rostedt
Quoted 33 lines · Shaohua Li

In IA64, a function pointer isn't a 'unsigned long' but a 'struct {unsigned long ip, unsigned long gp}'. MCOUNT_ADDR is determined at link time not compile time, so explictly ignore kernel/trace/ftrace.o in recordmcount.pl.

---
 kernel/trace/ftrace.c   |   10 +---------
 scripts/recordmcount.pl |    5 +++++
 2 files changed, 6 insertions(+), 9 deletions(-)

Index: linux/kernel/trace/ftrace.c
=================================> > --- linux.orig/kernel/trace/ftrace.c 2008-12-23 13:11:28.000000000 +0800
+++ linux/kernel/trace/ftrace.c 2008-12-23 13:24:59.000000000 +0800

(quoted diff) +0 -8
@@ -263,14 +263,6 @@ static void ftrace_update_pid_func(void)
 # error Dynamic ftrace depends on MCOUNT_RECORD
 #endif
 
-/*
- * Since MCOUNT_ADDR may point to mcount itself, we do not want
- * to get it confused by reading a reference in the code as we
- * are parsing on objcopy output of text. Use a variable for
- * it instead.
- */
-static unsigned long mcount_addr = MCOUNT_ADDR;
-
 enum {
 	FTRACE_ENABLE_CALLS		= (1 << 0),
 	FTRACE_DISABLE_CALLS		= (1 << 1),
@@ -575,7 +567,7 @@ ftrace_code_disable(struct module *mod, 
 
 	ip = rec->ip;
 
Quoted 9 lines

Review ftrace_code_disable(struct module *mod, · line 570

Quoted 2 lines
(quoted diff) +1 -1
-	ret = ftrace_make_nop(mod, rec, mcount_addr);
+	ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);

This change will make dynamic ftrace fail on other archs (ppc and x86). Please read the comment you deleted. By using MCOUNT_ADDR directly in the code, you will create a reference to mcount in a text section that will confuse recordmcount.pl. It will think this reference is a call to mcount and when it tries to modify it, it will fail because the code is not a call.

Did you read the changes just at the bottom? I explictly ignored kernel/trace/ftrace.o in recordmcount.pl.

Thanks,
Shaohua

Quoted 22 lines
Quoted 21 lines
(quoted diff) +0 -0
 	if (ret) {
 		ftrace_bug(ret, ip);
 		rec->flags |= FTRACE_FL_FAILED;

Index: linux/scripts/recordmcount.pl
=================================> > --- linux.orig/scripts/recordmcount.pl 2008-12-23 13:24:38.000000000 +0800
+++ linux/scripts/recordmcount.pl 2008-12-23 13:24:59.000000000 +0800

(quoted diff) +5 -0
@@ -109,6 +109,11 @@ if ($#ARGV < 7) {
 my ($arch, $bits, $objdump, $objcopy, $cc,
     $ld, $nm, $rm, $mv, $is_module, $inputfile) = @ARGV;
 
+# This file refers to mcount and shouldn't be ftraced, so lets' ignore it
+if ($inputfile eq "kernel/trace/ftrace.o") {
+    exit(0);
+}
+
 # Acceptable sections to record.
 my %text_sections = (
      ".text" => 1,
#3 lore raw
In reply to Shaohua Li
Quoted 62 lines · Shaohua Li
Quoted 35 lines · Steven Rostedt
Quoted 33 lines · Shaohua Li

In IA64, a function pointer isn't a 'unsigned long' but a 'struct {unsigned long ip, unsigned long gp}'. MCOUNT_ADDR is determined at link time not compile time, so explictly ignore kernel/trace/ftrace.o in recordmcount.pl.

---
 kernel/trace/ftrace.c   |   10 +---------
 scripts/recordmcount.pl |    5 +++++
 2 files changed, 6 insertions(+), 9 deletions(-)

Index: linux/kernel/trace/ftrace.c
=================================> > > --- linux.orig/kernel/trace/ftrace.c 2008-12-23 13:11:28.000000000 +0800
+++ linux/kernel/trace/ftrace.c 2008-12-23 13:24:59.000000000 +0800

(quoted diff) +0 -8
@@ -263,14 +263,6 @@ static void ftrace_update_pid_func(void)
 # error Dynamic ftrace depends on MCOUNT_RECORD
 #endif
 
-/*
- * Since MCOUNT_ADDR may point to mcount itself, we do not want
- * to get it confused by reading a reference in the code as we
- * are parsing on objcopy output of text. Use a variable for
- * it instead.
- */
-static unsigned long mcount_addr = MCOUNT_ADDR;
-
 enum {
 	FTRACE_ENABLE_CALLS		= (1 << 0),
 	FTRACE_DISABLE_CALLS		= (1 << 1),
@@ -575,7 +567,7 @@ ftrace_code_disable(struct module *mod, 
 
 	ip = rec->ip;
 
Quoted 9 lines

Review ftrace_code_disable(struct module *mod, · line 570

Quoted 2 lines
(quoted diff) +1 -1
-	ret = ftrace_make_nop(mod, rec, mcount_addr);
+	ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);

This change will make dynamic ftrace fail on other archs (ppc and x86). Please read the comment you deleted. By using MCOUNT_ADDR directly in the code, you will create a reference to mcount in a text section that will confuse recordmcount.pl. It will think this reference is a call to mcount and when it tries to modify it, it will fail because the code is not a call.

Did you read the changes just at the bottom? I explictly ignored kernel/trace/ftrace.o in recordmcount.pl.

Thanks,
Shaohua

Quoted 11 lines
Quoted 11 lines
(quoted diff) +0 -0
 	if (ret) {
 		ftrace_bug(ret, ip);
 		rec->flags |= FTRACE_FL_FAILED;

Index: linux/scripts/recordmcount.pl
=================================> > > --- linux.orig/scripts/recordmcount.pl 2008-12-23 13:24:38.000000000 +0800
+++ linux/scripts/recordmcount.pl 2008-12-23 13:24:59.000000000 +0800

(quoted diff) +0 -0
@@ -109,6 +109,11 @@ if ($#ARGV < 7) {
 my ($arch, $bits, $objdump, $objcopy, $cc,
     $ld, $nm, $rm, $mv, $is_module, $inputfile) = @ARGV;
 
Quoted 5 lines
Quoted 5 lines

Review if ($#ARGV < 7) { · line 116

Quoted 5 lines
(quoted diff) +5 -0
+# This file refers to mcount and shouldn't be ftraced, so lets' ignore it
+if ($inputfile eq "kernel/trace/ftrace.o") {
+    exit(0);
+}
+

I did see this before, just forgot about it ;-)

Well, fine then, but it is getting a bit more fragile than I would like.

-- Steve

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
(quoted diff) +0 -0
 # Acceptable sections to record.
 my %text_sections = (
      ".text" => 1,