Skip to contentSkip to conversation

ftrace/x86: Use kernel identity mapping only when CONFIG_DEBUG_RODATA enabled

PATCH In review Petr Mladek 2 participants 3 messages Jun 4, 2014 – Jun 5, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ftrace/x86: Use kernel identity mapping only when CONFIG_DEBUG_RODATA enabled

This is just a tiny optimization. The remapping is not needed when the kernel text mapping is read write all the time.

---
 arch/x86/kernel/ftrace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/ftrace.c +2 -1
index cbc4a91b131e..a7a517bb793e 100644
@@ -79,6 +79,7 @@ within(unsigned long addr, unsigned long start, unsigned long end)
 
 static unsigned long text_ip_addr(unsigned long ip)
 {
+#ifdef CONFIG_DEBUG_RODATA
 	/*
 	 * On x86_64, kernel text mappings are mapped read-only with
 	 * CONFIG_DEBUG_RODATA. So we use the kernel identity mapping instead
@@ -89,7 +90,7 @@ static unsigned long text_ip_addr(unsigned long ip)
 	 */
 	if (within(ip, (unsigned long)_text, (unsigned long)_etext))
 		ip = (unsigned long)__va(__pa_symbol(ip));
-
+#endif
 	return ip;
 }
 
Signature · 1 line
1.8.4
maintainer
#1 lore raw
Quoted 2 lines · On Wed, 4 Jun 2014 17:42:46 +0200 Petr Mladek <[email protected]> wrote:

This is just a tiny optimization. The remapping is not needed when the kernel text mapping is read write all the time.

This is true, but I think I rather have it still do it the same. The less variables in the code modification the better. The more changes per config option, the less things tend to get tested.

This is a micro optimization to something that is hardly a fast path.

-- Steve

Quoted 28 lines
---
 arch/x86/kernel/ftrace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/ftrace.c +2 -1
index cbc4a91b131e..a7a517bb793e 100644
@@ -79,6 +79,7 @@ within(unsigned long addr, unsigned long start, unsigned long end)
 
 static unsigned long text_ip_addr(unsigned long ip)
 {
+#ifdef CONFIG_DEBUG_RODATA
 	/*
 	 * On x86_64, kernel text mappings are mapped read-only with
 	 * CONFIG_DEBUG_RODATA. So we use the kernel identity mapping instead
@@ -89,7 +90,7 @@ static unsigned long text_ip_addr(unsigned long ip)
 	 */
 	if (within(ip, (unsigned long)_text, (unsigned long)_etext))
 		ip = (unsigned long)__va(__pa_symbol(ip));
-
+#endif
 	return ip;
 }
 
#2 lore raw
Quoted 11 lines · Steven Rostedt
Quoted 2 lines · On Wed, 4 Jun 2014 17:42:46 +0200 Petr Mladek <[email protected]> wrote:

This is just a tiny optimization. The remapping is not needed when the kernel text mapping is read write all the time.

This is true, but I think I rather have it still do it the same. The less variables in the code modification the better. The more changes per config option, the less things tend to get tested.

This is a micro optimization to something that is hardly a fast path.

It makes sense. Let's leave it as is.

Best Regards,
Petr

Quoted 29 lines
Quoted 28 lines
---
 arch/x86/kernel/ftrace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/ftrace.c +2 -1
index cbc4a91b131e..a7a517bb793e 100644
@@ -79,6 +79,7 @@ within(unsigned long addr, unsigned long start, unsigned long end)
 
 static unsigned long text_ip_addr(unsigned long ip)
 {
+#ifdef CONFIG_DEBUG_RODATA
 	/*
 	 * On x86_64, kernel text mappings are mapped read-only with
 	 * CONFIG_DEBUG_RODATA. So we use the kernel identity mapping instead
@@ -89,7 +90,7 @@ static unsigned long text_ip_addr(unsigned long ip)
 	 */
 	if (within(ip, (unsigned long)_text, (unsigned long)_etext))
 		ip = (unsigned long)__va(__pa_symbol(ip));
-
+#endif
 	return ip;
 }