[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130628130452.1132.85665.stgit@mhiramat-M0-7522>
Date: Fri, 28 Jun 2013 22:04:52 +0900
From: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
To: Oleg Nesterov <oleg@...hat.com>,
Steven Rostedt <rostedt@...dmis.org>
Cc: Frederic Weisbecker <fweisbec@...il.com>,
"zhangwei(Jovi)" <jovi.zhangwei@...wei.com>,
Ingo Molnar <mingo@...hat.com>,
Srikar Dronamraju <srikar@...ux.vnet.ibm.com>,
lkml <linux-kernel@...r.kernel.org>
Subject: [PATCH] tracing/kprobe: Recover old array if fails to enable kprobe
Make enable_trace_probe to recover (writeback) the old file array
and free new one if we fail to enable the kprobe.
However, this MUST NOT happen at this time except for unknown
bug or changing the implementation of enable_kprobe(), because
usual failure cases (not registered or gone) are already filtered.
Thus I just add a WARN_ON() on the error path.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Reported-by: Oleg Nesterov <oleg@...hat.com>
Reported-by: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
Cc: "zhangwei(Jovi)" <jovi.zhangwei@...wei.com>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...hat.com>
---
kernel/trace/trace_kprobe.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index f237417..d29773e 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -202,6 +202,20 @@ static int trace_probe_nr_files(struct trace_probe *tp)
static DEFINE_MUTEX(probe_enable_lock);
+static int __enable_trace_probe(struct trace_probe *tp)
+{
+ int ret = 0;
+
+ if (trace_probe_is_registered(tp) && !trace_probe_has_gone(tp)) {
+ if (trace_probe_is_return(tp))
+ ret = enable_kretprobe(&tp->rp);
+ else
+ ret = enable_kprobe(&tp->rp.kp);
+ WARN_ON(ret);/* This must succeed. */
+ }
+ return ret;
+}
+
/*
* Enable trace_probe
* if the file is NULL, enable "perf" handler, or enable "trace" handler.
@@ -232,19 +246,21 @@ enable_trace_probe(struct trace_probe *tp, struct ftrace_event_file *file)
rcu_assign_pointer(tp->files, new);
tp->flags |= TP_FLAG_TRACE;
+ ret = __enable_trace_probe(tp);
+ if (ret < 0) {
+ /* Write back the old list */
+ rcu_assign_pointer(tp->files, old);
+ old = new; /* "new" must be freed */
+ }
+
if (old) {
/* Make sure the probe is done with old files */
synchronize_sched();
kfree(old);
}
- } else
+ } else {
tp->flags |= TP_FLAG_PROFILE;
-
- if (trace_probe_is_registered(tp) && !trace_probe_has_gone(tp)) {
- if (trace_probe_is_return(tp))
- ret = enable_kretprobe(&tp->rp);
- else
- ret = enable_kprobe(&tp->rp.kp);
+ ret = __enable_trace_probe(tp);
}
out_unlock:
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists