summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-10-31 00:03:22 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-31 10:29:17 +0100
commita26a2a27396c0a0877aa701f8f92d08ba550a6c9 (patch)
tree8e314b970e0219419b89204d3197fbc1257bf36e
parentb807c3d0f8e39ed7cbbbe6da162650e305e8de15 (diff)
downloadop-kernel-dev-a26a2a27396c0a0877aa701f8f92d08ba550a6c9.zip
op-kernel-dev-a26a2a27396c0a0877aa701f8f92d08ba550a6c9.tar.gz
ftrace: nmi safe code clean ups
Impact: cleanup This patch cleans up the NMI safe code for dynamic ftrace as suggested by Andrew Morton. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/arm/include/asm/ftrace.h4
-rw-r--r--arch/powerpc/include/asm/ftrace.h4
-rw-r--r--arch/sh/include/asm/ftrace.h4
-rw-r--r--arch/sparc/include/asm/ftrace.h4
-rw-r--r--arch/x86/include/asm/ftrace.h10
-rw-r--r--arch/x86/kernel/ftrace.c16
-rw-r--r--include/linux/ftrace.h3
-rw-r--r--kernel/trace/trace.c9
8 files changed, 28 insertions, 26 deletions
diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h
index d4c24a7..3f3a1d1 100644
--- a/arch/arm/include/asm/ftrace.h
+++ b/arch/arm/include/asm/ftrace.h
@@ -2,8 +2,8 @@
#define _ASM_ARM_FTRACE
#ifndef __ASSEMBLY__
-#define ftrace_nmi_enter() do { } while (0)
-#define ftrace_nmi_exit() do { } while (0)
+static inline void ftrace_nmi_enter(void) { }
+static inline void ftrace_nmi_exit(void) { }
#endif
#ifdef CONFIG_FUNCTION_TRACER
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index 7652755..1cd7270 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -2,8 +2,8 @@
#define _ASM_POWERPC_FTRACE
#ifndef __ASSEMBLY__
-#define ftrace_nmi_enter() do { } while (0)
-#define ftrace_nmi_exit() do { } while (0)
+static inline void ftrace_nmi_enter(void) { }
+static inline void ftrace_nmi_exit(void) { }
#endif
#ifdef CONFIG_FUNCTION_TRACER
diff --git a/arch/sh/include/asm/ftrace.h b/arch/sh/include/asm/ftrace.h
index cdf2cb0..31ada03 100644
--- a/arch/sh/include/asm/ftrace.h
+++ b/arch/sh/include/asm/ftrace.h
@@ -2,8 +2,8 @@
#define __ASM_SH_FTRACE_H
#ifndef __ASSEMBLY__
-#define ftrace_nmi_enter() do { } while (0)
-#define ftrace_nmi_exit() do { } while (0)
+static inline void ftrace_nmi_enter(void) { }
+static inline void ftrace_nmi_exit(void) { }
#endif
#ifndef __ASSEMBLY__
diff --git a/arch/sparc/include/asm/ftrace.h b/arch/sparc/include/asm/ftrace.h
index 33a95fe..62055ac 100644
--- a/arch/sparc/include/asm/ftrace.h
+++ b/arch/sparc/include/asm/ftrace.h
@@ -2,8 +2,8 @@
#define _ASM_SPARC64_FTRACE
#ifndef __ASSEMBLY__
-#define ftrace_nmi_enter() do { } while (0)
-#define ftrace_nmi_exit() do { } while (0)
+static inline void ftrace_nmi_enter(void) { }
+static inline void ftrace_nmi_exit(void) { }
#endif
#ifdef CONFIG_MCOUNT
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index f2ed6b7..a234681 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -22,16 +22,16 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)
extern void ftrace_nmi_enter(void);
extern void ftrace_nmi_exit(void);
#else
-#define ftrace_nmi_enter() do { } while (0)
-#define ftrace_nmi_exit() do { } while (0)
-#endif
+static inline void ftrace_nmi_enter(void) { }
+static inline void ftrace_nmi_exit(void) { }
#endif
+#endif /* __ASSEMBLY__ */
#else /* CONFIG_FUNCTION_TRACER */
#ifndef __ASSEMBLY__
-#define ftrace_nmi_enter() do { } while (0)
-#define ftrace_nmi_exit() do { } while (0)
+static inline void ftrace_nmi_enter(void) { }
+static inline void ftrace_nmi_exit(void) { }
#endif
#endif /* CONFIG_FUNCTION_TRACER */
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 6685b0f..6914933 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -67,7 +67,7 @@ unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
*
* Two buffers are added: An IP buffer and a "code" buffer.
*
- * 1) Put in the instruction pointer into the IP buffer
+ * 1) Put the instruction pointer into the IP buffer
* and the new code into the "code" buffer.
* 2) Set a flag that says we are modifying code
* 3) Wait for any running NMIs to finish.
@@ -85,14 +85,14 @@ unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
* are the same as what exists.
*/
-static atomic_t in_nmi;
-static int mod_code_status;
-static int mod_code_write;
-static void *mod_code_ip;
-static void *mod_code_newcode;
+static atomic_t in_nmi = ATOMIC_INIT(0);
+static int mod_code_status; /* holds return value of text write */
+static int mod_code_write; /* set when NMI should do the write */
+static void *mod_code_ip; /* holds the IP to write to */
+static void *mod_code_newcode; /* holds the text to write to the IP */
-static int nmi_wait_count;
-static atomic_t nmi_update_count;
+static unsigned nmi_wait_count;
+static atomic_t nmi_update_count = ATOMIC_INIT(0);
int ftrace_arch_read_dyn_info(char *buf, int size)
{
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 703eb53..22240dfe 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -74,6 +74,9 @@ extern void ftrace_caller(void);
extern void ftrace_call(void);
extern void mcount_call(void);
+/* May be defined in arch */
+extern int ftrace_arch_read_dyn_info(char *buf, int size);
+
/**
* ftrace_modify_code - modify code segment
* @ip: the address of the code segment
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index bc36feb..7f86067 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2815,10 +2815,6 @@ static struct file_operations tracing_mark_fops = {
#ifdef CONFIG_DYNAMIC_FTRACE
-#define DYN_INFO_BUF_SIZE 1023
-static char ftrace_dyn_info_buffer[DYN_INFO_BUF_SIZE+1];
-static DEFINE_MUTEX(dyn_info_mutex);
-
int __weak ftrace_arch_read_dyn_info(char *buf, int size)
{
return 0;
@@ -2828,14 +2824,17 @@ static ssize_t
tracing_read_dyn_info(struct file *filp, char __user *ubuf,
size_t cnt, loff_t *ppos)
{
+ static char ftrace_dyn_info_buffer[1024];
+ static DEFINE_MUTEX(dyn_info_mutex);
unsigned long *p = filp->private_data;
char *buf = ftrace_dyn_info_buffer;
+ int size = ARRAY_SIZE(ftrace_dyn_info_buffer);
int r;
mutex_lock(&dyn_info_mutex);
r = sprintf(buf, "%ld ", *p);
- r += ftrace_arch_read_dyn_info(buf+r, DYN_INFO_BUF_SIZE-r);
+ r += ftrace_arch_read_dyn_info(buf+r, (size-1)-r);
buf[r++] = '\n';
r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
OpenPOWER on IntegriCloud