From df8fadee215f81b07f809f4d3ebb016e390f2c9b Mon Sep 17 00:00:00 2001 From: fche Date: Mon, 22 Aug 2005 19:14:35 +0000 Subject: [PATCH] 2005-08-22 Frank Ch. Eigler PR systemtap/1134 * elaborate.h (module_fds): New member in systemtap_session. * tapsets.cxx (dwarf_derived_probe ctor): Open /sys/module/$MOD/.text for the duration of a systemtap session, to lock module in memory. --- ChangeLog | 7 +++++++ elaborate.h | 3 +++ tapsets.cxx | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 56df0301a..d5b8d033b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-08-22 Frank Ch. Eigler + + PR systemtap/1134 + * elaborate.h (module_fds): New member in systemtap_session. + * tapsets.cxx (dwarf_derived_probe ctor): Open /sys/module/$MOD/.text + for the duration of a systemtap session, to lock module in memory. + 2005-08-21 Frank Ch. Eigler PR systemtap/1195, systemtap/1193 diff --git a/elaborate.h b/elaborate.h index c3c35fee6..43816e61a 100644 --- a/elaborate.h +++ b/elaborate.h @@ -231,6 +231,9 @@ struct systemtap_session std::vector probes; std::vector embeds; + // module-referencing file handles + std::map module_fds; + // unparser data translator_output* op; unparser* up; diff --git a/tapsets.cxx b/tapsets.cxx index 43f18c663..348340333 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -22,6 +22,7 @@ #include extern "C" { +#include #include #include #include @@ -1484,6 +1485,22 @@ dwarf_derived_probe::dwarf_derived_probe (dwarf_query & q, module_bias(q.dw.module_bias), has_return (q.has_return) { + // Lock the kernel module in memory. + if (module_name != TOK_KERNEL) + { + // XXX: There is a race window here, between the time that libdw + // opened up this same file for its relocation duties, and now. + int fd = q.sess.module_fds[module_name]; + if (fd == 0) + { + string sys_module = "/sys/module/" + module_name + "/sections/.text"; + fd = open (sys_module.c_str(), O_RDONLY); + if (fd < 0) + throw semantic_error ("error opening module refcount-bumping file."); + q.sess.module_fds[module_name] = fd; + } + } + // first synthesize an "expanded" location vector comps; comps.push_back -- 2.43.5