diff options
author | hiramatu <hiramatu> | 2008-03-15 00:02:00 +0000 |
---|---|---|
committer | hiramatu <hiramatu> | 2008-03-15 00:02:00 +0000 |
commit | 42cb22bd8d3108863152cd2a26e787f508cfae6b (patch) | |
tree | 1db48af17d84ba14243575060ad0e7a6fa7549b6 /tapsets.cxx | |
parent | ecf194547a1efcc82a6f77862a25c9327f55d011 (diff) | |
download | systemtap-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.
Diffstat (limited to 'tapsets.cxx')
-rw-r--r-- | tapsets.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
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;"; |