summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhiramatu <hiramatu>2008-03-15 00:02:00 +0000
committerhiramatu <hiramatu>2008-03-15 00:02:00 +0000
commit42cb22bd8d3108863152cd2a26e787f508cfae6b (patch)
tree1db48af17d84ba14243575060ad0e7a6fa7549b6
parentecf194547a1efcc82a6f77862a25c9327f55d011 (diff)
downloadsystemtap-steved-42cb22bd8d3108863152cd2a26e787f508cfae6b.tar.gz
systemtap-steved-42cb22bd8d3108863152cd2a26e787f508cfae6b.tar.xz
systemtap-steved-42cb22bd8d3108863152cd2a26e787f508cfae6b.zip
2008-03-14 Masami Hiramatsu <mhiramat@redhat.com>
PR 3542 * buildrun.cxx (compile_pass): Add an autoconf to check the kernel supports batch unregistration. * tapsets.cxx (dwarf_derived_probe_group::emit_module_decls): Add an array of probe pointers for batch unregistration. * tapsets.cxx (dwarf_derived_probe_group::emit_module_exit): Use unregister_k(ret)probes if it is supported. * runtime/autoconf-unregister-kprobes.c : New file.
-rw-r--r--ChangeLog10
-rw-r--r--buildrun.cxx1
-rw-r--r--runtime/ChangeLog5
-rw-r--r--runtime/autoconf-unregister-kprobes.c4
-rw-r--r--tapsets.cxx31
5 files changed, 51 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 280cb68e..5e4922e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-03-14 Masami Hiramatsu <mhiramat@redhat.com>
+
+ PR 3542
+ * buildrun.cxx (compile_pass): Add an autoconf to check the kernel
+ supports batch unregistration.
+ * tapsets.cxx (dwarf_derived_probe_group::emit_module_decls): Add an
+ array of probe pointers for batch unregistration.
+ * tapsets.cxx (dwarf_derived_probe_group::emit_module_exit): Use
+ unregister_k(ret)probes if it is supported.
+
2008-03-13 Frank Ch. Eigler <fche@elastic.org>
PR 5928.
diff --git a/buildrun.cxx b/buildrun.cxx
index 8504cf62..f3e72272 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -95,6 +95,7 @@ compile_pass (systemtap_session& s)
o << module_cflags << " += $(call stap_check_build, $(SYSTEMTAP_RUNTIME)/autoconf-x86-uniregs.c, -DSTAPCONF_X86_UNIREGS,)" << endl;
o << module_cflags << " += $(call stap_check_build, $(SYSTEMTAP_RUNTIME)/autoconf-nameidata.c, -DSTAPCONF_NAMEIDATA_CLEANUP,)" << endl;
+ o << module_cflags << " += $(call stap_check_build, $(SYSTEMTAP_RUNTIME)/autoconf-unregister-kprobes.c, -DSTAPCONF_UNREGISTER_KPROBES,)" << endl;
for (unsigned i=0; i<s.macros.size(); i++)
o << "EXTRA_CFLAGS += -D " << lex_cast_qstring(s.macros[i]) << endl;
diff --git a/runtime/ChangeLog b/runtime/ChangeLog
index 054def68..92a6eb12 100644
--- a/runtime/ChangeLog
+++ b/runtime/ChangeLog
@@ -1,3 +1,8 @@
+2008-03-14 Masami Hiramatsu <mhiramat@redhat.com>
+
+ PR 3542
+ * autoconf-unregister-kprobes.c : New file.
+
2008-03-10 Dave Brolley <brolley@redhat.com>
PR5189
diff --git a/runtime/autoconf-unregister-kprobes.c b/runtime/autoconf-unregister-kprobes.c
new file mode 100644
index 00000000..793891da
--- /dev/null
+++ b/runtime/autoconf-unregister-kprobes.c
@@ -0,0 +1,4 @@
+#include <linux/kprobes.h>
+
+void * x = (void *)unregister_kprobes;
+void * y = (void *)unregister_kretprobes;
diff --git a/tapsets.cxx b/tapsets.cxx
index 147ea3f0..5ed8017d 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -3932,6 +3932,11 @@ dwarf_derived_probe_group::emit_module_decls (systemtap_session& s)
s.op->newline() << "static int enter_kretprobe_probe (struct kretprobe_instance *inst,";
s.op->line() << " struct pt_regs *regs);";
+ // Emit an array of kprobe/kretprobe pointers
+ s.op->newline() << "#if defined(STAPCONF_UNREGISTER_KPROBES)";
+ s.op->newline() << "static void * stap_unreg_kprobes[" << probes_by_module.size() << "];";
+ s.op->newline() << "#endif";
+
// Emit the actual probe list.
// NB: we used to plop a union { struct kprobe; struct kretprobe } into
@@ -4102,16 +4107,42 @@ dwarf_derived_probe_group::emit_module_init (systemtap_session& s)
void
dwarf_derived_probe_group::emit_module_exit (systemtap_session& s)
{
+ //Unregister kprobes by batch interfaces.
+ s.op->newline() << "#if defined(STAPCONF_UNREGISTER_KPROBES)";
+ s.op->newline() << "j = 0;";
+ s.op->newline() << "for (i=0; i<" << probes_by_module.size() << "; i++) {";
+ s.op->newline(1) << "struct stap_dwarf_probe *sdp = & stap_dwarf_probes[i];";
+ s.op->newline() << "struct stap_dwarf_kprobe *kp = & stap_dwarf_kprobes[i];";
+ s.op->newline() << "if (! sdp->registered_p) continue;";
+ s.op->newline() << "if (!sdp->return_p)";
+ s.op->newline(1) << "stap_unreg_kprobes[j++] = &kp->u.kp;";
+ s.op->newline(-2) << "}";
+ s.op->newline() << "unregister_kprobes((struct kprobe **)stap_unreg_kprobes, j);";
+ s.op->newline() << "j = 0;";
+ s.op->newline() << "for (i=0; i<" << probes_by_module.size() << "; i++) {";
+ s.op->newline(1) << "struct stap_dwarf_probe *sdp = & stap_dwarf_probes[i];";
+ s.op->newline() << "struct stap_dwarf_kprobe *kp = & stap_dwarf_kprobes[i];";
+ s.op->newline() << "if (! sdp->registered_p) continue;";
+ s.op->newline() << "if (sdp->return_p)";
+ s.op->newline(1) << "stap_unreg_kprobes[j++] = &kp->u.krp;";
+ s.op->newline(-2) << "}";
+ s.op->newline() << "unregister_kretprobes((struct kretprobe **)stap_unreg_kprobes, j);";
+ s.op->newline() << "#endif";
+
s.op->newline() << "for (i=0; i<" << probes_by_module.size() << "; i++) {";
s.op->newline(1) << "struct stap_dwarf_probe *sdp = & stap_dwarf_probes[i];";
s.op->newline() << "struct stap_dwarf_kprobe *kp = & stap_dwarf_kprobes[i];";
s.op->newline() << "if (! sdp->registered_p) continue;";
s.op->newline() << "if (sdp->return_p) {";
+ s.op->newline() << "#if !defined(STAPCONF_UNREGISTER_KPROBES)";
s.op->newline(1) << "unregister_kretprobe (&kp->u.krp);";
+ s.op->newline() << "#endif";
s.op->newline() << "atomic_add (kp->u.krp.nmissed, & skipped_count);";
s.op->newline() << "atomic_add (kp->u.krp.kp.nmissed, & skipped_count);";
s.op->newline(-1) << "} else {";
+ s.op->newline() << "#if !defined(STAPCONF_UNREGISTER_KPROBES)";
s.op->newline(1) << "unregister_kprobe (&kp->u.kp);";
+ s.op->newline() << "#endif";
s.op->newline() << "atomic_add (kp->u.kp.nmissed, & skipped_count);";
s.op->newline(-1) << "}";
s.op->newline() << "sdp->registered_p = 0;";