2007-03-30 David Smith <dsmith@redhat.com>
+ PR 2341
+ * translate.cxx (c_unparser::emit_locks): No longer emits a read
+ lock for global variables that are only written to in begin/end
+ probes.
+ (c_unparser::emit_unlocks): Ditto.
+ (translate_pass): Runs a varuse_collecting_visitor over probes
+ that need global variable locks for use in
+ emit_locks()/emit_unlocks().
+
* stap.1.in: Corrected probe overload processing text.
2007-03-29 David Smith <dsmith@redhat.com>
unsigned tmpvar_counter;
unsigned label_counter;
+ varuse_collecting_visitor vcv_needs_global_locks;
+
map<string, string> probe_contents;
c_unparser (systemtap_session* ss):
else if (read_p && !write_p) { read_p = false; write_p = true; }
}
+ // We don't need to read lock "read-mostly" global variables. A
+ // "read-mostly" global variable is only written to within
+ // probes that don't need global variable locking (such as
+ // begin/end probes). If vcv_needs_global_locks doesn't mark
+ // the global as written to, then we don't have to lock it
+ // here to read it safely.
+ if (read_p && !write_p)
+ {
+ if (vcv_needs_global_locks.written.find(v)
+ == vcv_needs_global_locks.written.end())
+ continue;
+ }
+
string lockcall =
string (write_p ? "write" : "read") +
"_trylock (& global_" + v->name + "_lock)";
bool write_p = vut.written.find(v) != vut.written.end();
if (!read_p && !write_p) continue;
- numvars ++;
- o->newline(-1) << "unlock_" << v->name << ":";
- o->indent(1);
-
// Duplicate lock flipping logic from above
if (v->type == pe_stats)
{
else if (read_p && !write_p) { read_p = false; write_p = true; }
}
+ // Duplicate "read-mostly" global variable logic from above.
+ if (read_p && !write_p)
+ {
+ if (vcv_needs_global_locks.written.find(v)
+ == vcv_needs_global_locks.written.end())
+ continue;
+ }
+
+ numvars ++;
+ o->newline(-1) << "unlock_" << v->name << ":";
+ o->indent(1);
+
if (session->verbose>1)
clog << v->name << "[" << (read_p ? "r" : "")
<< (write_p ? "w" : "") << "] ";
s.up->emit_function (s.functions[i]);
}
+ // Run a varuse_collecting_visitor over probes that need global
+ // variable locks. We'll use this information later in
+ // emit_locks()/emit_unlocks().
+ for (unsigned i=0; i<s.probes.size(); i++)
+ {
+ if (s.probes[i]->needs_global_locks())
+ s.probes[i]->body->visit (&cup.vcv_needs_global_locks);
+ }
+
for (unsigned i=0; i<s.probes.size(); i++)
s.up->emit_probe (s.probes[i]);