diff options
author | hunt <hunt> | 2007-03-14 16:13:33 +0000 |
---|---|---|
committer | hunt <hunt> | 2007-03-14 16:13:33 +0000 |
commit | 8c235ce57600584d3126ad86520b4fb44765c8ec (patch) | |
tree | 4a7ee542bda895a54edbb5863d68bce19d4f135f /runtime/print_new.c | |
parent | fbbb89fffb3533a3b4fb63c15eaeaae6956391eb (diff) | |
download | systemtap-steved-8c235ce57600584d3126ad86520b4fb44765c8ec.tar.gz systemtap-steved-8c235ce57600584d3126ad86520b4fb44765c8ec.tar.xz systemtap-steved-8c235ce57600584d3126ad86520b4fb44765c8ec.zip |
2007-03-14 Martin Hunt <hunt@redhat.com>
* bench2/bench.rb: Updated to work with new transport
and new itest.c.
* bench2/Makefile: Updated for new itest.c
* bench2/itest.c: Rewritten to use multiple threads
and automatically divide the workload among the threads.
* print.c (_stp_print_flush): Move to print_new.c and
print_old.c.
* print_new.c: New file containing _stp_print_flush()
for the new transport.
* print_old.c: Ditto for old transport.
* runtime.h (STP_OLD_TRANSPORT): Define
(errk): Define.
(MAXSTRINGLEN): Define if not already defined.
* io.c (_stp_vlog): Use _stp_ctl_write().
Diffstat (limited to 'runtime/print_new.c')
-rw-r--r-- | runtime/print_new.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/runtime/print_new.c b/runtime/print_new.c new file mode 100644 index 00000000..a1f1274d --- /dev/null +++ b/runtime/print_new.c @@ -0,0 +1,64 @@ +/* -*- linux-c -*- + * Print Flush Function + * Copyright (C) 2007 Red Hat Inc. + * + * This file is part of systemtap, and is free software. You can + * redistribute it and/or modify it under the terms of the GNU General + * Public License (GPL); either version 2, or (at your option) any + * later version. + */ + +/** Send the print buffer to the transport now. + * Output accumulates in the print buffer until it + * is filled, or this is called. This MUST be called before returning + * from a probe or accumulated output in the print buffer will be lost. + * + * @note Preemption must be disabled to use this. + */ +spinlock_t _stp_print_lock = SPIN_LOCK_UNLOCKED; + +void _stp_print_flush (void) +{ + _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); + uint32_t len = pb->len; + + /* check to see if there is anything in the buffer */ + if (likely (len == 0)) + return; + + pb->len = 0; + + if (unlikely(!_stp_utt || _stp_utt->trace_state != Utt_trace_running)) + return; + +#ifdef STP_BULKMODE + { +#ifdef NO_PERCPU_HEADERS + void *buf = relay_reserve(_stp_utt->rchan, len); + if (likely(buf)) + memcpy(buf, pb->buf, len); + else + atomic_inc (&_stp_transport_failures); +#else + struct _stp_trace *t = relay_reserve(_stp_utt->rchan, sizeof(*t) + len); + if (likely(t)) { + t->sequence = _stp_seq_inc(); + t->pdu_len = len; + memcpy((void *) t + sizeof(*t), pb->buf, len); + } else + atomic_inc (&_stp_transport_failures); +#endif + } +#else + { + void *buf; + spin_lock(&_stp_print_lock); + buf = relay_reserve(_stp_utt->rchan, len); + if (likely(buf)) + memcpy(buf, pb->buf, len); + else + atomic_inc (&_stp_transport_failures); + spin_unlock(&_stp_print_lock); + } +#endif /* STP_BULKMODE */ +} |