]> sourceware.org Git - systemtap.git/commitdiff
2008-03-14 Masami Hiramatsu <mhiramat@redhat.com>
authorhiramatu <hiramatu>
Sat, 15 Mar 2008 00:02:00 +0000 (00:02 +0000)
committerhiramatu <hiramatu>
Sat, 15 Mar 2008 00:02:00 +0000 (00:02 +0000)
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.

ChangeLog
buildrun.cxx
runtime/ChangeLog
runtime/autoconf-unregister-kprobes.c [new file with mode: 0644]
tapsets.cxx

index 280cb68ee2fda247bee5229562181a68671ba133..5e4922e7ccf7e85f98843270c943e1ec3639af16 100644 (file)
--- 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.
index 8504cf62678ae0ce98ec064149aa235e0dff82d8..f3e72272a8c1e7e5cb371b04e1dd3dd1b0d21efb 100644 (file)
@@ -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;
index 054def687ab9db326a99c5ae85e2216dda064542..92a6eb12c176f095d05a33fa6d03b29cd79fc638 100644 (file)
@@ -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 (file)
index 0000000..793891d
--- /dev/null
@@ -0,0 +1,4 @@
+#include <linux/kprobes.h>
+
+void * x = (void *)unregister_kprobes;
+void * y = (void *)unregister_kretprobes;
index 147ea3f03662a21266e5609e87260ab41165ccaa..5ed8017d82eef84770ef707263dc828886a0c463 100644 (file)
@@ -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;";
This page took 0.041062 seconds and 5 git commands to generate.