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>,
Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH 4/5] [PATCH 4/5] tracing: enable records during the module load
Date: Tue, 13 Oct 2009 16:33:53 -0400 [thread overview]
Message-ID: <20091013203425.896285120@goodmis.org> (raw)
In-Reply-To: 20091013203349.814936710@goodmis.org
[-- Attachment #1: 0004-tracing-enable-records-during-the-module-load.patch --]
[-- Type: text/plain, Size: 2697 bytes --]
From: Jiri Olsa <jolsa@redhat.com>
I was debuging some module using "function" and "function_graph" tracers
and noticed, that if you load module after you enabled tracing, the module's
hooks will convert only to NOP instructions.
The attached patch enables modules' hooks if there's function
trace allready on, thus allowing to trace module functions.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
LKML-Reference: <1255183220-15640-1-git-send-email-jolsa@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 38 ++++++++++++++++++++++++++++++--------
1 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 0c799d1..aaea9cd 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1270,12 +1270,34 @@ static int ftrace_update_code(struct module *mod)
ftrace_new_addrs = p->newlist;
p->flags = 0L;
- /* convert record (i.e, patch mcount-call with NOP) */
- if (ftrace_code_disable(mod, p)) {
- p->flags |= FTRACE_FL_CONVERTED;
- ftrace_update_cnt++;
- } else
+ /*
+ * Do the initial record convertion from mcount jump
+ * to the NOP instructions.
+ */
+ if (!ftrace_code_disable(mod, p)) {
ftrace_free_rec(p);
+ continue;
+ }
+
+ p->flags |= FTRACE_FL_CONVERTED;
+ ftrace_update_cnt++;
+
+ /*
+ * If the tracing is enabled, go ahead and enable the record.
+ *
+ * The reason not to enable the record immediatelly is the
+ * inherent check of ftrace_make_nop/ftrace_make_call for
+ * correct previous instructions. Making first the NOP
+ * conversion puts the module to the correct state, thus
+ * passing the ftrace_make_call check.
+ */
+ if (ftrace_start_up) {
+ int failed = __ftrace_replace_code(p, 1);
+ if (failed) {
+ ftrace_bug(failed, p->ip);
+ ftrace_free_rec(p);
+ }
+ }
}
stop = ftrace_now(raw_smp_processor_id());
@@ -2609,7 +2631,7 @@ static __init int ftrace_init_dyn_debugfs(struct dentry *d_tracer)
return 0;
}
-static int ftrace_convert_nops(struct module *mod,
+static int ftrace_process_locs(struct module *mod,
unsigned long *start,
unsigned long *end)
{
@@ -2669,7 +2691,7 @@ static void ftrace_init_module(struct module *mod,
{
if (ftrace_disabled || start == end)
return;
- ftrace_convert_nops(mod, start, end);
+ ftrace_process_locs(mod, start, end);
}
static int ftrace_module_notify(struct notifier_block *self,
@@ -2730,7 +2752,7 @@ void __init ftrace_init(void)
last_ftrace_enabled = ftrace_enabled = 1;
- ret = ftrace_convert_nops(NULL,
+ ret = ftrace_process_locs(NULL,
__start_mcount_loc,
__stop_mcount_loc);
--
1.6.3.3
next prev parent reply other threads:[~2009-10-13 20:36 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-13 20:33 [PATCH 0/5] [GIT PULL][2.6.33] tracing: various updates Steven Rostedt
2009-10-13 20:33 ` [PATCH 1/5] [PATCH 1/5] function-graph/x86: replace unbalanced ret with jmp Steven Rostedt
2009-10-13 20:47 ` Mathieu Desnoyers
2009-10-13 21:10 ` Steven Rostedt
2009-10-13 21:21 ` Mathieu Desnoyers
2009-10-13 21:26 ` Steven Rostedt
2009-10-13 22:32 ` Mathieu Desnoyers
2009-10-13 21:02 ` Frederic Weisbecker
2009-10-13 21:12 ` Steven Rostedt
2009-10-13 22:26 ` Frederic Weisbecker
2009-10-14 6:58 ` [tip:tracing/core] function-graph/x86: Replace " tip-bot for Steven Rostedt
2009-10-13 20:33 ` [PATCH 2/5] [PATCH 2/5] tracing: export symbols for kernel lock tracepoints Steven Rostedt
2009-10-13 20:43 ` Frederic Weisbecker
2009-10-13 21:14 ` Steven Rostedt
2009-10-13 20:33 ` [PATCH 3/5] [PATCH 3/5] tracing: support multiple pids in set_pid_ftrace file Steven Rostedt
2009-10-14 6:58 ` [tip:tracing/core] tracing: Support " tip-bot for jolsa@redhat.com
2009-10-13 20:33 ` Steven Rostedt [this message]
2009-10-14 6:59 ` [tip:tracing/core] tracing: Enable records during the module load tip-bot for Jiri Olsa
2009-10-13 20:33 ` [PATCH 5/5] [PATCH 5/5] tracing: enabling "__cold" functions Steven Rostedt
2009-10-14 6:59 ` [tip:tracing/core] tracing: Enable " tip-bot for 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=20091013203425.896285120@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--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