[RFC PATCH tracing/kprobes] kprobes: Call vmalloc_sync_all() foravoiding in-kernel paging on kprobes

From: Masami Hiramatsu
Date: Tue Sep 08 2009 - 12:53:42 EST


Call vmalloc_sync_all() before registering new kprobes and using new
instruction buffers to sync page table entries of the pages on where
kprobes data structure and instruction buffers are.
With this patch, kprobes can avoid in-kernel on-demand paging on these
kprobes, and it allows kprobes to put probes on page-fault path.

Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Cc: Ananth N Mavinakayanahalli <ananth@xxxxxxxxxx>
Cc: Jim Keniston <jkenisto@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
---

kernel/kprobes.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 00d01b0..7cc8266 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -44,6 +44,7 @@
#include <linux/debugfs.h>
#include <linux/kdebug.h>
#include <linux/memory.h>
+#include <linux/vmalloc.h>

#include <asm-generic/sections.h>
#include <asm/cacheflush.h>
@@ -191,6 +192,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(void)
kfree(kip);
return NULL;
}
+ vmalloc_sync_all(); /* Prohibit on-demand kernel paging on kprobe */
INIT_LIST_HEAD(&kip->list);
list_add(&kip->list, &kprobe_insn_pages);
memset(kip->slot_used, SLOT_CLEAN, INSNS_PER_PAGE);
@@ -724,6 +726,7 @@ int __kprobes register_kprobe(struct kprobe *p)
}
preempt_enable();

+ vmalloc_sync_all(); /* Prohibit on-demand kernel paging on kprobe */
p->nmissed = 0;
INIT_LIST_HEAD(&p->list);
mutex_lock(&kprobe_mutex);


--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: mhiramat@xxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/