mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: rostedt@goodmis.org, fweisbec@gmail.com
Cc: linux-kernel@vger.kernel.org
Subject: [RFC 2/3] tracing: adding statical callers
Date: Fri, 29 Apr 2011 16:43:13 +0200	[thread overview]
Message-ID: <1304088194-6214-3-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1304088194-6214-1-git-send-email-jolsa@redhat.com>

adding statically generated code for 'mcount callback' providing
unique bitmask

---
 arch/x86/include/asm/ftrace.h |    2 ++
 arch/x86/kernel/entry_64.S    |   22 +++++++++++++++++-----
 arch/x86/kernel/ftrace.c      |   13 +++++++++++++
 include/linux/ftrace.h        |    4 +---
 kernel/trace/ftrace.c         |    2 +-
 5 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index 45ae1fa..6ef436b 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -2,6 +2,7 @@
 #define _ASM_X86_FTRACE_H
 
 #define FTRACE_TRACERS_MAX 4
+#define FTRACE_CALLERS_MAX ((1 << FTRACE_TRACERS_MAX) - 1)
 
 #ifdef __ASSEMBLY__
 
@@ -36,6 +37,7 @@
 
 #ifndef __ASSEMBLY__
 extern void mcount(void);
+extern unsigned long ftrace_callers[FTRACE_CALLERS_MAX];
 
 static inline unsigned long ftrace_call_adjust(unsigned long addr)
 {
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index e0ba7d9..1ec1668 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -69,19 +69,31 @@ ENTRY(mcount)
 	retq
 END(mcount)
 
-ENTRY(ftrace_caller)
+	.section .rodata,"a"
+ENTRY(ftrace_callers)
+	.section .entry.text
+.macro FTRACE_GEN_CALLERS num
+i=1
+.rept (1 << \num) - 1
+1:
 	cmpl $0, function_trace_stop
 	jne  ftrace_stub
-
 	MCOUNT_SAVE_FRAME
+	movq $i, %rdx
+	jmp ftrace_caller
+	.previous
+	.quad 1b
+	.section .entry.text
+i=i+1
+.endr
+.endm
+	FTRACE_GEN_CALLERS FTRACE_TRACERS_MAX
 
+ENTRY(ftrace_caller)
 	movq 0x38(%rsp), %rdi
 	movq 8(%rbp), %rsi
 	subq $MCOUNT_INSN_SIZE, %rdi
 
-	/* by default call all registered handlers */
-	movq $-1, %rdx
-
 	call ftrace_call
 
 	MCOUNT_RESTORE_FRAME
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index dc92378..5a8e679 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -328,6 +328,19 @@ int __init ftrace_dyn_arch_init(void *data)
 
 	return 0;
 }
+
+unsigned long ftrace_arch_tracer_addr(int mask)
+{
+	if (!mask)
+		return 0L;
+
+	/* tracer 1 is index 0 in ftrace_callers */
+	--mask;
+
+	BUG_ON(mask >= FTRACE_CALLERS_MAX);
+	return ftrace_callers[mask];
+}
+
 #endif
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index b7ab09d..b12f5df 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -180,10 +180,8 @@ extern void ftrace_caller(void);
 extern void ftrace_call(unsigned long ip, unsigned long parent_ip,
 			unsigned long flags);
 extern void mcount_call(void);
+extern unsigned long ftrace_arch_tracer_addr(int mask);
 
-#ifndef FTRACE_ADDR
-#define FTRACE_ADDR ((unsigned long)ftrace_caller)
-#endif
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 extern void ftrace_graph_caller(void);
 extern int ftrace_enable_ftrace_graph_caller(void);
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index f1eedda..b39dd52 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -963,7 +963,7 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable)
 	unsigned long ftrace_addr;
 	unsigned long flag = 0UL;
 
-	ftrace_addr = (unsigned long)FTRACE_ADDR;
+	ftrace_addr = ftrace_arch_tracer_addr(FTRACE_CALLERS_MAX);
 
 	/*
 	 * If this record is not to be traced or we want to disable it,
-- 
1.7.1


  parent reply	other threads:[~2011-04-29 14:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-29 14:43 [RFC 0/3] x86_64,tracing: multiplexing function tracer Jiri Olsa
2011-04-29 14:43 ` [RFC 1/3] tracing: function tracer registration Jiri Olsa
2011-04-29 14:43 ` Jiri Olsa [this message]
2011-04-29 14:43 ` [RFC 3/3] tracing: set_ftrace_filter support Jiri Olsa
2011-04-29 15:16   ` Steven Rostedt
2011-04-29 14:57 ` [RFC 0/3] x86_64,tracing: multiplexing function tracer Steven Rostedt
2011-04-29 15:06   ` Jiri Olsa

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=1304088194-6214-3-git-send-email-jolsa@redhat.com \
    --to=jolsa@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®