summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/runtime.h11
-rw-r--r--tapsets.cxx4
2 files changed, 13 insertions, 2 deletions
diff --git a/runtime/runtime.h b/runtime/runtime.h
index a95627ae..ba583aeb 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -179,6 +179,17 @@ void cleanup_module(void)
_stp_transport_close();
}
+#define pseudo_atomic_cmpxchg(v, old, new) ({\
+ int ret;\
+ unsigned long flags;\
+ local_irq_save(flags);\
+ ret = atomic_read(v);\
+ if (likely(ret == old))\
+ atomic_set(v, new);\
+ local_irq_restore(flags);\
+ ret; })
+
+
MODULE_LICENSE("GPL");
#endif /* _RUNTIME_H_ */
diff --git a/tapsets.cxx b/tapsets.cxx
index 17e315e9..21704f69 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -228,7 +228,7 @@ common_probe_entryfn_epilogue (translator_output* o,
// Check for excessive skip counts.
o->newline() << "if (unlikely (atomic_read (& skipped_count) > MAXSKIPPED)) {";
- o->newline(1) << "if (unlikely (atomic_cmpxchg(& session_state, STAP_SESSION_RUNNING, STAP_SESSION_ERROR) == STAP_SESSION_RUNNING))";
+ o->newline(1) << "if (unlikely (pseudo_atomic_cmpxchg(& session_state, STAP_SESSION_RUNNING, STAP_SESSION_ERROR) == STAP_SESSION_RUNNING))";
o->newline() << "_stp_error (\"Skipped too many probes, check MAXSKIPPED or try again with stap -t for more details.\");";
o->newline(-1) << "}";
@@ -4640,7 +4640,7 @@ uprobe_derived_probe_group::emit_module_decls (systemtap_session& s)
s.op->newline() << "#endif";
// NB: duplicates common_entryfn_epilogue, but then this is not a probe entry fn epilogue.
s.op->newline() << "if (unlikely (atomic_inc_return (& skipped_count) > MAXSKIPPED)) {";
- s.op->newline(1) << "if (unlikely (atomic_cmpxchg(& session_state, STAP_SESSION_RUNNING, STAP_SESSION_ERROR) == STAP_SESSION_RUNNING))";
+ s.op->newline(1) << "if (unlikely (pseudo_atomic_cmpxchg(& session_state, STAP_SESSION_RUNNING, STAP_SESSION_ERROR) == STAP_SESSION_RUNNING))";
s.op->newline() << "_stp_error (\"Skipped too many probes, check MAXSKIPPED or try again with stap -t for more details.\");";
s.op->newline(-1) << "}";
s.op->newline(-1) << "}";