From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Vojtech Pavlik <vojtech@suse.cz>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Jiri Kosina <jkosina@suse.cz>, Jiri Slaby <jslaby@suse.cz>,
linux390@de.ibm.com, linux-s390@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] s390/ftrace: optimize function graph caller code
Date: Fri, 15 Aug 2014 14:00:02 +0200 [thread overview]
Message-ID: <20140815120002.GD4215@osiris> (raw)
In-Reply-To: <20140815115753.GA4215@osiris>
When the function graph tracer is disabled we can skip three additional
instructions. So let's just do just this.
So if function tracing is enabled but function graph tracing is
runtime disabled, we get away with a single unconditional branch.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
arch/s390/include/asm/ftrace.h | 1 +
arch/s390/kernel/ftrace.c | 24 ++++++++++++++++++++++++
arch/s390/kernel/mcount64.S | 15 +++++++++------
3 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/arch/s390/include/asm/ftrace.h b/arch/s390/include/asm/ftrace.h
index 4b264caa0704..874f903c2eb4 100644
--- a/arch/s390/include/asm/ftrace.h
+++ b/arch/s390/include/asm/ftrace.h
@@ -4,6 +4,7 @@
#ifndef __ASSEMBLY__
extern void _mcount(void);
+extern char ftrace_graph_caller_end;
struct dyn_arch_ftrace { };
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
index ae4141fbcb07..7dc7df3857c4 100644
--- a/arch/s390/kernel/ftrace.c
+++ b/arch/s390/kernel/ftrace.c
@@ -170,6 +170,29 @@ out:
* directly after the instructions. To enable the call we calculate
* the original offset to prepare_ftrace_return and put it back.
*/
+
+#ifdef CONFIG_64BIT
+
+int ftrace_enable_ftrace_graph_caller(void)
+{
+ static unsigned short offset = 0x0002;
+
+ return probe_kernel_write((void *) ftrace_graph_caller + 2,
+ &offset, sizeof(offset));
+}
+
+int ftrace_disable_ftrace_graph_caller(void)
+{
+ unsigned short offset;
+
+ offset = ((void *) &ftrace_graph_caller_end -
+ (void *) ftrace_graph_caller) / 2;
+ return probe_kernel_write((void *) ftrace_graph_caller + 2,
+ &offset, sizeof(offset));
+}
+
+#else /* CONFIG_64BIT */
+
int ftrace_enable_ftrace_graph_caller(void)
{
unsigned short offset;
@@ -188,5 +211,6 @@ int ftrace_disable_ftrace_graph_caller(void)
&offset, sizeof(offset));
}
+#endif /* CONFIG_64BIT */
#endif /* CONFIG_DYNAMIC_FTRACE */
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
diff --git a/arch/s390/kernel/mcount64.S b/arch/s390/kernel/mcount64.S
index c67a8bf0fd9a..b03896d29274 100644
--- a/arch/s390/kernel/mcount64.S
+++ b/arch/s390/kernel/mcount64.S
@@ -32,14 +32,17 @@ ENTRY(ftrace_caller)
lg %r14,0(%r14)
basr %r14,%r14
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+# The j instruction gets runtime patched to a nop instruction.
+# See ftrace_enable_ftrace_graph_caller. The patched instruction is:
+# j .+2
+ENTRY(ftrace_graph_caller)
+ j ftrace_graph_caller_end
lg %r2,168(%r15)
lg %r3,272(%r15)
-ENTRY(ftrace_graph_caller)
-# The bras instruction gets runtime patched to call prepare_ftrace_return.
-# See ftrace_enable_ftrace_graph_caller. The patched instruction is:
-# bras %r14,prepare_ftrace_return
- bras %r14,0f
-0: stg %r2,168(%r15)
+ brasl %r14,prepare_ftrace_return
+ stg %r2,168(%r15)
+ftrace_graph_caller_end:
+ .globl ftrace_graph_caller_end
#endif
aghi %r15,160
lmg %r2,%r5,32(%r15)
--
1.8.5.5
next prev parent reply other threads:[~2014-08-15 12:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-03 12:00 [PATCH] s390: add support for DYNAMIC_FTRACE_WITH_REGS Vojtech Pavlik
2014-07-08 8:07 ` Heiko Carstens
2014-08-15 11:57 ` Heiko Carstens
2014-08-15 11:59 ` [PATCH 1/5] s390: pass march flag to assembly files as well Heiko Carstens
2014-08-15 11:59 ` [PATCH 2/5] s390/ftrace: optimize patched mcount calling code Heiko Carstens
2014-08-15 12:00 ` Heiko Carstens [this message]
2014-08-15 12:00 ` [PATCH 4/5] s390/ftrace: add HAVE_DYNAMIC_FTRACE_WITH_REGS support Heiko Carstens
2014-08-15 12:01 ` [PATCH 5/5] s390/ftrace: enforce DYNAMIC_FTRACE if FUNCTION_TRACER is selected Heiko Carstens
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=20140815120002.GD4215@osiris \
--to=heiko.carstens@de.ibm.com \
--cc=jkosina@suse.cz \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux390@de.ibm.com \
--cc=rostedt@goodmis.org \
--cc=schwidefsky@de.ibm.com \
--cc=vojtech@suse.cz \
/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