public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Subject: [PATCH 12/15] ftrace: Return record ip addr for ftrace_location()
Date: Fri, 18 May 2012 09:09:10 -0400	[thread overview]
Message-ID: <20120518131051.251652937@goodmis.org> (raw)
In-Reply-To: 20120518130858.392919640@goodmis.org

[-- Attachment #1: Type: text/plain, Size: 3140 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

ftrace_location() is passed an addr, and returns 1 if the addr is
on a ftrace nop (or caller to ftrace_caller), and 0 otherwise.

To let kprobes know if it should move a breakpoint or not, it
must return the actual addr that is the start of the ftrace nop.
This way a kprobe placed on the location of a ftrace nop, can
instead be placed on the instruction after the nop. Even if the
probe addr is on the second or later byte of the nop, it can
simply be moved forward.

Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 include/linux/ftrace.h |    2 +-
 kernel/trace/ftrace.c  |   16 ++++++++++------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index d32cc5e..609948e 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -295,7 +295,7 @@ struct dyn_ftrace *ftrace_rec_iter_record(struct ftrace_rec_iter *iter);
 int ftrace_update_record(struct dyn_ftrace *rec, int enable);
 int ftrace_test_record(struct dyn_ftrace *rec, int enable);
 void ftrace_run_stop_machine(int command);
-int ftrace_location(unsigned long ip);
+unsigned long ftrace_location(unsigned long ip);
 
 extern ftrace_func_t ftrace_trace_function;
 
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index dd091c8..ef08262 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1393,7 +1393,7 @@ static int ftrace_cmp_recs(const void *a, const void *b)
 	return 0;
 }
 
-static int ftrace_location_range(unsigned long start, unsigned long end)
+static unsigned long ftrace_location_range(unsigned long start, unsigned long end)
 {
 	struct ftrace_page *pg;
 	struct dyn_ftrace *rec;
@@ -1410,7 +1410,7 @@ static int ftrace_location_range(unsigned long start, unsigned long end)
 			      sizeof(struct dyn_ftrace),
 			      ftrace_cmp_recs);
 		if (rec)
-			return 1;
+			return rec->ip;
 	}
 
 	return 0;
@@ -1420,12 +1420,12 @@ static int ftrace_location_range(unsigned long start, unsigned long end)
  * ftrace_location - return true if the ip giving is a traced location
  * @ip: the instruction pointer to check
  *
- * Returns 1 if @ip given is a pointer to a ftrace location.
+ * Returns rec->ip if @ip given is a pointer to a ftrace location.
  * That is, the instruction that is either a NOP or call to
  * the function tracer. It checks the ftrace internal tables to
  * determine if the address belongs or not.
  */
-int ftrace_location(unsigned long ip)
+unsigned long ftrace_location(unsigned long ip)
 {
 	return ftrace_location_range(ip, ip);
 }
@@ -1442,8 +1442,12 @@ int ftrace_location(unsigned long ip)
  */
 int ftrace_text_reserved(void *start, void *end)
 {
-	return ftrace_location_range((unsigned long)start,
-				     (unsigned long)end);
+	unsigned long ret;
+
+	ret = ftrace_location_range((unsigned long)start,
+				    (unsigned long)end);
+
+	return (int)!!ret;
 }
 
 static void __ftrace_hash_rec_update(struct ftrace_ops *ops,
-- 
1.7.10



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2012-05-18 13:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-18 13:08 [PATCH 00/15] [GIT PULL] tracing: Updates for 3.5 Steven Rostedt
2012-05-18 13:08 ` [PATCH 01/15] tracing: Clean up tracing_mark_write() Steven Rostedt
2012-05-18 13:09 ` [PATCH 02/15] ring-buffer: Make removal of ring buffer pages atomic Steven Rostedt
2012-05-18 13:09 ` [PATCH 03/15] ring-buffer: Make addition of pages in ring buffer atomic Steven Rostedt
2012-05-18 13:09 ` [PATCH 04/15] ring-buffer: Add integrity check at end of iter read Steven Rostedt
2012-05-18 13:09 ` [PATCH 05/15] ring-buffer: Reset head page before running self test Steven Rostedt
2012-05-18 13:09 ` [PATCH 06/15] tracing: Check return value of tracing_dentry_percpu() Steven Rostedt
2012-05-18 13:09 ` [PATCH 07/15] tracing: change CPU ring buffer state from tracing_cpumask Steven Rostedt
2012-05-18 13:09 ` [PATCH 08/15] ftrace: Sort all function addresses, not just per page Steven Rostedt
2012-05-18 13:09 ` [PATCH 09/15] ftrace: Remove extra helper functions Steven Rostedt
2012-05-18 13:09 ` [PATCH 10/15] ftrace: Speed up search by skipping pages by address Steven Rostedt
2012-05-18 13:09 ` [PATCH 11/15] ftrace: Consolidate ftrace_location() and ftrace_text_reserved() Steven Rostedt
2012-05-18 13:09 ` Steven Rostedt [this message]
2012-05-18 14:19   ` [PATCH 12/15] ftrace: Return record ip addr for ftrace_location() Masami Hiramatsu
2012-05-18 13:09 ` [PATCH 13/15] ftrace: Make ftrace_modify_all_code() global for archs to use Steven Rostedt
2012-05-18 13:09 ` [PATCH 14/15] ftrace/x86: Have x86 ftrace use the ftrace_modify_all_code() Steven Rostedt
2012-05-18 13:09 ` [PATCH 15/15] ftrace: Remove selecting FRAME_POINTER with FUNCTION_TRACER Steven Rostedt
2012-05-19  1:43 ` [PATCH 00/15] [GIT PULL] tracing: Updates for 3.5 Steven Rostedt
2012-05-19 10:12   ` Ingo Molnar
2012-05-19 12:25     ` Steven Rostedt

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=20120518131051.251652937@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@elte.hu \
    /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