Index: tapsets.cxx =================================================================== RCS file: /cvs/systemtap/src/tapsets.cxx,v retrieving revision 1.174 diff -u -p -r1.174 tapsets.cxx --- tapsets.cxx 12 Jan 2007 16:33:17 -0000 1.174 +++ tapsets.cxx 25 Jan 2007 22:21:54 -0000 @@ -133,6 +133,7 @@ common_probe_entryfn_prologue (translato { o->newline() << "struct context* __restrict__ c;"; o->newline() << "unsigned long flags;"; + o->newline() << "cycles_t cycles_end, cycles_beg = get_cycles();"; o->newline() << "#ifdef STP_TIMING"; // NB: we truncate cycles counts to 32 bits. Perhaps it should be @@ -220,6 +221,16 @@ common_probe_entryfn_epilogue (translato o->newline() << "_stp_exit ();"; o->newline(-1) << "}"; o->newline(-1) << "}"; + o->newline() << "cycles_end = get_cycles();"; + o->newline() << "c->cycles_sum += cycles_end - cycles_beg;"; + o->newline() << "if (cycles_end - c->cycles_base > STP_ACCOUNTING_INTERVAL) {"; + o->newline(1) << "if (c->cycles_sum > STP_ACCOUNTING_THRESHOLD) {"; + o->newline(1) << "_stp_error (\"probe overhead exceeded threshold\");"; + o->newline() << "atomic_set (&session_state, STAP_SESSION_ERROR);"; + o->newline(-1) << "}"; + o->newline() << "c->cycles_base = cycles_end;"; + o->newline() << "c->cycles_sum = 0;"; + o->newline(-1) << "}"; o->newline() << "atomic_dec (&c->busy);"; o->newline(-1) << "probe_epilogue:"; // context is free Index: translate.cxx =================================================================== RCS file: /cvs/systemtap/src/translate.cxx,v retrieving revision 1.153 diff -u -p -r1.153 translate.cxx --- translate.cxx 22 Jan 2007 16:56:42 -0000 1.153 +++ translate.cxx 25 Jan 2007 22:21:54 -0000 @@ -793,6 +793,9 @@ c_unparser::emit_common_header () o->newline() << "atomic_t error_count = ATOMIC_INIT (0);"; o->newline() << "atomic_t skipped_count = ATOMIC_INIT (0);"; o->newline(); + o->newline() << "#define STP_ACCOUNTING_INTERVAL 1000000000LL"; + o->newline() << "#define STP_ACCOUNTING_THRESHOLD 500000000LL"; + o->newline(); o->newline() << "struct context {"; o->newline(1) << "atomic_t busy;"; o->newline() << "const char *probe_point;"; @@ -810,6 +813,8 @@ c_unparser::emit_common_header () o->newline() << "#ifdef STP_TIMING"; o->newline() << "Stat *statp;"; o->newline() << "#endif"; + o->newline() << "cycles_t cycles_base;"; + o->newline() << "cycles_t cycles_sum;"; o->newline() << "union {"; o->indent(1);