[tip:perf/core] kprobes: Separate kprobe optimizing code from optimizer

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: tip-bot for Masami Hiramatsu
Date: Monday, December 6, 2010 - 11:16 am

Commit-ID:  61f4e13ffd85c037a942c5b7fd13f2b0c3162862
Gitweb:     http://git.kernel.org/tip/61f4e13ffd85c037a942c5b7fd13f2b0c3162862
Author:     Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
AuthorDate: Fri, 3 Dec 2010 18:54:03 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 6 Dec 2010 17:59:30 +0100

kprobes: Separate kprobe optimizing code from optimizer

Separate kprobe optimizing code from optimizer, this
will make easy to introducing unoptimizing code in
optimizer.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: 2nddept-manager@sdl.hitachi.co.jp
LKML-Reference: <20101203095403.2961.91201.stgit@ltc236.sdl.hitachi.co.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/kprobes.c |   43 ++++++++++++++++++++++++++-----------------
 1 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index ab99caf..1f4f9b9 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -427,26 +427,14 @@ static void kprobe_optimizer(struct work_struct *work);
 static DECLARE_DELAYED_WORK(optimizing_work, kprobe_optimizer);
 #define OPTIMIZE_DELAY 5
 
-/* Kprobe jump optimizer */
-static __kprobes void kprobe_optimizer(struct work_struct *work)
+/*
+ * Optimize (replace a breakpoint with a jump) kprobes listed on
+ * optimizing_list.
+ */
+static __kprobes void do_optimize_kprobes(void)
 {
 	struct optimized_kprobe *op, *tmp;
 
-	/* Lock modules while optimizing kprobes */
-	mutex_lock(&module_mutex);
-	mutex_lock(&kprobe_mutex);
-	if (kprobes_all_disarmed || !kprobes_allow_optimization)
-		goto end;
-
-	/*
-	 * Wait for quiesence period to ensure all running interrupts
-	 * are done. Because optprobe may modify multiple instructions
-	 * there is a chance that Nth instruction is interrupted. In that
-	 * case, running interrupt can return to 2nd-Nth byte of jump
-	 * instruction. This wait is for avoiding it.
-	 */
-	synchronize_sched();
-
 	/*
 	 * The optimization/unoptimization refers online_cpus via
 	 * stop_machine() and cpu-hotplug modifies online_cpus.
@@ -467,6 +455,27 @@ static __kprobes void kprobe_optimizer(struct work_struct *work)
 	}
 	mutex_unlock(&text_mutex);
 	put_online_cpus();
+}
+
+/* Kprobe jump optimizer */
+static __kprobes void kprobe_optimizer(struct work_struct *work)
+{
+	/* Lock modules while optimizing kprobes */
+	mutex_lock(&module_mutex);
+	mutex_lock(&kprobe_mutex);
+	if (kprobes_all_disarmed || !kprobes_allow_optimization)
+		goto end;
+
+	/*
+	 * Wait for quiesence period to ensure all running interrupts
+	 * are done. Because optprobe may modify multiple instructions
+	 * there is a chance that Nth instruction is interrupted. In that
+	 * case, running interrupt can return to 2nd-Nth byte of jump
+	 * instruction. This wait is for avoiding it.
+	 */
+	synchronize_sched();
+
+	do_optimize_kprobes();
 end:
 	mutex_unlock(&kprobe_mutex);
 	mutex_unlock(&module_mutex);
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH -tip v5 0/8] Kprobes/x86: Batch optimization support, Masami Hiramatsu, (Fri Dec 3, 2:53 am)
[PATCH -tip v5 4/8] kprobes: Support delayed unoptimizing, Masami Hiramatsu, (Fri Dec 3, 2:54 am)
[PATCH -tip v5 5/8] kprobes: Reuse unused kprobe, Masami Hiramatsu, (Fri Dec 3, 2:54 am)
[tip:perf/core] kprobes: Rename old_p to more appropriate name, tip-bot for Masami H ..., (Mon Dec 6, 11:15 am)
[tip:perf/core] kprobes: Cleanup disabling and unregisteri ..., tip-bot for Masami H ..., (Mon Dec 6, 11:16 am)
[tip:perf/core] kprobes: Separate kprobe optimizing code f ..., tip-bot for Masami H ..., (Mon Dec 6, 11:16 am)
[tip:perf/core] kprobes: Support delayed unoptimizing, tip-bot for Masami H ..., (Mon Dec 6, 11:16 am)
[tip:perf/core] kprobes: Reuse unused kprobe, tip-bot for Masami H ..., (Mon Dec 6, 11:17 am)
[tip:perf/core] x86: Introduce text_poke_smp_batch() for b ..., tip-bot for Masami H ..., (Mon Dec 6, 11:17 am)
[tip:perf/core] kprobes: Use text_poke_smp_batch for optim ..., tip-bot for Masami H ..., (Mon Dec 6, 11:17 am)
[tip:perf/core] kprobes: Use text_poke_smp_batch for unopt ..., tip-bot for Masami H ..., (Mon Dec 6, 11:18 am)